Skip to content

feat(provider): add xai#74

Merged
bzp2010 merged 1 commit intomainfrom
bzp/feat-xai-provider
May 3, 2026
Merged

feat(provider): add xai#74
bzp2010 merged 1 commit intomainfrom
bzp/feat-xai-provider

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented May 3, 2026

Summary by CodeRabbit

  • New Features
    • Added xAI as a newly supported provider type - users can now select and configure xAI in both model configuration and provider management interfaces
    • Supports API key-based authentication with flexible custom API base URL override options
    • Automatic usage metrics reporting integrated with xAI streaming requests for improved observability

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14061a93-fe5f-43c6-b077-8b8adc995f40

📥 Commits

Reviewing files that changed from the base of the PR and between faa3308 and 039d80b.

📒 Files selected for processing (8)
  • src/config/entities/providers-schema.json
  • src/config/entities/providers.rs
  • src/gateway/providers/mod.rs
  • src/gateway/providers/xai.rs
  • src/proxy/provider.rs
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
  • ui/src/lib/api/types.ts

📝 Walkthrough

Walkthrough

This PR adds support for the xAI provider across the system. It extends the provider schema and config enum, implements the xAI gateway provider with API key and optional base URL configuration, wires authentication handling in the proxy layer, and adds UI support with English and Chinese localization entries.

Changes

xAI Provider Integration

Layer / File(s) Summary
Schema & Provider Config
src/config/entities/providers-schema.json, src/config/entities/providers.rs
JSON schema type enum extended to include "xai". ProviderConfig enum gains Xai variant; provider_type() match returns identifiers::XAI. Validation test added.
Gateway Provider Implementation
src/gateway/providers/mod.rs, src/gateway/providers/xai.rs
XAI provider module declared and registered. New xai.rs defines IDENTIFIER, XaiProviderConfig (api_key + optional api_base), and Xai provider via macro with base URL https://api.x.ai/v1, bearer auth, logit_bias unsupported quirk, and stream usage injection. Tests verify macro-generated metadata and request transformation (logit_bias removed, stream_options.include_usage set).
Authentication & Proxy Wiring
src/proxy/provider.rs
provider_auth_and_base_url() extended to handle ProviderConfig::Xai, returning API key auth and parsed api_base override. Test validates Xai auth and optional base URL.
UI & Localization
ui/src/i18n/locales/en.json, ui/src/i18n/locales/zh-CN.json, ui/src/lib/api/types.ts
Translation keys added: "providers.form.types.xai" and "models.form.providers.xai" in both English and Chinese. TypeScript PROVIDER_TYPE_VARIANTS extended to include 'xai'; Provider union updated with 'xai' variant using ApiBaseProviderConfig.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • feat(provider): add mistral #72: Adds a new provider type by extending provider schema, ProviderConfig enum, gateway provider module, provider-specific implementation, proxy auth handling, and UI types—follows the same structural pattern.
  • feat(provider): add groq #71: Extends provider type enums and schemas, adds ProviderConfig variant, registers gateway provider module, adds provider-specific auth handling, and updates UI/provider type lists in an identical pattern.
  • feat(provider): add openrouter #63: Adds a new provider variant across schema, ProviderConfig enum, gateway provider module, proxy auth handling, and UI/provider-type entries using the same established pattern.
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning PR includes only unit tests for provider metadata, request transformation, and schema validation but lacks end-to-end/integration tests for the complete xAI provider business flow. Add E2E/integration tests in tests/proxy/ directory following established patterns to verify complete request flow, transformation, streaming behavior, and error scenarios.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat(provider): add xai' clearly and accurately summarizes the main change: adding support for the xAI provider across the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed xAI provider implementation follows established security patterns with proper API key handling, base URL validation, and no new credential exposure vectors.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-xai-provider

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

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

@bzp2010 bzp2010 merged commit 96be769 into main May 3, 2026
3 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-xai-provider branch May 3, 2026 07:42
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.

1 participant