google/langextract/langextract-usage
Claude Code and agent skill by google/langextract
- vendor
- ext:[{"type":"plugin","description":"Custom plugin integration"}]
Checking that the SKILL.md file is still in the repository.
How to use LangExtract to extract structured information from text. Use when writing code that calls lx.extract(), building extraction pipelines, defining examples, or troubleshooting alignment issues.
Install
npx vskill@latest install google/langextract/langextract-usageSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
LangExtract Usage
LangExtract extracts structured information from unstructured text using LLMs. The main entry point is lx.extract(). Every extraction needs at least one example and input text. prompt_description is optional but recommended.
Install
API keys
Auto-routing + env-default resolution is tuned for GPT-style model IDs (gpt-4*, gpt-5*, gpt-6*). For OpenAI-compatible endpoints or non-GPT IDs, pass an explicit ModelConfig — see references/providers.md.
Basic extraction
See examples/basic_extraction.py for a runnable version and examples/relationship_extraction.py for using extraction_class + attributes to encode relationships between entities.
Writing good examples
Examples drive model behavior. Follow these rules:
extraction_textmust be verbatim from the example text, not paraphrased- List extractions in order of appearance in the text
- Each
extraction_classshould be consistent across examples - Include attributes that match what you want extracted at runtime
LangExtract can raise prompt-alignment warnings when an example's extraction_text values don't align cleanly to the example's text (failed alignment, or fuzzy/lesser rather than exact). The validator does not enforce rules 2–4 above — those are guidance to steer the model's output, not checked invariants.
To fail fast on alignment issues during development, pass these kwargs directly to lx.extract() (both default to permissive):
See references/prompt-validation.md for level semantics and strict-mode behavior.
Key parameters
text_or_documentsaccepts a URL string, which is fetched only when
fetch_urls=True; otherwise it is treated as text. Only enable fetching for URLs from a trusted source, in a sandboxed process.
- For full parallelism, keep
batch_length >= max_workers. Parallel
processing via max_workers is provider-dependent; some providers parallelize batched prompts, while others (such as the current Ollama provider) process them sequentially.
context_window_charsincludes characters from the previous chunk as
context for the current one, which helps with coreference and entity continuity across chunk boundaries.
- For multiple documents, pass a list of
lx.data.Document— see
examples/multiple_documents.py.
Working with results
Provider selection
The default is Gemini. For other providers, see references/providers.md, which covers:
- OpenAI (JSON mode; fence behavior auto-configured)
- Ollama (local models,
model_url) ModelConfigfor advanced provider_kwargs (custombase_url, etc.)- Custom provider plugins via
router.register()
Common issues
Extractions with `char_interval=None`: the extraction could not be located in the source text. Common causes include paraphrased output, alignment misses, or hallucinated entities. Filter with [e for e in result.extractions if e.char_interval]. To tune alignment, see references/resolver-params.md.
Prompt alignment warnings: your examples have extraction_text that doesn't match the example text verbatim. Fix the examples, or see references/prompt-validation.md to fail fast during development.
Slow on long documents: extraction_passes > 1 multiplies processing time. Start with 1 and increase only if recall is insufficient.
Model selection: gemini-2.5-flash is recommended for most tasks; gemini-2.5-pro for complex reasoning.
Further reading
references/providers.md— OpenAI, Ollama, ModelConfig, custom pluginsreferences/resolver-params.md— fuzzy alignment tuningreferences/prompt-validation.md— catching example issues earlyexamples/— runnable scripts for each scenario above
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 26 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/langextract-usage/SKILL.md
Popularity
- Repository stars
- 39,047
- Repository forks
- 2,731
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 Jul 2026, 3 months ago.
Extension points
pluginCustom plugin integration
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/google/langextract/langextract-usage)