mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 02:04:05 +00:00
feat(ai): route copilot claude via anthropic messages api
This commit is contained in:
parent
cf1353b8e7
commit
0a132a30a1
9 changed files with 196 additions and 76 deletions
|
|
@ -519,13 +519,21 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
|
|||
if (m.tool_call !== true) continue;
|
||||
if (m.status === "deprecated") continue;
|
||||
|
||||
// Claude 4.x models route to Anthropic Messages API
|
||||
const isCopilotClaude4 = /^claude-(haiku|sonnet|opus)-4([.\-]|$)/.test(modelId);
|
||||
// gpt-5 models require responses API, others use completions
|
||||
const needsResponsesApi = modelId.startsWith("gpt-5") || modelId.startsWith("oswe");
|
||||
|
||||
const api: Api = isCopilotClaude4
|
||||
? "anthropic-messages"
|
||||
: needsResponsesApi
|
||||
? "openai-responses"
|
||||
: "openai-completions";
|
||||
|
||||
const copilotModel: Model<any> = {
|
||||
id: modelId,
|
||||
name: m.name || modelId,
|
||||
api: needsResponsesApi ? "openai-responses" : "openai-completions",
|
||||
api,
|
||||
provider: "github-copilot",
|
||||
baseUrl: "https://api.individual.githubcopilot.com",
|
||||
reasoning: m.reasoning === true,
|
||||
|
|
@ -540,13 +548,13 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
|
|||
maxTokens: m.limit?.output || 8192,
|
||||
headers: { ...COPILOT_STATIC_HEADERS },
|
||||
// compat only applies to openai-completions
|
||||
...(needsResponsesApi ? {} : {
|
||||
...(api === "openai-completions" ? {
|
||||
compat: {
|
||||
supportsStore: false,
|
||||
supportsDeveloperRole: false,
|
||||
supportsReasoningEffort: false,
|
||||
},
|
||||
}),
|
||||
} : {}),
|
||||
};
|
||||
|
||||
models.push(copilotModel);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue