Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
schema = {
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"total_amount": {"type": "number"},
"due_date": {"type": "string"},
},
"required": ["invoice_number", "total_amount"],
}
with open("invoice_acme_corp.pdf", "rb") as file:
response = client.documents.submit_deep_transform(
file=file,
schema=schema,
)
print(f"Job submitted: {response.job_id}")import fs from "fs";
import { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const schema = {
type: "object",
properties: {
invoiceNumber: { type: "string" },
totalAmount: { type: "number" },
lineItems: {
type: "array",
items: {
type: "object",
properties: {
description: { type: "string" },
quantity: { type: "number" },
unitPrice: { type: "number" },
},
},
},
},
required: ["invoiceNumber", "totalAmount"],
};
const response = await client.documents.submitDeepTransform({
file: fs.createReadStream("./invoices/invoice-2024-0142.pdf"),
schema,
});
console.log(`Submitted deep-transform job: ${response.job_id}`);package main
import (
"context"
"fmt"
"log"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
file, err := os.Open("./invoice_2024_04.pdf")
if err != nil {
log.Fatal(err)
}
defer file.Close()
resp, err := client.Documents.SubmitDeepTransform(context.Background(), v2.BodySubmitDeepTransform{
File: file,
Schema: map[string]any{
"type": "object",
"properties": map[string]any{
"invoice_number": map[string]any{"type": "string"},
"total_amount": map[string]any{"type": "number"},
"due_date": map[string]any{"type": "string", "format": "date"},
},
"required": []string{"invoice_number", "total_amount"},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Deep-transform job submitted: %s\n", resp.JobID)
}curl --request POST \
--url https://api.meibel.ai/v2/documents/deep-transform \
--header 'Content-Type: multipart/form-data' \
--header 'Meibel-API-Key: <api-key>' \
--form file='@example-file' \
--form 'schema=<string>' \
--form 'root_name=<string>' \
--form 'guidance=<string>' \
--form max_pages=123const form = new FormData();
form.append('file', '<string>');
form.append('schema', '<string>');
form.append('root_name', '<string>');
form.append('guidance', '<string>');
form.append('max_pages', '123');
const options = {method: 'POST', headers: {'Meibel-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.meibel.ai/v2/documents/deep-transform', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meibel.ai/v2/documents/deep-transform",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data; boundary=---011000010111000001101001",
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.meibel.ai/v2/documents/deep-transform")
.header("Meibel-API-Key", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/documents/deep-transform")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Meibel-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"job_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Deep transform
Submit a deep-transform extraction from a file upload (async)
Upload a document and submit an extraction against a JSON schema, returning immediately with a job id. To reuse an already-parsed document instead of uploading, use POST /documents/deep-transform/from-document. Poll status via GET /documents/deep-transform/ and download artifacts once it succeeds. Submission is idempotent on the (document, schema) pair.
POST
/
documents
/
deep-transform
Python
import os
from meibel import MeibelClient
client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])
schema = {
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"total_amount": {"type": "number"},
"due_date": {"type": "string"},
},
"required": ["invoice_number", "total_amount"],
}
with open("invoice_acme_corp.pdf", "rb") as file:
response = client.documents.submit_deep_transform(
file=file,
schema=schema,
)
print(f"Job submitted: {response.job_id}")import fs from "fs";
import { MeibelClient } from "meibel";
const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });
const schema = {
type: "object",
properties: {
invoiceNumber: { type: "string" },
totalAmount: { type: "number" },
lineItems: {
type: "array",
items: {
type: "object",
properties: {
description: { type: "string" },
quantity: { type: "number" },
unitPrice: { type: "number" },
},
},
},
},
required: ["invoiceNumber", "totalAmount"],
};
const response = await client.documents.submitDeepTransform({
file: fs.createReadStream("./invoices/invoice-2024-0142.pdf"),
schema,
});
console.log(`Submitted deep-transform job: ${response.job_id}`);package main
import (
"context"
"fmt"
"log"
"os"
v2 "github.com/meibel-ai/meibel-go/v2"
)
func main() {
client := v2.NewClient(v2.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
file, err := os.Open("./invoice_2024_04.pdf")
if err != nil {
log.Fatal(err)
}
defer file.Close()
resp, err := client.Documents.SubmitDeepTransform(context.Background(), v2.BodySubmitDeepTransform{
File: file,
Schema: map[string]any{
"type": "object",
"properties": map[string]any{
"invoice_number": map[string]any{"type": "string"},
"total_amount": map[string]any{"type": "number"},
"due_date": map[string]any{"type": "string", "format": "date"},
},
"required": []string{"invoice_number", "total_amount"},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Deep-transform job submitted: %s\n", resp.JobID)
}curl --request POST \
--url https://api.meibel.ai/v2/documents/deep-transform \
--header 'Content-Type: multipart/form-data' \
--header 'Meibel-API-Key: <api-key>' \
--form file='@example-file' \
--form 'schema=<string>' \
--form 'root_name=<string>' \
--form 'guidance=<string>' \
--form max_pages=123const form = new FormData();
form.append('file', '<string>');
form.append('schema', '<string>');
form.append('root_name', '<string>');
form.append('guidance', '<string>');
form.append('max_pages', '123');
const options = {method: 'POST', headers: {'Meibel-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.meibel.ai/v2/documents/deep-transform', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.meibel.ai/v2/documents/deep-transform",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data; boundary=---011000010111000001101001",
"Meibel-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.meibel.ai/v2/documents/deep-transform")
.header("Meibel-API-Key", "<api-key>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meibel.ai/v2/documents/deep-transform")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Meibel-API-Key"] = '<api-key>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"schema\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"root_name\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"guidance\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"max_pages\"\r\n\r\n123\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"job_id": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Body
multipart/form-data
Document file to extract from
JSON Schema (as a JSON string) of the entities to extract
Name of the root entity in the schema. Optional: resolved from the schema's title or inferred when omitted.
Optional domain guidance for the extraction
Optional cap on the number of pages to process
Response
Successful Response
Poll status via GET /documents/deep-transform/{job_id}
Was this page helpful?
⌘I