All guides
Extract structured data (JSON)
Strict structured output makes the model return JSON that matches your schema every time: right fields, right types, no extra text. It is the simplest way to put AI into a pipeline, CRM or spreadsheet.
Recommended models
Chosen from models whose abilities we have verified for this job. Cost is for one email or form (about 600 tokens in, 120 out), at current prices.
| Model | Input / 1M | Output / 1M | Context | Per request |
|---|---|---|---|---|
| Our pickDeepSeek V4.1 Flash deepseek/deepseek-v4.1-flash | $0.375 | $1.50 | 1.05M | $0.000405 |
| Also strongGLM 5.3 Flash z-ai/glm-5.3-flash | $0.1875 | $0.625 | 1.05M | $0.000188 |
| Lowest costgpt-oss-20b openai/gpt-oss-20b | $0.0625 | $0.5625 | 128K | $0.000105 |
How it works
- 1Describe the fields you want as a JSON Schema. List every field in required and set additionalProperties to false.
- 2For values that may be missing, ask for an empty string or 0 instead of leaving the field out.
- 3Send response_format with type json_schema and strict: true, then parse the reply with JSON.parse or json.loads.
Copy, paste, run
Set AMR_API_KEY to a key from your dashboard, install the OpenAI SDK (pip install openai or npm install openai) and run it. Swap the model for any other in the table.
import json
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.aimodelsrouter.ai/v1", api_key=os.environ["AMR_API_KEY"])
MODEL = "deepseek/deepseek-v4.1-flash"
# Describe exactly the fields you want. With "strict": True the reply always matches this schema.
schema = {
"type": "object",
"properties": {
"name": {"type": "string"},
"email": {"type": "string", "description": "Empty string if not given"},
"company": {"type": "string", "description": "Empty string if not given"},
"seats": {"type": "integer", "description": "0 if not given"},
"intent": {"type": "string", "enum": ["sales", "support", "billing", "other"]},
},
"required": ["name", "email", "company", "seats", "intent"],
"additionalProperties": False,
}
message = "Hi, I'm Dana Ruiz from Northwind Traders (dana@northwind.example). Could we get a quote for 50 seats?"
response = client.chat.completions.create(
model=MODEL,
messages=[
{"role": "system", "content": "Extract the requested fields from the customer's message."},
{"role": "user", "content": message},
],
response_format={"type": "json_schema", "json_schema": {"name": "lead", "strict": True, "schema": schema}},
)
lead = json.loads(response.choices[0].message.content)
print(lead) # {'name': 'Dana Ruiz', 'email': 'dana@northwind.example', 'company': 'Northwind Traders', ...}Tested 2026-10-28: both versions were run against the live API with each model recommended at the time, and their answers checked.
Tips
- Only models listed with Structured outputs on their page guarantee the schema; we verify this on every model before listing it.
- Enums (a fixed list of allowed values) make classification-style fields reliable.
- Batch many small documents through concurrent requests instead of one huge prompt, so one bad document cannot spoil the rest.
All 26 models that fit this job
- gpt-oss-20b$0.000105
- Qwen3 30B A3B Instruct 2507$0.00012
- DeepSeek V4 Flash 0423$0.000147
- DeepSeek V4 Flash 0731$0.000147
- Ministral 3 14B 2512$0.00018
- gpt-oss-120b$0.00018
- GLM 5.3 Flash$0.000188
- Gemma 4 31B$0.00021
- Nemotron Nano 12B v2 VL$0.00024
- Qwen3 235B A22B Instruct 2507$0.00024
- Llama 4 Maverick$0.000318
- Nemotron 3.5 Super VL$0.000323
- DeepSeek V4.1 Flash$0.000405
- DeepSeek V4.1 Flash 1017$0.000405
- Beam 1.0 501B A23B$0.00048
- Nemotron 3 Nano Omni$0.00051
- DeepSeek V3.2$0.000615
- Nemotron 3 Ultra$0.00093
- MiMo-V2.5-Pro$0.00105
- Hermes 4 405B$0.0012
- DeepSeek V4 Pro 0813$0.001584
- GLM 5.1$0.00171
- GLM 5.3$0.00171
- DeepSeek V4 Pro 0423$0.001827
- Qwen3.8 Max (open weights, 2.4T A95B)$0.0024
- Kimi K3$0.0045