{"id":9066,"library":"langextract","title":"LangExtract Library","description":"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.","status":"active","version":"1.2.1","language":"en","source_language":"en","source_url":"https://github.com/google/langextract","tags":["LLM","data extraction","structured data","AI","NLP"],"install":[{"cmd":"pip install langextract","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"extract","correct":"from langextract import extract"},{"symbol":"ModelConfig","correct":"from langextract import ModelConfig"},{"symbol":"ProviderConfig","correct":"from langextract import ProviderConfig"},{"symbol":"langextract_schema","correct":"from langextract.dataclasses import langextract_schema"},{"symbol":"LangExtractSchema","correct":"from langextract.dataclasses import LangExtractSchema"}],"quickstart":{"code":"import os\nfrom langextract import extract, dataclasses\n\n# Define a simple schema for extraction\n@dataclasses.langextract_schema\nclass Person(dataclasses.LangExtractSchema):\n    name: str\n    age: int\n    occupation: str\n\ntext = \"John Doe is a software engineer aged 30.\"\n\n# Use a dummy OpenAI key for quickstart, actual key from env\nos.environ['OPENAI_API_KEY'] = os.environ.get('OPENAI_API_KEY', 'sk-dummy-key')\n\n# Extract data using the schema\nresult = extract(\n    text=text,\n    schema=Person,\n    model_name=\"gpt-3.5-turbo\" # Or any other supported model\n)\n\nprint(result.extracted_data)\n# Expected: Person(name='John Doe', age=30, occupation='software engineer')","lang":"python","description":"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`)."},"warnings":[{"fix":"Update to `langextract>=1.0.4` and ensure your `ModelConfig` for Ollama uses `model_id='llama2'` instead of `model='llama2'`.","message":"Prior to v1.0.4, `OllamaLanguageModel` used the `model` parameter. This was changed to `model_id` in v1.0.4 for consistency.","severity":"breaking","affected_versions":"<1.0.4"},{"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.","message":"Using `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.","severity":"gotcha","affected_versions":"<1.2.1"},{"fix":"Upgrade to `langextract>=1.2.0` to ensure proper loading and resolution of model providers.","message":"When 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`.","severity":"gotcha","affected_versions":"<1.2.0"},{"fix":"Upgrade to `langextract>=1.1.1` to ensure the `project` parameter is correctly passed to the Vertex AI Batch API.","message":"For 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.","severity":"gotcha","affected_versions":"<1.1.1"},{"fix":"If you relied on the `debug=True` behavior, explicitly set `debug=True` in your `extract()` calls after upgrading to `langextract>=1.0.9`.","message":"The `debug` parameter in `extract()` defaulted to `True` in versions prior to v1.0.9, resulting in verbose output. It now defaults to `False`.","severity":"gotcha","affected_versions":"<1.0.9"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `langextract` to version 1.2.1 or newer (`pip install --upgrade langextract`).","cause":"Incorrect parameter passing for `reasoning_effort` with specific OpenAI models (o1, o3, o4-mini, gpt-5) in `langextract` versions prior to 1.2.1.","error":"unexpected keyword argument 'reasoning'"},{"fix":"Upgrade `langextract` to version 1.2.0 or newer (`pip install --upgrade langextract`).","cause":"Built-in model providers were not correctly loaded when specified by name in `ModelConfig` for `langextract` versions prior to 1.2.0.","error":"InferenceConfigError: Could not resolve model provider for 'ollama'"},{"fix":"Upgrade `langextract` to version 1.1.1 or newer (`pip install --upgrade langextract`).","cause":"Missing or incorrect `project` parameter handling for Vertex AI Gemini Batch API calls in `langextract` versions prior to 1.1.1.","error":"ValueError: Required parameter: project"},{"fix":"Update your `ModelConfig` for Ollama to use `model_id` instead of `model`, e.g., `ModelConfig(provider='ollama', model_id='llama2')`.","cause":"The `OllamaLanguageModel` parameter for specifying the model ID changed from `model` to `model_id` in `langextract` v1.0.4.","error":"TypeError: OllamaLanguageModel.__init__() got an unexpected keyword argument 'model'"}]}