Request: Built-in Anthropic (Claude) and xAI (Grok) providers

Author: jaideepkumar69-techCreated Aug 20, 2026Updated Aug 20, 2026

Describe the overall idea and motivation

Add first-class built-in providers so lx.extract(model_id="claude-sonnet-5") and lx.extract(model_id="grok-4.6") auto-route without LiteLLM or a custom plugin.

Current-generation IDs this would cover:

  • Claude: claude-sonnet-5 (default), claude-opus-5, claude-fable-5, claude-haiku-4-5
  • Grok: grok-4.6 (default), plus grok-4.5 / grok-*

Env keys: ANTHROPIC_API_KEY, XAI_API_KEY (Grok also uses the existing OpenAI SDK extra at https://api.x.ai/v1).

Related to an issue?

Related to #99 (plugin support) and #187 (LiteLLM, which can already reach Anthropic as a community plugin). This request is for built-in routing of the native model IDs, matching how Gemini / OpenAI / Ollama work today.

Possible solutions and alternatives

Proposed: two optional built-in providers in langextract.providers:

  • AnthropicLanguageModel — Anthropic Messages API
  • XAILanguageModel — subclass of the OpenAI-compatible provider with xAI base URL + XAI_API_KEY

Factory env-key lookup would recognize claude* / grok* the same way it already recognizes gemini* / gpt*.

Alternatives:

  • Keep using langextract-litellm (#187) and pass Anthropic/xAI through LiteLLM.
  • Publish separate langextract-anthropic / langextract-xai community plugins (CONTRIBUTING.md's preferred path for new providers).

Built-in support is still useful because claude-* and grok-* IDs currently match no provider and fail with InferenceConfigError.

Priority and timeline considerations

Nice-to-have / developer-experience. Claude 5 and Grok 4.6 are the current generally-available IDs as of August 2026.

Additional context

pyproject.toml extras (langextract[anthropic]) would be a maintainer follow-up if this is accepted; a first patch can document pip install anthropic so the PR does not touch protected infrastructure files.

I would like to contribute this and have an implementation ready.