Skip to content

Add xAI Grok provider to the Inference effect #425

@aallan

Description

@aallan

xAI's Grok uses an OpenAI-compatible endpoint, making it a one-row addition to the provider registry introduced in #413.

Blocked by #413 — the _PROVIDERS registry must land first.

Background

xAI's Grok API is OpenAI-compatible:

  • Endpoint: https://api.x.ai/v1/chat/completions
  • Auth: Bearer token (identical to OpenAI/Moonshot/Mistral pattern)
  • Response: choices[0].message.content (identical)
  • Env var: VERA_XAI_API_KEY
  • Default model: grok-3-mini-fast-beta (cheap/fast tier — analogous to Haiku, GPT-4o-mini, mistral-small-latest; their flagship is grok-4-0709 but that's the expensive tier)

Once the _PROVIDERS registry exists, this is literally one dict entry:

"xai": _ProviderConfig(
    env_key="VERA_XAI_API_KEY",
    url="https://api.x.ai/v1/chat/completions",
    default_model="grok-3-mini-fast-beta",
    auth_style="bearer",
    response_style="openai",
),

Auto-detection, error messages, and the dispatch logic all inherit from the registry with no further changes.

Change list

vera/codegen/api.py

Tests — tests/test_codegen.py

  • test_inference_xai_auto_detect — copy pattern from other provider auto-detect tests
  • test_xai_provider — unit test for the xAI config entry

Documentation sweep

  • spec/09-standard-library.md — one row in the provider table
  • SKILL.md — one row in the provider table
  • README.md — one row in the env var table
  • CHANGELOG.md — entry for xAI support

Out of scope

  • Grok-specific features (real-time web search, etc.) — Inference.complete is plain String → Result<String, String>
  • Browser runtime — separate PR, same pattern as other providers

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestintegrationIntegration with external tools and languages

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions