copilot-api icon indicating copy to clipboard operation
copilot-api copied to clipboard

API Error: Gemini 3 Pro not supported

Open foamzou opened this issue 1 year ago • 18 comments

Thanks for maintaining this great project!

Issue

Claude Code fails when configured to use gemini-3-pro-preview model.

Error:

API Error: 400 {"error":{"message":"{"error":{"message":"invalid request body","code":"invalid_request_body"}}\n","type":"error"}}

Configuration:

export ANTHROPIC_BASE_URL=http://localhost:4141
export ANTHROPIC_AUTH_TOKEN=dummy
export ANTHROPIC_MODEL=gemini-3-pro-preview
export ANTHROPIC_DEFAULT_SONNET_MODEL=gemini-3-pro-preview
export ANTHROPIC_SMALL_FAST_MODEL=claude-haiku-4.5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4.5
export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1

foamzou avatar Nov 19 '25 06:11 foamzou

@foamzou https://github.com/ericc-ch/copilot-api/pull/152 in lastest claude code, also need "CLAUDE_CODE_SUBAGENT_MODEL": "gpt-5-mini" , if not warm up request will use gemini-3-pro-preview.

caozhiyuan avatar Nov 19 '25 14:11 caozhiyuan

@foamzou #152 in lastest claude code, also need "CLAUDE_CODE_SUBAGENT_MODEL": "gpt-5-mini" , if not warm up request will use gemini-3-pro-preview.

get this when it receive the tool call result : ERROR HTTP error: { error: { message: 'invalid request body', code: 'invalid_request_body' } } 8:06:28 PM

--> POST /v1/messages?beta=true 400 484ms <-- POST /v1/messages --> POST /v1/messages 200 4s <-- POST /v1/messages

ERROR Failed to create chat completions Response {} 8:07:38 PM

ERROR Error occurred: Failed to create chat completions 8:07:38 PM

at <anonymous> (src/services/copilot/create-chat-completions.ts:39:15)
at async handleCompletion (src/routes/messages/handler.ts:41:26)
at async <anonymous> (src/routes/messages/route.ts:12:18)
at async dispatch (node_modules/hono/dist/compose.js:22:23)
at async cors2 (node_modules/hono/dist/middleware/cors/index.js:84:11)
at async dispatch (node_modules/hono/dist/compose.js:22:23)
at async logger2 (node_modules/hono/dist/middleware/logger/index.js:38:11)
at async dispatch (node_modules/hono/dist/compose.js:22:23)
at async <anonymous> (node_modules/hono/dist/hono-base.js:201:31)
at processTicksAndRejections (native:7:39)

ERROR HTTP error: { error: { message: 'invalid request body', code: 'invalid_request_body' } }

Louis454545 avatar Nov 19 '25 19:11 Louis454545

@Louis454545 try https://github.com/caozhiyuan/copilot-api/tree/feature/chat-completions-reasoning

caozhiyuan avatar Nov 19 '25 21:11 caozhiyuan

@Louis454545 try https://github.com/caozhiyuan/copilot-api/tree/feature/chat-completions-reasoning

This forked branch doesn't work for me when doing the sub agent mode. Getting the same error. Anyone know of a fix?

patrickrho-patty avatar Nov 25 '25 11:11 patrickrho-patty

@patrickrho-patty what's error and you claude code version and settings.json ?

caozhiyuan avatar Nov 25 '25 12:11 caozhiyuan

@caozhiyuan This is super weird, I was trying to capture the invalid request body error so I tried again, spawning a sub agent tool, but this time it worked perfectly fine. Thanks so much for the fork and your work!

patrickrho-patty avatar Nov 25 '25 12:11 patrickrho-patty

@Louis454545 try https://github.com/caozhiyuan/copilot-api/tree/feature/chat-completions-reasoning

@caozhiyuan

Does this version (branch) support both responss-API (codex) and gemini 3 pro simultaneously?

nickfan avatar Nov 26 '25 02:11 nickfan

@nickfan https://github.com/caozhiyuan/copilot-api/tree/all

caozhiyuan avatar Nov 26 '25 02:11 caozhiyuan

@caozhiyuan using your repo but still get the error. i am using claude-opus-4.5 now

lab16k5u avatar Dec 10 '25 05:12 lab16k5u

@caozhiyuan using your repo but still get the error. i am using claude-opus-4.5 now

what's error ? @lab16k5u

caozhiyuan avatar Dec 10 '25 05:12 caozhiyuan

