Skip to main content

Anthropic Claude provider plugin for LangExtract

Project description

langextract-claude

Anthropic Claude provider for LangExtract.

LangExtract ships with Gemini, Vertex AI, OpenAI, and Ollama providers. This package adds Claude support as a third-party provider plugin.

Installation

pip install langextract-claude

Usage

import langextract as lx

results = lx.extract(text, schema, model_id="claude-sonnet-4-6")

Any claude-* model ID is automatically routed to this provider. The default model is claude-sonnet-4-6.

Configuration

The API key is resolved in order:

  1. Explicit api_key parameter
  2. ANTHROPIC_API_KEY environment variable
  3. LANGEXTRACT_API_KEY environment variable
from langextract_claude import AnthropicLanguageModel

model = AnthropicLanguageModel(
    model_id="claude-sonnet-4-6",
    api_key="sk-ant-...",       # or set ANTHROPIC_API_KEY
    temperature=0.0,
    max_tokens=8192,
    max_workers=5,              # parallel inference threads
)

Features

  • Multi-block JSON normalization — Claude sometimes splits large extractions across multiple fenced code blocks. This provider automatically merges them into a single block that LangExtract can parse.
  • Parallel inference — batch prompts are processed concurrently via a thread pool (configurable max_workers, default 5).
  • Auto-discovery — any model ID matching ^claude is routed here. No manual provider registration needed.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langextract_claude-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langextract_claude-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file langextract_claude-0.1.0.tar.gz.

File metadata

  • Download URL: langextract_claude-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for langextract_claude-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3ada1c75022d5ebad986e665f45c993a38ef1f69e8ef51f4291ad98726e9801
MD5 2d8fe1a44b930569b4162104f5af393a
BLAKE2b-256 758089f3c271cb230245413505f8807a18bb4bb7584647da396b92168bfb0dce

See more details on using hashes here.

File details

Details for the file langextract_claude-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langextract_claude-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca41e3795c96eb63752a64fc2e3111816dff75b417d2e08b2ec8595998682090
MD5 1a266f2290d659a32b231b27fc20a6b0
BLAKE2b-256 3b75945cddf849bb7379229a8a57b91efd892839ada92b8f5203b19424f5401d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page