Request: Built-in Anthropic (Claude) and xAI (Grok) providers
- Dominant language
- Python
- Stars
- 38.6k
- Forks
- 2.7k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 3
Description
## 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.
Contributor guide
Research direction
Read CONTRIBUTING.md and inspect langextract.providers plus the factory's existing model-ID and environment-key lookup for Gemini, OpenAI, and Ollama. Confirm the proposed Anthropic Messages API and OpenAI-compatible xAI routes, including the documented pip install requirement. Done means Claude and Grok IDs route without LiteLLM or a plugin and the relevant provider behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100