Skip to content

feat: Support xAI native client and openai compatible response client#4010

Merged
Wendong-Fan merged 4 commits intomasterfrom
xai_native
Apr 14, 2026
Merged

feat: Support xAI native client and openai compatible response client#4010
Wendong-Fan merged 4 commits intomasterfrom
xai_native

Conversation

@Wendong-Fan
Copy link
Copy Markdown
Member

Summary

Add native xAI model backend using the xai_sdk gRPC package, enabling direct access to Grok models (including grok-4.20-reasoning)
with native features that are unavailable through the OpenAI-compatible endpoint.

Key features

  • Native xAI SDK integration: Uses xai_sdk (gRPC) instead of the OpenAI-compatible REST endpoint, providing access to xAI-specific
    features like encrypted thinking content and server-side conversation storage.
  • Conversation chaining via previous_response_id: On multi-turn conversations, only delta messages are sent to the API. The server
    retains the full history and applies automatic prompt caching, significantly reducing token usage and cost.
  • Encrypted thinking content: Supports use_encrypted_content for reasoning models. Encrypted reasoning traces are stored across turns
    and injected back into the conversation history, preserving the full reasoning chain.
  • Full message format conversion: Translates between CAMEL's OpenAI-format messages and xAI SDK protobuf messages
    (system/user/assistant/tool roles, including tool_calls and tool results).
  • Streaming support: Converts xAI's (Response, Chunk) tuple stream into OpenAI-compatible ChatCompletionChunk generators with proper
    pydantic objects.
  • Sync and async: Both _run() and _arun() are supported via lazy-initialized xai_sdk.Client and xai_sdk.AsyncClient.

@Wendong-Fan Wendong-Fan self-assigned this Apr 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 678cf060-1ee1-4a04-8317-93d1b5f77272

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch xai_native

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Wendong-Fan Wendong-Fan linked an issue Apr 14, 2026 that may be closed by this pull request
2 tasks
@Wendong-Fan Wendong-Fan requested a review from Zephyroam April 14, 2026 08:08
@github-actions github-actions Bot added the Review Required PR need to be reviewed label Apr 14, 2026
@Wendong-Fan Wendong-Fan marked this pull request as ready for review April 14, 2026 08:08
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, reopen this pull request to trigger a review.

@Wendong-Fan Wendong-Fan merged commit 095f039 into master Apr 14, 2026
12 of 13 checks passed
@Wendong-Fan Wendong-Fan deleted the xai_native branch April 14, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review Required PR need to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support xAI model native client

2 participants