Registry / llm-agents / langextract

langextract

JSON →
library1.5.0pypypi✓ verified 85d ago

LangExtract is a Python library for robustly extracting structured data from large language models (LLMs). It handles automatic chunking, multi-language support, and provides integrations with various LLM providers (e.g., OpenAI, Vertex AI, Ollama). The current version is 1.2.1, with a frequent release cadence, often introducing new providers, features, and bug fixes.

pip install langextract
INSTALL
IMPORT
SIG · LANGEXTRACT
L
langextract
llm-agentspythonv1.5.0
Install
16.5s avg
Import
2268ms
Disk
243MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 19.4s
py 3.11
✓ —
✓ 16.7s
py 3.12
✓ —
✓ 14.7s
py 3.13
✓ —
✓ 15.2s
py 3.9
✕ build_error
✕ build_error
243MB installed
● package 243MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

extract
from langextract import extract
ModelConfig
from langextract import ModelConfig
ProviderConfig
from langextract import ProviderConfig
langextract_schema
from langextract.dataclasses import langextract_schema
LangExtractSchema
from langextract.dataclasses import LangExtractSchema

This quickstart defines a schema using `langextract_schema` and then uses the `extract` function to parse structured data from a given text, demonstrating a basic usage pattern. Ensure your LLM provider's API key is available (e.g., `OPENAI_API_KEY`).

import os from langextract import extract, dataclasses # Define a simple schema for extraction @dataclasses.langextract_schema class Person(dataclasses.LangExtractSchema): name: str age: int occupation: str text = "John Doe is a software engineer aged 30." # Use a dummy OpenAI key for quickstart, actual key from env os.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'sk-dummy-key') # Extract data using the schema result = extract( text=text, schema=Person, model_name="gpt-3.5-turbo" # Or any other supported model ) print(result.extracted_data) # Expected: Person(name='John Doe', age=30, occupation='software engineer')
Debug
Known issues
breakingPrior to v1.0.4, `OllamaLanguageModel` used the `model` parameter. This was changed to `model_id` in v1.0.4 for consistency.
fix
Update to `langextract>=1.0.4` and ensure your `ModelConfig` for Ollama uses `model_id='llama2'` instead of `model='llama2'`.
affects: <1.0.4
gotchaUsing `reasoning_effort` with certain OpenAI models (e.g., o1, o3, o4-mini, gpt-5) in versions <1.2.1 would cause an `unexpected keyword argument 'reasoning'` error due to incorrect parameter passing.
fix
Upgrade to `langextract>=1.2.1` to fix the parameter passing, or avoid using `reasoning_effort` for affected models if an upgrade is not possible.
affects: <1.2.1
gotchaWhen specifying an LLM provider by name (e.g., `ModelConfig(provider='ollama')`), versions <1.2.0 could fail to load built-in providers correctly, leading to an `InferenceConfigError`.
fix
Upgrade to `langextract>=1.2.0` to ensure proper loading and resolution of model providers.
affects: <1.2.0
gotchaFor users of Gemini Batch API with Vertex AI, versions <1.1.1 might have encountered a 'Required parameter: project' error due to incorrect parameter handling.
fix
Upgrade to `langextract>=1.1.1` to ensure the `project` parameter is correctly passed to the Vertex AI Batch API.
affects: <1.1.1
gotchaThe `debug` parameter in `extract()` defaulted to `True` in versions prior to v1.0.9, resulting in verbose output. It now defaults to `False`.
fix
If you relied on the `debug=True` behavior, explicitly set `debug=True` in your `extract()` calls after upgrading to `langextract>=1.0.9`.
affects: <1.0.9
Errors
Common errors & fixes
unexpected keyword argument 'reasoning'
Incorrect parameter passing for `reasoning_effort` with specific OpenAI models (o1, o3, o4-mini, gpt-5) in `langextract` versions prior to 1.2.1.
fix
Upgrade `langextract` to version 1.2.1 or newer (`pip install --upgrade langextract`).
InferenceConfigError: Could not resolve model provider for 'ollama'
Built-in model providers were not correctly loaded when specified by name in `ModelConfig` for `langextract` versions prior to 1.2.0.
fix
Upgrade `langextract` to version 1.2.0 or newer (`pip install --upgrade langextract`).
ValueError: Required parameter: project
Missing or incorrect `project` parameter handling for Vertex AI Gemini Batch API calls in `langextract` versions prior to 1.1.1.
fix
Upgrade `langextract` to version 1.1.1 or newer (`pip install --upgrade langextract`).
TypeError: OllamaLanguageModel.__init__() got an unexpected keyword argument 'model'
The `OllamaLanguageModel` parameter for specifying the model ID changed from `model` to `model_id` in `langextract` v1.0.4.
fix
Update your `ModelConfig` for Ollama to use `model_id` instead of `model`, e.g., `ModelConfig(provider='ollama', model_id='llama2')`.
Upgrade
Version history
1.5.0latest on PyPI · released May 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
langextract — pip install langextract · libregistry