-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
Calls to models with the string claude or anthropic in the id fail when they are not actual anthropic upstream providers.
I have this custom provider in my config:
"provider": {
"custom": {
"models": {
"claude-opus-4.1": {
"name": "claude-opus-4.1"
},
},
"npm": "@ai-sdk/openai-compatible",
"options": {
"apiKey": "na",
"baseURL": "https://custom.com"
}
}
},Chatting with this model fails with
litellm.BadRequestError: Vertex_aiException BadRequestError - b'{"type":"error","error":{"type":"invalid_request_error","message":"invalid beta flag"},"request_id":"req_vrtx_011CWdZLV7UDvRZBkvyfXcKJ"}'. Received Model Group=claude-opus-4.1
Available Model Group Fallbacks=None
Because of this logic https://github.com/sst/opencode/blob/3fe5d91372fdf859e09ed5a2aefe359e0648ed10/packages/opencode/src/provider/transform.ts#L198-L208
Even though my model has claude in the name I am explicitly saying it is an openai provider with "npm": "@ai-sdk/openai-compatible". In this case I am using LiteLLM proxy to front all LLM access and it does not support the added "cache_control" key this injects to every message.
Some possible solutions that could be done:
- config option to disable the applyCaching functionality, either per model or provider
(... existing ors) && model.api.npm !== "@ai-sdk/openai-compatible"be added to the if statement logic there. Though I am not sure if that is the best approach or if it should apply to other providers as well.
OpenCode version
1.0.212
Steps to reproduce
- Setup LiteLLM in front of Anthropic models where model id includes claude or anthropic
- Setup a custom provider in opencode using LiteLLM as a @ai-sdk/openai-compatible provider
- call on a model and it fails due to injected cache keys in messages array.
Screenshot and/or share link
Operating System
NixOS/macos
Terminal
Kitty/Iterm2