JSON Mode
This guide explains how to use Token Market JSON mode so text models return output in the specified JSON format.
What Is JSON Mode?
JSON Mode uses response_format={"type":"json_object"} to ask the model to return JSON. It is not a global switch that works for every model and channel.
Important: The current Model Market shows model types, input/output modalities, context, pricing, and channel information, but it has no dedicated JSON Mode support field. Do not treat a provider list, model tag, or text-model type as a support guarantee; validate the response with the actual model ID before using it in production.
How to Use JSON Mode
Basic Usage
Add the response_format parameter to the Chat Completions API request:
curl -X POST https://api.tokensmarket.ai/v1/chat/completions \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.1",
"messages": [
{
"role": "system",
"content": "You are a professional JSON output assistant. Respond strictly in JSON format."
},
{
"role": "user",
"content": "List two colors and return them as {\"colors\":[\"color1\",\"color2\"]}"
}
],
"response_format": {"type": "json_object"}
}'
Select and Verify from Model Market
Current text models visible in Model Market include glm-5.1, deepseek-v4-flash, claude-haiku-4-5-20251001, gpt-5.4-mini, and claude-sonnet-5; models, channels, prices, and capabilities can change. For JSON Mode:
- In Model Market, prioritize text-generation models, then copy the real model ID shown on the current page; JSON Mode applies to text generation rather than image-only models.
- Send a request with
response_format: {"type":"json_object"}using that model ID; do not use a provider name or a stale static list. - Parse the response as JSON and validate it against your business schema; do not infer that the content matches your schema from the model name, tag, or request success alone.
- If the current model or channel rejects the parameter, handle the error or fall back to a normal text request with an explicit JSON instruction; otherwise switch to another text model in Model Market and validate again.
Model Market does not maintain a fixed JSON Mode support list. Do not hard-code a permanent provider or model support conclusion in the client.
