https://api.cerebras.ai/v1 --> UnknownError: AI_APICallError: Bad Request #1030

Closed
opened 2026-02-16 17:29:08 -05:00 by yindo · 3 comments
Owner

Originally created by @michabbb on GitHub (Jul 31, 2025).

Originally assigned to: @thdxr on GitHub.

"provider": {
                "cerebras": {
                        "npm": "@ai-sdk/openai-compatible",
                        "options": {
                                "baseURL": "https://api.cerebras.ai/v1",
                                "apiKey": "xxxxxxxxxxx"
                        },
                        "models": {
                                "qwen-3-235b-a22b-thinking-2507": {}
                        }
                }
        },

according to cerebras, a call should be made like this:

curl --location 'https://api.cerebras.ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${CEREBRAS_API_KEY}" \
--data '{
  "model": "qwen-3-235b-a22b-thinking-2507",
  "stream": true,
  "max_tokens": 65536,
  "temperature": 0.6,
  "top_p": 0.95,
  "messages": [
    {
      "role": "system",
      "content": ""
    }
  ]
}'

UnknownError: AI_APICallError: Bad Request 😢

i don´t know what i am doing wrong 🤷

Originally created by @michabbb on GitHub (Jul 31, 2025). Originally assigned to: @thdxr on GitHub. ```json "provider": { "cerebras": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://api.cerebras.ai/v1", "apiKey": "xxxxxxxxxxx" }, "models": { "qwen-3-235b-a22b-thinking-2507": {} } } }, ``` according to cerebras, a call should be made like this: ```bash curl --location 'https://api.cerebras.ai/v1/chat/completions' \ --header 'Content-Type: application/json' \ --header "Authorization: Bearer ${CEREBRAS_API_KEY}" \ --data '{ "model": "qwen-3-235b-a22b-thinking-2507", "stream": true, "max_tokens": 65536, "temperature": 0.6, "top_p": 0.95, "messages": [ { "role": "system", "content": "" } ] }' ``` UnknownError: AI_APICallError: Bad Request 😢 i don´t know what i am doing wrong 🤷
yindo closed this issue 2026-02-16 17:29:08 -05:00
Author
Owner

@michabbb commented on GitHub (Aug 1, 2025):

i learned from another issue that i have to use @ai-sdk/cerebras instead of @ai-sdk/openai-compatible 🤕

the main problem is: the whole "use another provider thing" is absolutly not well convered in the docs. it´s super hard to find out how all that works, i never heard anything about https://github.com/vercel/ai - but you need to know that if you want to work with others providers... that docs should mention that 😕

thinking is not possible with https://github.com/vercel/ai (cerebras): https://github.com/vercel/ai/discussions/7706

and i have no idea if that is an issue with opencode or with the vercel package.... 🤷

@michabbb commented on GitHub (Aug 1, 2025): i learned from another issue that i have to use `@ai-sdk/cerebras` instead of `@ai-sdk/openai-compatible` 🤕 the main problem is: the whole "use another provider thing" is absolutly not well convered in the docs. it´s super hard to find out how all that works, i never heard anything about https://github.com/vercel/ai - but you need to know that if you want to work with others providers... that docs should mention that 😕 thinking is not possible with https://github.com/vercel/ai (cerebras): https://github.com/vercel/ai/discussions/7706 and i have no idea if that is an issue with opencode or with the vercel package.... 🤷
Author
Owner

@jayair commented on GitHub (Aug 1, 2025):

We made Cerebras work out of the box: https://opencode.ai/docs/providers/#cerebras

Also added more docs on the custom provider option as well https://opencode.ai/docs/providers/#custom-provider

I tested it and it should work, feel free to reopen if you are still having problems.

@jayair commented on GitHub (Aug 1, 2025): We made Cerebras work out of the box: https://opencode.ai/docs/providers/#cerebras Also added more docs on the custom provider option as well https://opencode.ai/docs/providers/#custom-provider I tested it and it should work, feel free to reopen if you are still having problems.
Author
Owner

@opencode-agent[bot] commented on GitHub (Aug 1, 2025):

Perfect! I can see you've made excellent improvements to the documentation:

Cerebras Support

  • Added a dedicated Cerebras section with clear setup instructions
  • Shows users how to use opencode auth login and select Cerebras directly
  • Mentions the Qwen 3 Coder 480B model as an example

Custom Provider Documentation

  • Much more comprehensive custom provider section
  • Clear step-by-step instructions for adding any OpenAI-compatible provider
  • Explains the relationship with AI SDK and mentions that most modern providers offer OpenAI-compatible APIs
  • Shows configuration options like npm, name, options.baseURL, options.apiKey, options.headers
  • Includes practical examples with environment variables and custom headers

Troubleshooting Section

  • Added helpful troubleshooting guidance
  • Specifically mentions using @ai-sdk/cerebras for Cerebras vs @ai-sdk/openai-compatible for other providers
  • Covers common configuration issues

The documentation now addresses the user's main concerns:

  1. Provider discovery: The custom provider section clearly explains the AI SDK dependency
  2. Correct package usage: Troubleshooting section specifically mentions @ai-sdk/cerebras vs @ai-sdk/openai-compatible
  3. Step-by-step guidance: Much clearer instructions for both built-in and custom providers

This should significantly improve the user experience for anyone trying to add new providers to opencode!

Adding%20Cerebras%20provider%20support%20and%20documentation
opencode session  |  github run

@opencode-agent[bot] commented on GitHub (Aug 1, 2025): Perfect! I can see you've made excellent improvements to the documentation: ## Cerebras Support - Added a dedicated Cerebras section with clear setup instructions - Shows users how to use `opencode auth login` and select Cerebras directly - Mentions the Qwen 3 Coder 480B model as an example ## Custom Provider Documentation - Much more comprehensive custom provider section - Clear step-by-step instructions for adding any OpenAI-compatible provider - Explains the relationship with AI SDK and mentions that most modern providers offer OpenAI-compatible APIs - Shows configuration options like `npm`, `name`, `options.baseURL`, `options.apiKey`, `options.headers` - Includes practical examples with environment variables and custom headers ## Troubleshooting Section - Added helpful troubleshooting guidance - Specifically mentions using `@ai-sdk/cerebras` for Cerebras vs `@ai-sdk/openai-compatible` for other providers - Covers common configuration issues The documentation now addresses the user's main concerns: 1. **Provider discovery**: The custom provider section clearly explains the AI SDK dependency 2. **Correct package usage**: Troubleshooting section specifically mentions `@ai-sdk/cerebras` vs `@ai-sdk/openai-compatible` 3. **Step-by-step guidance**: Much clearer instructions for both built-in and custom providers This should significantly improve the user experience for anyone trying to add new providers to opencode! <a href="https://opencode.ai/s/WyaIfaQv"><img width="200" alt="Adding%20Cerebras%20provider%20support%20and%20documentation" src="https://social-cards.sst.dev/opencode-share/QWRkaW5nIENlcmVicmFzIHByb3ZpZGVyIHN1cHBvcnQgYW5kIGRvY3VtZW50YXRpb24=.png?model=anthropic/claude-sonnet-4-20250514&version=0.3.112&id=WyaIfaQv" /></a> [opencode session](https://opencode.ai/s/WyaIfaQv)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/16687742785)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1030