Structured output and JSON mode across models

JSON schema, JSON mode or a plain instruction: which is enforceable, which catalog ids accept response_format, and why a non-matching answer is retried free.

Checked 2026-11-22

·All posts·Models

Asking a model for JSON works three ways, a JSON schema, JSON mode, or a plain instruction in the prompt, and only the first two can be enforced; this page lists which ids on this catalog are verified to accept response_format, explains what the catalog's flags do and do not mean, and shows why an answer that does not match the schema is retried once here and the miss is never billed. Every request below goes to https://api.uplinkswitch.com/v1/chat/completions with the OpenAI SDK or curl; the same response_format field is accepted on every model route.

The three ways, and what each one guarantees

MethodHow you askWhat is guaranteedWhen it fails
JSON schemaresponse_format: {"type": "json_schema", "json_schema": {...}}Output is valid JSON and matches the schema's shapeA missing required key, a wrong type, prose around the object
JSON moderesponse_format: {"type": "json_object"}Output is valid JSONA code fence, a trailing sentence, truncated output
Instruction"Reply only with JSON" in the promptNothing; the model usually compliesAny of the above, with no signal that it happened

On this gateway, the first two carry a billing rule the third does not: with json_object or json_schema in the request, only a matching answer is charged. When a non-streamed answer misses, the gateway asks the model a second time at no cost to you, and a second miss goes unbilled as well. The guarantee shares the account's daily refund allowance with refusal refunds, and a streamed answer is billed as sent because the gateway cannot check what it has already forwarded. Put the schema in the request, not the prompt, and the parse failure never reaches your balance.

Which models accept response_format

The catalog at GET /v1/catalog carries a supported_parameters list per model: the parameters that have been verified against that id. Two entries matter here. response_format is the field itself. structured_outputs is listed separately for ids where schema-following has been checked as well; the catalog does not define the two further, so treat a row with both as verified for a schema and a row with response_format alone as verified for the field, with json_schema something to test before you rely on it.

The ids below are the catalog rows whose supported_parameters includes response_format or structured_outputs and whose availability is ok on the reading date. The catalog's tuned variants of the same models, whose ids carry a suffix, share the flags and are left out of the table; the live catalog is the authority at build time.

Model idDeveloperresponse_formatstructured_outputsToolsRoutes
deepseek-r1DeepSeekyes-yeschat completions, messages, responses, Gemini
gemma-3n-e2b-itGoogleyes-yeschat completions, messages, responses, Gemini
gemma-4-12b-itGoogleyesyesyeschat completions, messages, responses, Gemini
gemma-4-26b-a4b-itGoogleyes-yeschat completions, messages, responses, Gemini
gemma-4-31b-itGoogleyes-yeschat completions, messages, responses, Gemini
llama-3.3-70b-instructMetayes-yeschat completions, messages, responses, Gemini
muse-glimmer-30bMetayes-yeschat completions, messages, responses, Gemini
muse-spark-openMetayes-yeschat completions, messages, responses, Gemini
minimax-m2.5MiniMaxyesyesyeschat completions, messages, responses, Gemini
minimax-m2.7MiniMaxyesyesyeschat completions, messages, responses, Gemini
devstral-2512Mistralyes-yeschat completions, messages, responses, Gemini
kimi-k2-0905Moonshot AIyes-yeschat completions, messages, responses, Gemini
kimi-k2-instructMoonshot AIyesyesyeschat completions, messages, responses, Gemini
kimi-k2-thinkingMoonshot AIyes-yeschat completions, messages, responses, Gemini
kimi-latestMoonshot AIyesyesyeschat completions, messages, responses, Gemini
nemotron-3.5-super-vlNVIDIAyesyesyeschat completions, messages, responses, Gemini
gpt-5.3-codexOpenAIyes-yeschat completions, messages, responses, Gemini
qwen3.5-122b-a10bQwenyes-yeschat completions, messages, responses, Gemini
qwen3.5-35b-a3bQwenyes-yeschat completions, messages, responses, Gemini
step-5-previewStepFunyesyesyeschat completions, messages, responses, Gemini
hy4Tencentyesyesyeschat completions, messages, responses, Gemini
hy4-previewTencentyesyesyeschat completions, messages, responses, Gemini

