AI
Extract metadata (structured)
Sends an AI request to supported Large Language Models (LLMs) and returns extracted metadata as a set of key-value pairs.
To define the extraction structure, provide either a metadata template or a list of fields. To learn more about creating templates, see Creating metadata templates in the Admin Console or use the metadata template API.
This endpoint also supports Enhanced Extract Agent.
For information about supported file formats and languages, see the Extract metadata from file (structured) API guide.
post/ai/extract_structured
Request body
Example request
{
"items": [
{
"id": "123",
"type": "file",
"content": "This is file content."
}
],
"metadata_template": {
"template_key": "invoiceTemplate",
"type": "metadata_template",
"scope": "enterprise_12345"
},
"fields": [
{
"key": "name",
"description": "The name of the person.",
"displayName": "Name",
"prompt": "Name is the first and last name from the email address",
"type": "enum",
"options": [
{
"key": "First Name"
},
{
"key": "Last Name"
}
],
"fields": [
{
"key": "street_name",
"description": "The street name of the address.",
"displayName": "Street Name",
"prompt": "The street name from the address section",
"type": "string",
"options": [
{
"key": "First Name"
}
]
}
],
"taxonomy_key": "certification_taxonomy",
"namespace": "enterprise_123",
"options_rules": {
"multi_select": true,
"selectable_levels": [
1
]
}
}
],
"ai_agent": {
"type": "ai_agent_id",
"id": "14031"
},
"include_confidence_score": true,
"include_reference": true,
"taxonomy_sources": [
{
"type": "taxonomy",
"taxonomy_key": "certification_taxonomy",
"namespace": "enterprise_123"
},
{
"type": "file",
"taxonomy_key": "industry_taxonomy",
"id": "1234567890"
}
]
}Response
A successful response including the answer from the LLM.
Example response
{
"created_at": "2012-12-12T10:53:43-08:00",
"completion_reason": "done",
"ai_agent_info": {
"models": [
{
"name": "azure__openai__text_embedding_ada_002",
"provider": "azure",
"supported_purpose": "embedding"
}
],
"processor": "basic_text"
}
}