endpoint
POST /v1/extract
Takes a piece of text, or photos and scans of a document’s pages, and a JSON Schema describing what you want from it, and returns one JSON object that fills the schema. Numbers come back as numbers, dates as ISO dates, lists in the order the text gives them. A field the text does not contain comes back empty rather than invented.
The schema is the standard one you already have: what Pydantic’s model_json_schema(), Zod or an OpenAI response_format produce. Extractor 1 reads the field names and descriptions, so a description is the place to say what you mean by a field.
Request
curl https://meragpt.com/v1/extract \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "extractor-1",
"text": "Confirming your cleaning with Dr. Patel on Tuesday 9 December at 2:30 pm. Copay is $25.",
"reference_date": "2026-12-01",
"schema": {
"type": "object",
"properties": {
"dentist": { "type": "string" },
"date": { "type": "string", "format": "date" },
"time": { "type": "string", "format": "time" },
"copay_usd": { "type": "number" },
"insurance_id": { "type": ["string", "null"] }
},
"required": ["dentist", "date", "time", "copay_usd", "insurance_id"]
}
}'| field | type | notes |
|---|---|---|
text | string | The text to read, up to 600,000 characters; see long documents below. Send this or images. |
images | array | Pages of one document, in order: up to 6, each an https URL or a base64 data URL, PNG, JPEG, WebP or GIF, up to 10 MB. Send this or text. |
schema | object | Required. A JSON Schema whose root is an object with at least one property. |
reference_date | string | Optional, YYYY-MM-DD. The date the text was written, so “next Friday” resolves to a date. |
question | string | Optional. A question the answer should address, when the schema alone does not say what to look for. |
model | string | Optional, defaults to extractor-1. |
Response
{
"id": "req_...",
"object": "extraction",
"model": "extractor-1",
"data": {
"dentist": "Dr. Patel",
"date": "2026-12-09",
"time": "14:30",
"copay_usd": 25,
"insurance_id": null
},
"windows": 1,
"usage": { "prompt_tokens": 182, "completion_tokens": 41, "total_tokens": 223, "cost_usd": "$0.0000073" },
"balance_usd": "$4.99"
}data is plain JSON in your schema’s shape, so it drops straight into a Pydantic model. A property you leave out of required, or whose type allows null, is null when the text does not say; a list the text has no items for is [].
Schemas
| JSON Schema | what comes back |
|---|---|
string | the value as the text gives it |
number, integer | a number; a description can name the unit (“in minutes”), and simple sums and conversions are worked out |
string + format: date | time | date-time | ISO 2026-12-09, 14:30, 2026-12-09T14:30 |
string + format: duration | an ISO 8601 duration |
boolean | true or false |
enum | one of your options |
array | items in the order the text gives them |
object | nested objects, to any depth up to ten |
$ref to $defs | inlined, as Pydantic emits for nested models; recursion is refused |
anyOf: [X, {"type": "null"}] | nullable X, as Pydantic emits for Optional |
A keyword the model cannot honour (pattern, oneOf, allOf, minLength, other formats) is refused with a 400 unsupported_schema that names it, rather than ignored.
Images
Photos, scans and screenshots work the same way: send the pages as images instead of text, with the same schema. The model reads the page itself, so there is no OCR step to run first and nothing lost between it and the model. A multi-page document goes in one request, pages in order. Image tokens are billed as input, like text: a receipt photo is about 1,500 tokens, so a fraction of a cent.
curl https://meragpt.com/v1/extract \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "extractor-1",
"images": ["https://example.com/receipts/2026-11-21.jpg"],
"schema": {
"type": "object",
"properties": {
"store": { "type": "string" },
"date": { "type": "string", "format": "date" },
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"quantity": { "type": "integer" },
"price": { "type": "number" }
}
}
},
"total": { "type": "number" }
}
}
}'On /v1/chat/completions, put the pages in the user message as image_url parts; any text in that message is treated as your instruction and the model reads the pages.
Memory for agents
To pull memories out of a conversation, ask for a list. Facts the user states about themselves come back one per item, and a turn with nothing worth keeping comes back as an empty list rather than padded with guesses, so what you store is what was said. The answer below is the model’s own output.
"text": "user: I just moved to Lisbon for a job at a fintech.\nassistant: Congratulations! How are you settling in?\nuser: Good, though I'm vegetarian and still looking for places to eat.",
"schema": {
"type": "object",
"properties": {
"memories": {
"type": "array",
"description": "Facts about the user worth remembering, one per item.",
"items": { "type": "string" }
}
}
}
"data": {
"memories": [
"The user recently moved to Lisbon.",
"The user is looking for new places to eat.",
"The user is vegetarian."
]
}Long documents
One request reads up to 32,768 tokens at a time, schema included. Longer text is split on line breaks into windows, each window is read with the same schema, and the answers are merged: a single value is the first one found in document order, a list is every window’s items in order with duplicates dropped, and an object is merged field by field. windows in the response says how many were read. Every token is billed, so a document read in four windows costs about four times one window.
OpenAI-compatible structured output
The same model answers on /v1/chat/completions with response_format: {"type": "json_schema"}, so the OpenAI SDK, Instructor and LangChain’s with_structured_output work by changing the base URL and the model name. The user messages are the text; system messages are ignored, because the model’s instruction is fixed. The answer is the JSON string in message.content.
from openai import OpenAI
from pydantic import BaseModel
class Appointment(BaseModel):
dentist: str
date: str
copay_usd: float | None
client = OpenAI(base_url="https://meragpt.com/v1", api_key=MERAGPT_API_KEY)
r = client.beta.chat.completions.parse(
model="extractor-1",
messages=[{"role": "user", "content": email_text}],
response_format=Appointment,
)
print(r.choices[0].message.parsed)Sizes and price
| text per request | 600,000 characters |
| images per request | 6 pages |
| read at a time | 32,768 tokens, schema included |
| answer | up to 4,096 tokens of JSON per window |
| input | $0.04 / 1M tokens |
| output | free: the answer’s tokens are counted and reported, never charged |
| repeatability | same input, same output |
A schema so large that its answer does not finish within the output limit fails with 502 unparseable_output and is not charged; split the schema across requests. Errors use the OpenAI envelope: see errors.