fix: migrate from deprecated chat/completions to Responses API #135
+429
−41
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