Skip to content

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

Description

@jaideepkumar69-tech

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:

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions