@nyrra/foundry-ai
Version:
Thin Palantir Foundry provider adapters and model catalog for the Vercel AI SDK.
888 lines (879 loc) • 27 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/providers/openai.ts
var openai_exports = {};
__export(openai_exports, {
createFoundryOpenAI: () => createFoundryOpenAI
});
module.exports = __toCommonJS(openai_exports);
var import_openai = require("@ai-sdk/openai");
var import_ai2 = require("ai");
// src/config.ts
function normalizeFoundryUrl(foundryUrl) {
return foundryUrl.trim().replace(/\/+$/, "");
}
function resolveFoundryConfig(config, callerName) {
const normalizedConfig = normalizeResolvedFoundryConfig({
foundryUrl: typeof config.foundryUrl === "string" ? config.foundryUrl : "",
token: typeof config.token === "string" ? config.token : "",
attributionRid: typeof config.attributionRid === "string" ? config.attributionRid : void 0
});
if (normalizedConfig.foundryUrl.length === 0) {
throw new Error(`${callerName} requires config.foundryUrl to be a non-empty string.`);
}
if (normalizedConfig.token.length === 0) {
throw new Error(`${callerName} requires config.token to be a non-empty string.`);
}
return normalizedConfig;
}
function normalizeResolvedFoundryConfig(config) {
const attributionRid = config.attributionRid?.trim();
return {
foundryUrl: normalizeFoundryUrl(config.foundryUrl),
token: config.token.trim(),
attributionRid: attributionRid || void 0
};
}
// src/middleware.ts
var import_ai = require("ai");
function wrapFoundryLanguageModel(model, options) {
return (0, import_ai.wrapLanguageModel)({
model,
middleware: {
specificationVersion: "v3",
transformParams: async ({ params }) => {
return options.transformParams?.(params) ?? params;
}
},
modelId: options.modelId,
providerId: options.providerId
});
}
// src/models/metadata.ts
var VISION_INPUT_TYPES = /* @__PURE__ */ new Set([
"GENERIC_VISION_COMPLETION",
"GPT_WITH_VISION_COMPLETION"
]);
function createProviderModelCatalog(provider, definitions) {
return Object.freeze(
Object.fromEntries(
Object.entries(definitions).map(([modelId, definition]) => [
modelId,
createModelMetadata(provider, definition)
])
)
);
}
function modelSupportsInputType(metadata, inputType) {
return metadata.inputTypes.includes(inputType);
}
function createModelMetadata(provider, definition) {
return {
...definition,
provider,
supportsResponses: definition.inputTypes.includes("OPEN_AI_RESPONSES"),
supportsVision: definition.inputTypes.some((inputType) => VISION_INPUT_TYPES.has(inputType))
};
}
// src/models/anthropic-models.ts
var ANTHROPIC_MODEL_DEFINITIONS = {
"claude-3.5-haiku": {
rid: "ri.language-model-service..language-model.anthropic-claude-3-5-haiku",
modelIdentifier: "ANTHROPIC_CLAUDE_35_HAIKU",
displayName: "Claude 3.5 Haiku",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2024-07-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "LIGHTWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://aws.amazon.com/bedrock/claude/"
},
"claude-3.7-sonnet": {
rid: "ri.language-model-service..language-model.anthropic-claude-3-7-sonnet",
modelIdentifier: "ANTHROPIC_CLAUDE_37_SONNET",
displayName: "Claude 3.7 Sonnet",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2024-11-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://aws.amazon.com/bedrock/claude/"
},
"claude-haiku-4.5": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-5-haiku",
modelIdentifier: "ANTHROPIC_CLAUDE_45_HAIKU",
displayName: "Claude Haiku 4.5",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-07-01T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://www.anthropic.com/news/claude-haiku-4-5"
},
"claude-opus-4": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-opus",
modelIdentifier: "ANTHROPIC_CLAUDE_4_OPUS",
displayName: "Claude Opus 4",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-03-01T00:00:00Z",
performance: {
cost: "HIGH",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-4"
},
"claude-opus-4.1": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-1-opus",
modelIdentifier: "ANTHROPIC_CLAUDE_41_OPUS",
displayName: "Claude Opus 4.1",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-08-01T00:00:00Z",
performance: {
cost: "HIGH",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-opus-4-1"
},
"claude-opus-4.5": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-5-opus",
modelIdentifier: "ANTHROPIC_CLAUDE_45_OPUS",
displayName: "Claude Opus 4.5",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-08-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-opus-4-5"
},
"claude-opus-4.6": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-6-opus",
modelIdentifier: "ANTHROPIC_CLAUDE_46_OPUS",
displayName: "Claude Opus 4.6",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-08-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-opus-4-6"
},
"claude-sonnet-4": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-sonnet",
modelIdentifier: "ANTHROPIC_CLAUDE_4_SONNET",
displayName: "Claude Sonnet 4",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-03-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-4"
},
"claude-sonnet-4.5": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-5-sonnet",
modelIdentifier: "ANTHROPIC_CLAUDE_45_SONNET",
displayName: "Claude Sonnet 4.5",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-07-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-sonnet-4-5"
},
"claude-sonnet-4.6": {
rid: "ri.language-model-service..language-model.anthropic-claude-4-6-sonnet",
modelIdentifier: "ANTHROPIC_CLAUDE_46_SONNET",
displayName: "Claude Sonnet 4.6",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"CLAUDE_CHAT"
],
trainingCutoffDate: "2025-08-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://www.anthropic.com/news/claude-sonnet-4-6"
}
};
var ANTHROPIC_MODELS = createProviderModelCatalog(
"anthropic",
ANTHROPIC_MODEL_DEFINITIONS
);
var ANTHROPIC_MODEL_IDS = Object.freeze(
Object.keys(ANTHROPIC_MODELS)
);
// src/models/google-models.ts
var GOOGLE_MODEL_DEFINITIONS = {
"gemini-2.5-pro": {
rid: "ri.language-model-service..language-model.gemini-2-5-pro",
modelIdentifier: "GEMINI_2_5_PRO",
displayName: "Gemini 2.5 Pro",
lifecycle: "ga",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "MEDIUM"
},
externalUrl: "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-pro"
},
"gemini-2.5-flash": {
rid: "ri.language-model-service..language-model.gemini-2-5-flash",
modelIdentifier: "GEMINI_2_5_FLASH",
displayName: "Gemini 2.5 Flash",
lifecycle: "ga",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "REASONING",
speed: "HIGH"
},
externalUrl: "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash"
},
"gemini-2.5-flash-lite": {
rid: "ri.language-model-service..language-model.gemini-2-5-flash-lite",
modelIdentifier: "GEMINI_2_5_FLASH_LITE",
displayName: "Gemini 2.5 Flash Lite",
lifecycle: "ga",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-lite"
},
"gemini-3-flash": {
rid: "ri.language-model-service..language-model.gemini-3-flash",
modelIdentifier: "GEMINI_3_FLASH",
displayName: "Gemini 3 Flash (Preview)",
lifecycle: "ga",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-flash"
},
"gemini-3.1-pro": {
rid: "ri.language-model-service..language-model.gemini-3-1-pro",
modelIdentifier: "GEMINI_3_1_PRO",
displayName: "Gemini 3.1 Pro (Preview)",
lifecycle: "ga",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "MEDIUM"
},
externalUrl: "https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/3-1-pro"
},
"gemini-3.1-flash-lite": {
rid: "ri.language-model-service..language-model.gemini-3-1-flash-lite",
modelIdentifier: "GEMINI_3_1_FLASH_LITE",
displayName: "Gemini 3.1 Flash Lite (Preview)",
lifecycle: "experimental",
inputTypes: [
"GEMINI_CHAT",
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION"
],
trainingCutoffDate: "2025-01-01T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://deepmind.google/models/model-cards/gemini-3-1-flash-lite/"
}
};
var GOOGLE_MODELS = createProviderModelCatalog("google", GOOGLE_MODEL_DEFINITIONS);
var GOOGLE_MODEL_IDS = Object.freeze(
Object.keys(GOOGLE_MODELS)
);
// src/models/openai-models.ts
var OPENAI_MODEL_DEFINITIONS = {
"gpt-4.1": {
rid: "ri.language-model-service..language-model.gpt-4-1",
modelIdentifier: "GPT_4_1",
displayName: "GPT-4.1",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-31T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-4.1"
},
"gpt-4.1-mini": {
rid: "ri.language-model-service..language-model.gpt-4-1-mini",
modelIdentifier: "GPT_4_1_MINI",
displayName: "GPT-4.1 mini",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-31T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-4.1-mini"
},
"gpt-4.1-nano": {
rid: "ri.language-model-service..language-model.gpt-4-1-nano",
modelIdentifier: "GPT_4_1_NANO",
displayName: "GPT-4.1 nano",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-31T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-4.1-nano"
},
"gpt-4o": {
rid: "ri.language-model-service..language-model.gpt-4-o",
modelIdentifier: "GPT_4_O",
displayName: "GPT-4o",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2023-10-01T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-4o"
},
"gpt-5": {
rid: "ri.language-model-service..language-model.gpt-5",
modelIdentifier: "GPT_5",
displayName: "GPT-5",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-09-30T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5"
},
"gpt-5-codex": {
rid: "ri.language-model-service..language-model.gpt-5-codex",
modelIdentifier: "GPT_5_CODEX",
displayName: "GPT-5 Codex",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-09-29T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5-codex"
},
"gpt-5-mini": {
rid: "ri.language-model-service..language-model.gpt-5-mini",
modelIdentifier: "GPT_5_MINI",
displayName: "GPT-5 mini",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-30T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5-mini"
},
"gpt-5-nano": {
rid: "ri.language-model-service..language-model.gpt-5-nano",
modelIdentifier: "GPT_5_NANO",
displayName: "GPT-5 nano",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-30T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5-nano"
},
"gpt-5.1": {
rid: "ri.language-model-service..language-model.gpt-5-1",
modelIdentifier: "GPT_5_1",
displayName: "GPT-5.1",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-09-30T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.1"
},
"gpt-5.1-codex": {
rid: "ri.language-model-service..language-model.gpt-5-1-codex",
modelIdentifier: "GPT_5_1_CODEX",
displayName: "GPT-5.1 Codex",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-09-30T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.1-codex"
},
"gpt-5.1-codex-mini": {
rid: "ri.language-model-service..language-model.gpt-5-1-codex-mini",
modelIdentifier: "GPT_5_1_CODEX_MINI",
displayName: "GPT-5.1 Codex mini",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-09-30T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.1-codex-mini"
},
"gpt-5.2": {
rid: "ri.language-model-service..language-model.gpt-5-2",
modelIdentifier: "GPT_5_2",
displayName: "GPT-5.2",
lifecycle: "experimental",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2025-08-31T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.2"
},
"gpt-5.4": {
rid: "ri.language-model-service..language-model.gpt-5-4",
modelIdentifier: "GPT_5_4",
displayName: "GPT-5.4",
lifecycle: "experimental",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2025-08-31T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "HEAVYWEIGHT",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.4"
},
"gpt-5.4-mini": {
rid: "ri.language-model-service..language-model.gpt-5-4-mini",
modelIdentifier: "GPT_5_4_MINI",
displayName: "GPT-5.4 mini",
lifecycle: "experimental",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2025-08-31T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.4-mini"
},
"gpt-5.4-nano": {
rid: "ri.language-model-service..language-model.gpt-5-4-nano",
modelIdentifier: "GPT_5_4_NANO",
displayName: "GPT-5.4 nano",
lifecycle: "experimental",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"GPT_CHAT_COMPLETION",
"GPT_WITH_VISION_COMPLETION",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_REASONING",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2025-08-31T00:00:00Z",
performance: {
cost: "LOW",
modelClass: "LIGHTWEIGHT",
speed: "HIGH"
},
externalUrl: "https://platform.openai.com/docs/models/gpt-5.4-nano"
},
o3: {
rid: "ri.language-model-service..language-model.o-3",
modelIdentifier: "O_3",
displayName: "o3",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"OPEN_AI_REASONING",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-31T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "LOW"
},
externalUrl: "https://platform.openai.com/docs/models/o3"
},
"o4-mini": {
rid: "ri.language-model-service..language-model.o-4-mini",
modelIdentifier: "O_4_MINI",
displayName: "o4-mini",
lifecycle: "ga",
inputTypes: [
"GENERIC_COMPLETION",
"GENERIC_CHAT_COMPLETION",
"OPEN_AI_REASONING",
"GENERIC_VISION_COMPLETION",
"OPEN_AI_RESPONSES"
],
trainingCutoffDate: "2024-05-31T00:00:00Z",
performance: {
cost: "MEDIUM",
modelClass: "REASONING",
speed: "MEDIUM"
},
externalUrl: "https://platform.openai.com/docs/models/o4-mini"
}
};
var OPENAI_MODELS = createProviderModelCatalog("openai", OPENAI_MODEL_DEFINITIONS);
var OPENAI_MODEL_IDS = Object.freeze(
Object.keys(OPENAI_MODELS)
);
var OPENAI_REASONING_MODEL_TARGETS = new Set(
Object.entries(OPENAI_MODELS).filter(([, metadata]) => modelSupportsInputType(metadata, "OPEN_AI_REASONING")).flatMap(([modelId, metadata]) => [modelId, metadata.rid])
);
function isKnownOpenAIReasoningTarget(modelId) {
return OPENAI_REASONING_MODEL_TARGETS.has(modelId);
}
// src/models/catalog.ts
var MODEL_CATALOG = {
...OPENAI_MODELS,
...ANTHROPIC_MODELS,
...GOOGLE_MODELS
};
var MODEL_CATALOG_BY_RID = Object.fromEntries(
Object.values(MODEL_CATALOG).map((metadata) => [metadata.rid, metadata])
);
function getModelMetadata(modelId) {
return MODEL_CATALOG[modelId];
}
function resolveModelTarget(modelId) {
const metadata = getModelMetadata(modelId) ?? getModelMetadataByRid(modelId);
return {
rid: metadata?.rid ?? modelId,
metadata
};
}
function getModelMetadataByRid(modelRid) {
return MODEL_CATALOG_BY_RID[modelRid];
}
// src/providers/openai.ts
function createFoundryOpenAI(config) {
const providerId = "foundry-openai";
const resolvedConfig = resolveFoundryConfig(config, "createFoundryOpenAI");
const baseProvider = (0, import_openai.createOpenAI)({
apiKey: resolvedConfig.token,
baseURL: `${resolvedConfig.foundryUrl}/api/v2/llm/proxy/openai/v1`,
headers: resolvedConfig.attributionRid ? { attribution: resolvedConfig.attributionRid } : void 0,
name: providerId
});
const createLanguageModel = (modelId) => {
const resolvedModel = resolveModelTarget(modelId);
const shouldForceReasoning = isKnownOpenAIReasoningTarget(modelId) || isKnownOpenAIReasoningTarget(resolvedModel.rid);
return wrapFoundryLanguageModel(baseProvider.responses(resolvedModel.rid), {
modelId,
providerId,
transformParams: (params) => applyOpenAICompat(params, shouldForceReasoning)
});
};
function provider(modelId) {
return createLanguageModel(modelId);
}
const callableProvider = provider;
callableProvider.specificationVersion = "v3";
callableProvider.languageModel = createLanguageModel;
callableProvider.responses = createLanguageModel;
callableProvider.embeddingModel = (modelId) => {
throw new import_ai2.NoSuchModelError({ modelId, modelType: "embeddingModel" });
};
callableProvider.imageModel = (modelId) => {
throw new import_ai2.NoSuchModelError({ modelId, modelType: "imageModel" });
};
return callableProvider;
}
function applyOpenAICompat(params, shouldForceReasoning) {
const openaiOptions = asRecord(params.providerOptions?.openai);
if (openaiOptions.store === true) {
throw new Error(
"Foundry OpenAI does not support providerOptions.openai.store=true. Remove the store option or set it to false."
);
}
return {
...params,
providerOptions: {
...params.providerOptions ?? {},
openai: {
...openaiOptions,
...openaiOptions.forceReasoning == null && shouldForceReasoning ? { forceReasoning: true } : {},
store: false
}
},
...params.tools != null ? { tools: params.tools.map(applyOpenAIFunctionToolCompat) } : {}
};
}
function asRecord(value) {
if (value == null || typeof value !== "object" || Array.isArray(value)) {
return {};
}
return value;
}
function applyOpenAIFunctionToolCompat(tool) {
if (tool.type !== "function" || tool.strict != null) {
return tool;
}
return {
...tool,
strict: true
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createFoundryOpenAI
});
//# sourceMappingURL=openai.cjs.map