Change to Anthropic compatible API

It seemed as if the OpenAI message spec tried to send non-compliant messages with { text: "" } instead of { contet: "" }, which the AI Gateway did not accept.
This commit is contained in:
Timo Lins 2026-01-13 15:20:35 +01:00 committed by Mario Zechner
parent 164a69a601
commit 9860ee86f3
2 changed files with 378 additions and 377 deletions

View file

@ -53,7 +53,8 @@ const COPILOT_STATIC_HEADERS = {
"Copilot-Integration-Id": "vscode-chat",
} as const;
const AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
const AI_GATEWAY_MODELS_URL = "https://ai-gateway.vercel.sh/v1";
const AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
async function fetchOpenRouterModels(): Promise<Model<any>[]> {
try {
@ -116,7 +117,7 @@ async function fetchOpenRouterModels(): Promise<Model<any>[]> {
async function fetchAiGatewayModels(): Promise<Model<any>[]> {
try {
console.log("Fetching models from Vercel AI Gateway API...");
const response = await fetch(`${AI_GATEWAY_BASE_URL}/models`);
const response = await fetch(`${AI_GATEWAY_MODELS_URL}/models`);
const data = await response.json();
const models: Model<any>[] = [];
@ -147,7 +148,7 @@ async function fetchAiGatewayModels(): Promise<Model<any>[]> {
models.push({
id: model.id,
name: model.name || model.id,
api: "openai-completions",
api: "anthropic-messages",
baseUrl: AI_GATEWAY_BASE_URL,
provider: "ai-gateway",
reasoning: tags.includes("reasoning"),

File diff suppressed because it is too large Load diff