Skip to content

feat: switch xai provider to responses API#18175

Merged
rekram1-node merged 1 commit intoanomalyco:devfrom
Jaaneek:feat/xai-responses-api
Mar 20, 2026
Merged

feat: switch xai provider to responses API#18175
rekram1-node merged 1 commit intoanomalyco:devfrom
Jaaneek:feat/xai-responses-api

Conversation

@Jaaneek
Copy link
Copy Markdown
Contributor

@Jaaneek Jaaneek commented Mar 19, 2026

Issue for this PR

Closes #18179 #3890

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Switches xAI provider from completions API to responses API. The reason for this change is to use 'reasoning.encrypted_content' with reasoning models. This should improve performance in long multi turn conversations.

How did you verify your code works?

I did a lot of manual testing also told agent to test the changes e2e. I tried reading files, writing code, opening images etc..

Screenshots / recordings

image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Jaaneek Jaaneek changed the title feat: switch xai provider to responses API feat: switch xai provider to responses API and hide Multi Agent model Mar 19, 2026
Comment thread patches/@ai-sdk%2Fxai@2.0.51.patch
Comment thread packages/opencode/src/provider/provider.ts Outdated
@Jaaneek Jaaneek force-pushed the feat/xai-responses-api branch from 615bc30 to 2b8a267 Compare March 19, 2026 11:21
@Jaaneek Jaaneek force-pushed the feat/xai-responses-api branch from 2b8a267 to 80d2d37 Compare March 19, 2026 11:24
@Jaaneek Jaaneek changed the title feat: switch xai provider to responses API and hide Multi Agent model feat: switch xai provider to responses API Mar 19, 2026
@Jaaneek Jaaneek requested a review from rekram1-node March 19, 2026 16:30
@rekram1-node rekram1-node merged commit b3d0446 into anomalyco:dev Mar 20, 2026
12 checks passed
@Jaaneek Jaaneek deleted the feat/xai-responses-api branch March 20, 2026 02:12
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
Co-authored-by: Jaaneek <jankiewiczmilosz@gmail.com>
@nikolaibogdanov
Copy link
Copy Markdown

@Jaaneek are you sure it's fixed?
I'm now trying it and it still uses chat api for me. The only difference that I use it via ACP.
From opencode logs:

INFO  2026-03-27T10:09:36 +1113ms service=default version=1.3.3 args=["acp"] opencode
...
ERROR 2026-03-27T10:09:46 +88ms service=llm providerID=xai modelID=grok-4-1-fast-non-reasoning sessionID=ses_2d13aa720ffeLji2Rqfqkl6bhc small=false agent=build mode=primary error={"error":{"name":"AI_APICallError","url":"https://XXX/YY/xai/v1/chat/completions","requestBodyValues":{"model":"grok-4-1-fast-non-reasoning","max_completion_tokens":30000,"temperature":0.5,"messages":[{"role":"system","content":"You are a title generator. You output ONLY ..."},{"role":"user","content":"Generate a title for this conversation:\n"},{"role":"user","content":"ping"}],"stream":true,"stream_options":{"include_usage":true}},"statusCode":404,...,"responseBody":"","isRetryable":false}} stream error

It gives 404 just because our proxy doesn't support /chat/completions api.

@Jaaneek
Copy link
Copy Markdown
Contributor Author

Jaaneek commented Mar 27, 2026

@nikolaibogdanov will take a look within next 2 hours

@Jaaneek
Copy link
Copy Markdown
Contributor Author

Jaaneek commented Mar 27, 2026

@nikolaibogdanov I can't reproduce

cc @rekram1-node can you? I tested ACP via zed with multiple different models from xAI on newest dev branch

@rekram1-node
Copy link
Copy Markdown
Collaborator

Testing rn actually haha

@rekram1-node
Copy link
Copy Markdown
Collaborator

funny seeing the msg come in live

@rekram1-node
Copy link
Copy Markdown
Collaborator

@nikolaibogdanov I cannot reproduce either, the responses api is definitely being used, perhaps you are on an older opencode version?

If u installed using brew make sure u used: brew install anomalyco/tap/opencode

@nikolaibogdanov
Copy link
Copy Markdown

Ok, you are right, it works.
However, we ran into the case, where the custom providers are registered only if the providerKey already registered for this provider. In our case we were setting the keys in the same config file, so the xai provider fell back to the default one and used /chat/completion APIs.
Fixed it with the setting XAI_API_KEY in ENV

balcsida pushed a commit to balcsida/opencode that referenced this pull request Apr 8, 2026
Co-authored-by: Jaaneek <jankiewiczmilosz@gmail.com>
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Co-authored-by: Jaaneek <jankiewiczmilosz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: xAI provider is using completions API instead of responses API, multi agent model is listed but does not work

3 participants