fix: migrate from deprecated chat/completions to Responses API#135
Closed
blackjr21 wants to merge 1 commit intosuperagent-ai:mainfrom
Closed
fix: migrate from deprecated chat/completions to Responses API#135blackjr21 wants to merge 1 commit intosuperagent-ai:mainfrom
blackjr21 wants to merge 1 commit intosuperagent-ai:mainfrom
Conversation
xAI deprecated the /v1/chat/completions endpoint (returns 410 "Live search
is deprecated"). This PR migrates to the /v1/responses endpoint.
Changes:
- chat() now uses /v1/responses with fetch instead of OpenAI SDK
- chatStream() parses SSE events (event: + data: format) from Responses API
- Tool format flattened: {type, name, description, parameters} instead of
nested {type, function: {name, description, parameters}}
- Response parsing extracts text from output[].content[].text
- Added convertResponseToGrokResponse() for backward compatibility
- Added convertStreamChunk() to handle SSE event types:
- response.output_text.delta (main content)
- response.content_part.delta (alternative content)
- response.output_item.added/done (tool calls)
- response.completed/done (finish)
Fixes superagent-ai#134
Tested with:
- Basic chat (headless & interactive modes)
- Tool calling (view_file, bash, create_file)
- Streaming responses
pburkindine
approved these changes
Jan 27, 2026
gmgauthier
approved these changes
Feb 9, 2026
Contributor
|
Fixed in #145 |
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.
Summary
xAI deprecated the
/v1/chat/completionsendpoint which now returns410 "Live search is deprecated". This PR migrates grok-cli to use the/v1/responsesendpoint.Changes
src/grok/client.tschat()method - Now uses/v1/responseswith nativefetchinstead of OpenAI SDK'schat.completions.create()Tool format conversion - Flattened from nested structure:
Response parsing - Added
convertResponseToGrokResponse()to extract text from xAI's response format:Streaming - Rewrote
chatStream()to parse SSE format from Responses API:Handles event types:
response.output_text.delta- Main content streamingresponse.content_part.delta- Alternative content formatresponse.output_item.added/done- Tool callsresponse.completed/done- Response finishedTesting
Tested and working:
grok -p "hello")grok)Related Issues
Fixes #134
Notes
agentQuery()but didn't switch the main conversation loopGrokResponseformat