Query parameters
-
The amount of time to wait for the inference request to complete.
Default value is
120s.
Body
Required
- input
object | array[object] Required The documents to extract the content from. Either a
contentobject or an array ofcontentobjects.contentobject example:"input": { "content": { "type": "pdf", "format": "base64", "value": "data:application/pdf;base64,..." } }contentobject array example:"input": [ { "content": { "type": "pdf", "format": "base64", "value": "data:application/pdf;base64,..." } }, { "content": { "type": "image", "format": "url", "value": "https://example.com/scanned-page.png" } } ] -
Task settings for the individual inference request. These settings are specific to the task type you specified and override the task settings specified when initializing the service.
POST
/_inference/document_extraction/{inference_id}
Console
POST _inference/document_extraction/my-document-extraction-endpoint
{
"input": [
{
"content": {
"type": "pdf",
"format": "base64",
"value": "data:application/pdf;base64,..."
}
}
]
}
resp = client.inference.document_extraction(
inference_id="my-document-extraction-endpoint",
input=[
{
"content": {
"type": "pdf",
"format": "base64",
"value": "data:application/pdf;base64,..."
}
}
],
)
const response = await client.inference.documentExtraction({
inference_id: "my-document-extraction-endpoint",
input: [
{
content: {
type: "pdf",
format: "base64",
value: "data:application/pdf;base64,...",
},
},
],
});
response = client.inference.document_extraction(
inference_id: "my-document-extraction-endpoint",
body: {
"input": [
{
"content": {
"type": "pdf",
"format": "base64",
"value": "data:application/pdf;base64,..."
}
}
]
}
)
$resp = $client->inference()->documentExtraction([
"inference_id" => "my-document-extraction-endpoint",
"body" => [
"input" => array(
[
"content" => [
"type" => "pdf",
"format" => "base64",
"value" => "data:application/pdf;base64,...",
],
],
),
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"input":[{"content":{"type":"pdf","format":"base64","value":"data:application/pdf;base64,..."}}]}' "$ELASTICSEARCH_URL/_inference/document_extraction/my-document-extraction-endpoint"
Request examples
Document extraction task
Run `POST _inference/document_extraction/my-document-extraction-endpoint` to extract the content of the example PDF document
{
"input": [
{
"content": {
"type": "pdf",
"format": "base64",
"value": "data:application/pdf;base64,..."
}
}
]
}
Run `POST _inference/document_extraction/my-document-extraction-endpoint` to extract the content of an image of a document referenced by URL as markdown.
{
"input": {
"content": {
"type": "image",
"format": "url",
"value": "https://example.com/scanned-page.png"
}
},
"task_settings": {
"output_format": "markdown"
}
}
Response examples (200)
An abbreviated response from `POST _inference/document_extraction/my-document-extraction-endpoint`.
{
"document_extraction": [
{
"content": "# Annual Report 2025\n\n...",
"format": "markdown",
"metadata": {
"title": "Annual Report 2025"
}
}
]
}