Skip to main content

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

Metadata

Release files for langextract-claude 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langextract-claude 0.1.0
File Size Uploaded
langextract_claude-0.1.0.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langextract-claude 0.1.0
File Interpreter ABI Platform
langextract_claude-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / langextract_claude-0.1.0.tar.gz

Download URL langextract_claude-0.1.0.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d3ada1c75022d5ebad986e665f45c993a38ef1f69e8ef51f4291ad98726e9801
BLAKE2b-256 checksum
How to use checksums
758089f3c271cb230245413505f8807a18bb4bb7584647da396b92168bfb0dce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / langextract_claude-0.1.0-py3-none-any.whl

Download URL langextract_claude-0.1.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca41e3795c96eb63752a64fc2e3111816dff75b417d2e08b2ec8595998682090
BLAKE2b-256 checksum
How to use checksums
3b75945cddf849bb7379229a8a57b91efd892839ada92b8f5203b19424f5401d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page