feat(xai): expose explicit Responses API routing via xai_api provider option#699
Merged
Merged
Conversation
… option `use_responses_api?/1` only flipped to `/responses` as a side effect of including xAI's built-in tools (web_search/x_search). Multi-turn reasoning loops with custom function tools benefit from the stateful Responses endpoint too — `previous_response_id` threads reasoning across turns so Grok-4 family models keep "thinking" through a tool round-trip rather than restarting fresh in each Chat Completions call. Add `xai_api: :auto | :chat | :responses` (default `:auto` preserves the existing built-in-tool behavior). `:responses` forces the Responses endpoint regardless of which tools are present; `:chat` is the explicit override the other direction. Verified end-to-end with a probe: Grok 4.3 + reasoning_effort: medium + tool_choice: required completes a two-turn fetch_changed_files → post_review loop natively on /responses but stalls after the first tool call on /chat/completions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
xai_api: :auto | :chat | :responsesprovider option so callers can force xAI's/responsesendpoint without enabling a built-inweb_search/x_searchtool. Default:autopreserves the existing behavior.use_responses_api?/1now readsxai_apiandxai_toolsfrom both the top level and:provider_options, so the toggle works on the streaming path too (Options.process!/4re-nests provider-schema keys before they reachattach_stream).Adds a
guides/xai.mdentry under Provider Options and 4 tests for the routing-override matrix.Type of Change
Breaking Changes
Testing
mix test)mix quality)Checklist
CHANGELOG.md(it is auto-generated by git_ops)Related Issues
Closes #