Source: catalog.json supported_parameters, endpoints and availability per id. Prices for each row are on the price index, ours beside the developer's list.

An empty list means unverified, not refused

Most rows in the catalog have an empty supported_parameters list, and that includes heavily used ids: claude-sonnet-5-5, gemini-4-argon and gpt-6.1-sol among them. Empty means nobody has recorded a verification for that id yet; it does not mean the parameter is rejected. The gateway passes response_format through to every model route, and the billing guarantee applies to any request that asks for JSON, listed or not. So the practical reading is: a listed id is a safe default for a JSON pipeline, and an unlisted id is one test request away from being your own verified row.

A request with a schema

The OpenAI SDK sends the field unchanged. Keep stream off when you want the free retry.

python
from openai import OpenAI

client = OpenAI(base_url="https://api.uplinkswitch.com/v1", api_key=KEY)

schema = {
    "name": "ticket",
    "strict": True,
    "schema": {
        "type": "object",
        "properties": {
            "category": {"type": "string", "enum": ["billing", "bug", "other"]},
            "urgent": {"type": "boolean"},
            "summary": {"type": "string"},
        },
        "required": ["category", "urgent", "summary"],
        "additionalProperties": False,
    },
}

r = client.chat.completions.create(
    model="kimi-latest",
    messages=[{"role": "user", "content": "Customer says: charged twice, please fix today."}],
    response_format={"type": "json_schema", "json_schema": schema},
)
body = r.to_dict()
print(body["choices"][0]["message"]["content"])   # the JSON object
print(body["model"], body["usage"]["cost"])        # who answered, what it cost

The same with curl, in JSON mode rather than a schema:

bash
curl https://api.uplinkswitch.com/v1/chat/completions \
  -H "Authorization: Bearer $UPLINKSWITCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemma-4-12b-it",
    "messages": [{"role": "user", "content": "Return the three primary colours as a JSON array under the key colours."}],
    "response_format": {"type": "json_object"}
  }'

Two habits make either shape reliable across developers. Name the keys you want in the prompt as well as in the schema. And keep max_tokens generous: an answer cut off by the request's own output limit is not valid JSON and is not treated as a model miss, so it is not refunded.

What a miss looks like on your side

You will usually not see one. The gateway checks the non-streamed answer against the JSON or schema the request asked for, and on a miss it asks the model again and returns the retry. Afterwards the evidence is in the record: GET /v1/requests/{request_id} shows the request's refund field, and the signed receipt at GET /v1/requests/{request_id}/receipt carries refund: "invalid_output" when an answer was not billed, verifiable at /statements/verify. If both attempts miss, the body you receive is the second answer and the charge is nothing; parse defensively and treat that as a signal to change model or schema.

With model: "auto", a request carrying a json_schema answer is classified to the balanced tier rather than the fast one, because schema-following is one of the signals the auto router uses; the body's model field names the id it chose.

Tool calls as a fourth way

If what you want is a function's arguments rather than a document, send tools instead. Tool definitions travel in OpenAI's tools shape and the calls return as tool events, arguments included, streamed piece by piece; every id in the table carries the flag (the Tools column). A tool call's arguments are JSON by construction; the catalog's tools flag is the one to check for that path, and the SDK guide shows the loop.

Questions and answers

The catalog rows whose supported_parameters lists structured_outputs beside response_format are verified for schema-following: on the reading date gemma-4-12b-it, minimax-m2.5, minimax-m2.7, kimi-k2-instruct, kimi-latest, nemotron-3.5-super-vl, step-5-preview, hy4 and hy4-preview, among others. Rows with response_format alone are verified for the field; an empty list means untested, not refused.

On a non-streamed request the gateway asks the model again, you receive that second answer, and the first one costs nothing. If that misses too, you receive it unbilled, and the request's record and signed receipt carry refund: "invalid_output". A streamed answer is billed as sent, and an answer cut off by your own max_tokens is not refunded.

No. response_format adds no fee; the request bills at the model's ordinary input and output rates, which the response body reports as usage.cost. The only cost effect runs the other way: a non-matching answer on a non-streamed request is retried once at no charge, so a JSON request can cost less than a prompt-only one that you would retry yourself.
Join on Telegram
Help