LangExtract, an open-source project from Google: https://github.com/google/langextractLangExtract is a Python library developed by Google, focused on "extracting structured information from unstructured text using large language models (LLMs)." Its core features include: It can extract structured data such as entities, attributes, and relationships from text (e.g., medical reports, literary works) based on your custom rules and examples. It can precisely locate results within the original text, making it easy to implement highlighting, visualization, and traceability. Especially suitable for long texts, such as parsing an entire novel or lengthy medical report at once, using chunked parallel processing and multiple iterations to improve recall. Built-in interactive HTML visualization allows you to vividly display extraction results on web pages.Pricing: Calculated based on model invocation costs
Request
Header Params
Body Params application/json
Examples
{"model_id":"gemini-2.5-flash","text_or_documents":"Lady Juliet gazed longingly at the stars, her heart aching for Romeo","prompt":"\n\t\t\tExtract characters, emotions, and relationships in order of appearance.\n\t\t Use exact text for extractions. Do not paraphrase or overlap entities.\n\t\t Provide meaningful attributes for each entity to add context.\n\t\t\t","examples":[{"extractions":[{"attributes":{"emotional_state":"wonder"},"extraction_class":"character","extraction_text":"ROMEO"},{"attributes":{"feeling":"gentle awe"},"extraction_class":"emotion","extraction_text":"But soft!"},{"attributes":{"type":"metaphor"},"extraction_class":"relationship","extraction_text":"Juliet is the sun"}],"text":"\n\t\t\t\t\tROMEO. But soft! What light through yonder window breaks? It is the east, and Juliet is the sun.\n\t\t\t\t\t"}]}
Request Code Samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
cURL
curl--location--request POST 'https://api.302.ai/302/langextract/task' \
--header'Authorization: Bearer sk-jls4AaVBGoe1GwZD64qZA1qyKTN1MPHa4NmvH1cT68z7K1Zz' \
--header'Content-Type: application/json' \
--data-raw'{
"model_id": "gemini-2.5-flash",
"text_or_documents": "Lady Juliet gazed longingly at the stars, her heart aching for Romeo",
"prompt": "\n\t\t\tExtract characters, emotions, and relationships in order of appearance.\n\t\t Use exact text for extractions. Do not paraphrase or overlap entities.\n\t\t Provide meaningful attributes for each entity to add context.\n\t\t\t",
"examples": [
{
"extractions": [
{
"attributes": {
"emotional_state": "wonder"
},
"extraction_class": "character",
"extraction_text": "ROMEO"
},
{
"attributes": {
"feeling": "gentle awe"
},
"extraction_class": "emotion",
"extraction_text": "But soft!"
},
{
"attributes": {
"type": "metaphor"
},
"extraction_class": "relationship",
"extraction_text": "Juliet is the sun"
}
],
"text": "\n\t\t\t\t\tROMEO. But soft! What light through yonder window breaks? It is the east, and Juliet is the sun.\n\t\t\t\t\t"
}
]
}'