Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/keiko-model-gateway/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,22 @@ function resolveProviderEndpointStyle(

function resolveProviderApiVersion(
rawValue: unknown,
path: string,
providerPath: string,
modelId: string,
env: EnvSource,
endpointStyle: ProviderEndpointStyle | undefined,
): string | undefined {
const path = `${providerPath}.apiVersion`;
const token = envModelToken(modelId);
const perModelName = `KEIKO_MODEL_${token}_API_VERSION`;
const perModel = env[perModelName];
const defaultValue = env.KEIKO_DEFAULT_API_VERSION;
// The GLOBAL default applies only where an api version is meaningful: a provider whose
// resolved style is not the Azure deployment path must not inherit it, or one
// KEIKO_DEFAULT_API_VERSION would make every explicitly openai-compatible provider on the
// same server unparseable through the pairing rule below (review finding on #3042 —
// per-model and file values stay authoritative and still fail the pairing loudly).
const defaultValue =
endpointStyle === "azure-openai-deployment" ? env.KEIKO_DEFAULT_API_VERSION : undefined;
const value = resolvePerModelValue(perModel, rawValue, defaultValue);
if (value === undefined || value === "") {
return undefined;
Expand Down Expand Up @@ -1273,7 +1281,7 @@ function parseProviderConfig(
modelId,
env,
);
const apiVersion = resolveProviderApiVersion(raw.apiVersion, `${path}.apiVersion`, modelId, env);
const apiVersion = resolveProviderApiVersion(raw.apiVersion, path, modelId, env, endpointStyle);
assertProviderEndpointVersion(endpointStyle, apiVersion, path);
const realtimeAuthMode = resolveRealtimeAuthMode(
raw.realtimeAuthMode,
Expand Down
Loading
Loading