mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 01:04:36 +00:00
feat(ai): add OpenRouter provider routing support
Allows custom models to specify which upstream providers OpenRouter should route requests to via the `openRouterRouting` field in model definitions. Supported fields: - `only`: list of provider slugs to exclusively use - `order`: list of provider slugs to try in order
This commit is contained in:
parent
a6d878e804
commit
dac7474da2
5 changed files with 30 additions and 0 deletions
|
|
@ -445,6 +445,11 @@ function buildParams(model: Model<"openai-completions">, context: Context, optio
|
|||
params.reasoning_effort = options.reasoningEffort;
|
||||
}
|
||||
|
||||
// OpenRouter provider routing preferences
|
||||
if (model.baseUrl.includes("openrouter.ai") && model.compat?.openRouterRouting) {
|
||||
(params as any).provider = model.compat.openRouterRouting;
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
|
@ -777,6 +782,7 @@ function detectCompat(model: Model<"openai-completions">): Required<OpenAIComple
|
|||
requiresThinkingAsText: isMistral,
|
||||
requiresMistralToolIds: isMistral,
|
||||
thinkingFormat: isZai ? "zai" : "openai",
|
||||
openRouterRouting: {},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -800,5 +806,6 @@ function getCompat(model: Model<"openai-completions">): Required<OpenAICompletio
|
|||
requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
|
||||
requiresMistralToolIds: model.compat.requiresMistralToolIds ?? detected.requiresMistralToolIds,
|
||||
thinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,
|
||||
openRouterRouting: model.compat.openRouterRouting ?? {},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue