Features
JSON Output Mode
Request parseable JSON from supported models and validate its structure in your application.
JSON mode is useful for classification, extraction, routing decisions, and configuration generation. It improves machine readability, but your application must still validate fields and business rules.
Request example
import json
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["APIQIK_API_KEY"],
base_url="https://api.apiqik.com/v1",
)
response = client.chat.completions.create(
model="qwen-turbo",
messages=[
{
"role": "system",
"content": (
"Return only a JSON object containing category, priority, and summary. "
"priority must be low, medium, or high."
),
},
{
"role": "user",
"content": "The production API has been timing out continuously for ten minutes.",
},
],
response_format={"type": "json_object"},
temperature=0,
)
result = json.loads(response.choices[0].message.content)
print(result)Response example
{
"category": "availability",
"priority": "high",
"summary": "The production API is continuously timing out"
}Usage guidelines
- Explicitly request JSON and describe fields, types, and allowed values in the prompt.
- Catch parsing failures and, if necessary, use a bounded format-repair retry.
- Validate fields with JSON Schema or a data model rather than only calling
json.loads. - Apply escaping, authorization, and content checks to JSON fields containing user input.
- If the model does not support JSON mode, use tool calling or a validated prompting approach.
Parseable does not mean factually correct. JSON mode addresses formatting; it does not guarantee the accuracy of extracted facts, numbers, or judgments.