JSON Mode with the AI API in India | unoblox
Get reliable structured output from unoblox's ₹-billed AI API using JSON mode — setup, model choices, and when to use it over prompting.
JSON mode asks a model to return a single, valid JSON object instead of free-form prose, which matters the moment your application needs to parse the reply rather than just display it. On unoblox this is a request parameter, not a separate product — the same rupee-billed endpoint and OpenAI-style request body you already use for chat can be told to constrain its output to JSON.
What JSON mode changes
Normally a model might answer "The total comes to about twelve thousand rupees" — readable, but painful to parse reliably at scale. With JSON mode and a clear instruction of the shape you want, the same request returns something like {"total_inr": 12000}, which your code can load directly with a standard JSON parser instead of writing fragile regular expressions against natural language.
Turning it on
curl https://api.unoblox.ai/v1/chat/completions \
-H "Authorization: Bearer ub-gw-your-key-here" \
-H "Content-Type: application/json" \
-d '{
"model":"qwen/qwen3-235b-a22b-instruct-2507",
"response_format":{"type":"json_object"},
"messages":[{"role":"system","content":"Return a JSON object with keys name and amount_inr."},{"role":"user","content":"Extract the payer and amount from: Paid to Ramesh Traders, amount 4,500."}]
}'
Always describe the exact keys you expect in your system prompt — response_format guarantees valid JSON syntax, but the shape of that JSON is still up to your instructions.
JSON mode versus plain prompting for structure
| Approach | Reliability | Best for |
|---|---|---|
| Ask for JSON in plain prompt only | Model sometimes adds prose around the object | Quick prototypes, low volume |
response_format: json_object | Output is guaranteed to parse as JSON | Pipelines, extraction, anything downstream code reads |
| JSON mode + a strict system-prompt schema | Most consistent field names and types | Production data pipelines at scale |
Model picks for structured extraction
Extraction-style tasks tend to be cheaper per call than long-form writing, so budget models are often the right default:
- High-volume extraction: DeepSeek V4 Flash (₹9.07 / ₹18.14 per 1M tokens) or the free Qwen3 1.7B for simple, well-defined fields.
- Mixed or messier documents: Qwen3.8-27B (₹16.32 / ₹48.96), which also accepts images if your source documents are scanned.
- Highest-accuracy structured extraction: GPT-5 (₹126 / ₹1008) or Claude Sonnet (₹201.6 / ₹1008).
- Any model not shown here — GPT-4.1 mini, Gemma 4 26B, and others — still supports JSON mode; see
/modelsfor current ₹ rates.
Frequently asked questions
Does JSON mode guarantee the field names I asked for? It guarantees valid JSON syntax, not the exact schema. Be explicit about key names and types in your system prompt, and validate the parsed object in your own code before trusting it downstream.
Is JSON mode billed any differently?
No — it uses the same per-token ₹ pricing as a normal chat completion. There's no separate charge for turning on response_format.
Can I use JSON mode with streaming at the same time? Yes, though you typically buffer the streamed chunks and parse the full object once the stream finishes, rather than parsing partial JSON mid-stream.
Which models support JSON mode on unoblox?
Support is broad across the catalog. Check the individual model page under /models if you need to confirm behaviour before committing a production pipeline to it.
What happens if my prompt asks for something the model can't extract? JSON mode only shapes the output format — if the requested field isn't present in the input, expect a null, empty value, or the model's best guess, so validate outputs rather than assuming completeness.
Get started in rupees → https://unoblox.ai/sign-in
More from unoblox
Developer Guides
AI API Rate Limits Explained (India Guide)
Developer Guides
How to Get an AI API Key in India
Developer Guides
Migrate from Azure OpenAI to unoblox (India)
Developer Guides
Streaming AI API Responses in India | unoblox
Developer Guides
Tool Calling with the AI API in India | unoblox
Developer Guides
AI API for Agencies in India | unoblox
Start building in rupees
Call every major model through one OpenAI-compatible endpoint, billed in ₹ on a GST invoice.