@lab16k5u please run https://github.com/caozhiyuan/copilot-api/tree/all bun run start start -v , and see log in user\xxx.local\share\copilot-api\logs\ .

caozhiyuan avatar Dec 10 '25 05:12 caozhiyuan

@lab16k5u because claude model support thinking , microsofe copilot change api logic . now it's fixed. you can pull latest code

caozhiyuan avatar Dec 11 '25 03:12 caozhiyuan

still same error @caozhiyuan

{ Authorization: "Bearer tid=REDACTEDexp=1765439896;sku=copilot_enterprise_seat_quota;proxy-ep=proxy.enterprise.githubcopilot.com;st=dotcom;ssc=1;chat=1;cit=1;malfil=1;editor_preview_features=0;agent_mode=1;agent_mode_auto_approval=1;mcp=0;ccr=1;8kp=1;ip=REDACTED;asn=REDACTED", "content-type": "application/json", "copilot-integration-id": "vscode-chat", "editor-version": "vscode/1.107.0", "editor-plugin-version": "copilot-chat/0.35.0", "user-agent": "GitHubCopilotChat/0.35.0", "openai-intent": "conversation-panel", "x-github-api-version": "2025-10-01", "x-request-id": "REDACTED", "x-vscode-user-agent-library-version": "electron-fetch", } ERROR Failed to create chat completions Response {}
ERROR HTTP error: { error:
{ message: 'The requested model is not supported.', code: 'model_not_supported', param: 'model', type: 'invalid_request_error' } }

lab16k5u avatar Dec 11 '25 07:12 lab16k5u

@lab16k5u you need vpn

caozhiyuan avatar Dec 11 '25 10:12 caozhiyuan

@caozhiyuan 大佬Hi there, thanks for your fork(https://github.com/caozhiyuan/copilot-api/tree/feature/responses-api) that allowed me to use GPT5.2's xhigh on Codex. However, I'm currently encountering an issue where occasionally the following error appears in conversations—sometimes retrying a few times lets it continue, but other times it just gets stuck indefinitely:

<-- POST /responses

ERROR Failed to create responses Response {} 2:36:47 PM

ERROR Error occurred: Failed to create responses 2:36:47 PM

at <anonymous> (/data/private/yangdeyu/copilot-api/src/services/copilot/create-responses.ts:351:15)
at async <anonymous> (/data/private/yangdeyu/copilot-api/src/routes/responses/handler.ts:52:26)
at async <anonymous> (/data/private/yangdeyu/copilot-api/src/routes/responses/route.ts:11:18)
at async dispatch (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/compose.js:22:23)
at async cors2 (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/middleware/cors/index.js:84:11)
at async dispatch (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/compose.js:22:23)
at async logger2 (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/middleware/logger/index.js:38:11)
at async dispatch (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/compose.js:22:23)
at async <anonymous> (/data/private/yangdeyu/copilot-api/node_modules/hono/dist/hono-base.js:201:31)
at processTicksAndRejections (native:7:39)

ERROR HTTP error: Internal Server Error 2:36:47 PM

--> POST /responses 500 26s

<-- POST /responses

ERROR Failed to create responses Response {} 2:42:33 PM

ERROR Error occurred: Failed to create responses 2:42:33 PM

at <anonymous> (/data/private/yangdeyu/copilot-api/src/services/copilot/create-responses.ts:351:15)
at unknown
at unknown
at async dispatch (unknown)
at async cors2 (unknown)
at async dispatch (unknown)
at async logger2 (unknown)
at async dispatch (unknown)
at unknown
at processTicksAndRejections (native:7:39)

ERROR HTTP error: Internal Server Error 2:42:33 PM

--> POST /responses 500 36s

What's the problem here ? Thank you

Deyu008 avatar Dec 26 '25 06:12 Deyu008

@Deyu008 I mainly use it in claude code. Judging from your logs, it should be a network issue or an error reported by the copilot-api server. I haven't encountered this problem when using it in claude code. Currently, I primarily use the branch https://github.com/caozhiyuan/copilot-api/tree/all, started with bun run start start -v, and the logs are located in the home .local\share\copilot-api\logs folder.

caozhiyuan avatar Dec 26 '25 07:12 caozhiyuan

@Deyu008 You can also let the AI add a try-catch in responses handler.ts to log detailed exception information.

caozhiyuan avatar Dec 26 '25 07:12 caozhiyuan

OK,Thanks @caozhiyuan

Deyu008 avatar Dec 26 '25 07:12 Deyu008