Skip to content

Add built-in Anthropic (Claude 5) and xAI (Grok 4.6) providers - #523

Open
jaideepkumar69-tech wants to merge 1 commit into
google:mainfrom
jaideepkumar69-tech:feat/anthropic-xai-providers
Open

Add built-in Anthropic (Claude 5) and xAI (Grok 4.6) providers#523
jaideepkumar69-tech wants to merge 1 commit into
google:mainfrom
jaideepkumar69-tech:feat/anthropic-xai-providers

Conversation

@jaideepkumar69-tech

@jaideepkumar69-tech jaideepkumar69-tech commented Aug 20, 2026

Copy link
Copy Markdown

Description

Add first-class built-in providers so lx.extract(model_id="claude-sonnet-5") and lx.extract(model_id="grok-4.6") auto-route, matching Gemini / OpenAI / Ollama.

  • AnthropicLanguageModel — Anthropic Messages API (claude-*). Default claude-sonnet-5; also claude-opus-5, claude-fable-5, claude-haiku-4-5.
  • XAILanguageModel — OpenAI-compatible client at https://api.x.ai/v1 (grok-*). Default grok-4.6.
  • Factory env lookup: ANTHROPIC_API_KEY / XAI_API_KEY (falls back to LANGEXTRACT_API_KEY).

Does not change pyproject.toml (protected infrastructure). Claude needs pip install anthropic; Grok reuses langextract[openai].

This extends the provider-registry work discussed in the community-supported provider thread.

Related to #99
Related to #522
Related to #187

Feature

How Has This Been Tested?

$ pytest tests/claude_grok_provider_test.py tests/registry_test.py tests/factory_test.py

51 passed. Coverage includes:

  • claude-sonnet-5 / claude-opus-5 / claude-fable-5 / claude-haiku-4-5 route to AnthropicLanguageModel
  • grok-4.6 / grok-4.5 route to XAILanguageModel
  • factory env-key + xAI base URL injection
  • Anthropic message content flattening (mocked SDK)

Also ran pyink on the new/changed Python files. CI: format-check and unit tests + pylint on 3.10 / 3.11 / 3.12.

Checklist:

  • I have read and acknowledged Google's Open Source
    Code of conduct.
  • I have read the
    Contributing
    page, and I either signed the Google
    Individual CLA
    or am covered by my company's
    Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked
    issue(s) and we have agreed upon the general approach.
  • I have made any needed documentation changes, or noted in the linked
    issue(s) that documentation elsewhere needs updating.
  • I have added tests, or I have ensured existing tests cover the changes
  • I have followed
    Google's Python Style Guide
    and ran pylint over the affected code.

Route claude-* model IDs to the Anthropic Messages API and grok-* IDs
to xAI's OpenAI-compatible endpoint. Factory picks ANTHROPIC_API_KEY
and XAI_API_KEY. Defaults are claude-sonnet-5 and grok-4.6.
@jaideepkumar69-tech
jaideepkumar69-tech force-pushed the feat/anthropic-xai-providers branch from 65f7e8b to 2c7a920 Compare August 20, 2026 05:08
@jaideepkumar69-tech
jaideepkumar69-tech marked this pull request as ready for review August 20, 2026 05:08
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