Developers / Docs / JSON output
JSON output
Use response_format to ask for a JSON answer, optionally shaped by a JSON Schema. ARK instructs the model to answer in JSON and strips any Markdown fence around it.
API reference: Chat completions
Any JSON object
response = client.chat.completions.create(
model="arklabsai/Qwen3.6-35B-A3B",
messages=[
{"role": "system", "content": "Extract invoice data."},
{"role": "user", "content": "Invoice FV/2026/10/118 from Odra Logistics, 12 400 PLN net, due 30 October 2026."},
],
response_format={"type": "json_object"},
)
data = json.loads(response.choices[0].message.content)curl https://api.ark-labs.cloud/api/v1/chat/completions \
-H "Authorization: Bearer $ARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "arklabsai/Qwen3.6-35B-A3B",
"messages": [
{"role": "system", "content": "Extract invoice data."},
{"role": "user", "content": "Invoice FV/2026/10/118 from Odra Logistics, 12 400 PLN net, due 30 October 2026."}
],
"response_format": {"type": "json_object"}
}'JSON that follows a schema
Pass a schema with json_schema. name is required; description helps the model.
Python
response = client.chat.completions.create(
model="arklabsai/Qwen3.5-122B-A10B",
messages=[{"role": "user", "content": "Invoice FV/2026/10/118 from Odra Logistics, 12 400 PLN net, due 30 October 2026."}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "invoice",
"schema": {
"type": "object",
"properties": {
"number": {"type": "string"},
"vendor": {"type": "string"},
"net_amount": {"type": "number"},
"currency": {"type": "string"},
"due_date": {"type": "string", "format": "date"},
},
"required": ["number", "vendor", "net_amount", "currency", "due_date"],
},
},
},
)Validate what you receive
ARK guides the model towards JSON but does not constrain decoding, and strict: true is not enforced. Parse the answer, validate it against your schema, and retry on the rare failure. Keep max_tokens high enough that the object is not cut off (finish_reason: "length").
With the Anthropic API
On the Messages API, use output_config.format: {"type": "json_schema", "schema": {…}}. It behaves the same way.