JSON Schema Output on Chinese LLM APIs
JSON schema output on Chinese LLM APIs: which response_format DeepSeek, Qwen, GLM, MiniMax and Kimi accept, the Kimi K3 gotcha, and Python that fails loudly.
By OceanToken Team

Editor's note: Structured output is where "OpenAI-compatible" stops meaning "identical". The request shape is the same for all five models here, but one of them refuses the most common form of JSON mode, and none of them will tell you with an error when a parameter is ignored. We would rather you find that out from a table than from a parsing exception at 2 a.m.
Short answer: For JSON schema output on Chinese LLM APIs, send response_format with type: json_schema to every model. DeepSeek V4.1 Flash, Qwen3.8 Max, GLM-5.3 and MiniMax M3 also accept json_object, but Kimi K3 does not: it takes a schema or nothing. Parse every answer, retry once, then fail loudly.
We use OceanToken for the examples because one key and one OpenAI-compatible base URL reach all five of these models from outside China, so the comparison is a change of the model string rather than five accounts and five SDKs. Every fact about parameters below comes from our docs and model pages, read November 28, 2026. We have not run your schemas through these models, so the last part of the article is a test plan you can run yourself. For prices, see the current rates on /deepseek-api, /qwen-api and /kimi-api.
01 · JSON schema output on Chinese LLM APIs: the support table
Here is what each model's parameter list says about response_format, along with the limits that matter when the JSON is long. The response_format column is copied from each model's docs entry; context and max output come from the model pages on our site. For DeepSeek V4.1 Flash the model page and the docs spec currently give different output limits, so see the model page for the current output limit and test the ceiling you plan to use.
| Model id | json_object | json_schema | Reasoning | Context | Max output per reply |
|---|---|---|---|---|---|
deepseek/deepseek-v4.1-flash |
Yes | Yes | Yes | 1.05M | See model page |
qwen/qwen3.8-max-0902 |
Yes | Yes | Yes | 984K | 131K |
z-ai/glm-5.3 |
Yes | Yes | Yes | 1.05M | 944K |
minimax/minimax-m3 |
Yes | Yes | Yes | 1.05M | 512K |
moonshotai/kimi-k3 |
No | Yes | Yes | 1.05M | 944K |
The table settles two design choices. First, json_schema is the only form all five list, which makes it the obvious default for code that has to work across them. Second, every one of these models reasons before it answers, and on all five the docs describe max_tokens as "the most tokens to write, reasoning included." That second point causes more broken JSON than any schema feature does, and section 06 covers it.
The two sources disagree on reasoning_effort. In the docs parameter lists only MiniMax M3 includes it (none, low, medium, high); the model pages list reasoning_effort for DeepSeek V4.1 Flash, Qwen3.8 Max, GLM-5.3 and Kimi K3 but not for MiniMax M3. Treat it as something to test per model before you send it, checking whether it is accepted or dropped, not a guarantee.
02 · Kimi K3 JSON schema: the one model that refuses json_object
Kimi K3 needs a schema: its docs entry lists only json_schema for response_format and states that plain json_object is not supported on this model. If your code was written against a model where "JSON mode" means {"type": "json_object"}, it will not behave the same on Kimi.
Why does this matter more than it sounds? Because of how unsupported parameters are handled. Our API reference says a parameter the chosen model does not support is dropped and the request runs without it, and the text-generation guide adds that a model which does not honour a schema drops response_format and answers in prose. Put together, a json_object request to Kimi is not guaranteed to fail with a clear error. The safer assumption is that it may come back as ordinary text, which your json.loads call then rejects, far from the place where the real mistake was made.
Never send json_object to Kimi. If you have a code path that does, map it to a schema, even a loose one. A schema with "type": "object" and no required properties still counts as a schema, and it keeps the request in the form Kimi's docs say it takes. Better still, write the real schema: you get validation for free and the model gets a clearer target.
03 · DeepSeek JSON output API: both modes, and which to use
The DeepSeek JSON output API on deepseek/deepseek-v4.1-flash accepts both json_object and json_schema, so either request is valid. We would still send json_schema.
The reason is what each mode promises. json_object, per our docs, "asks for any valid JSON without a schema." That guarantees braces and quotes, not field names. A model asked for {"invoice_total": ...} in the prompt can return {"total": ...} and still satisfy json_object. With json_schema you hand the model the exact keys, types and required fields, and you can validate the answer against the same schema on your side.
DeepSeek V4.1 Flash is also a reasoning model with a large output limit, which is useful for long extractions such as turning a contract into a list of clauses. The reasoning tokens still count toward max_tokens, so a long schema plus a low max_tokens can produce a cut-off answer. If you only need a short object, set max_tokens with headroom for both the thinking and the JSON, rather than tight to the size of the object you expect.
For setting up the client itself, our guide to the DeepSeek API with the OpenAI SDK walks through the base URL and key.
04 · GLM 5.3 response_format: what the docs list
GLM 5.3's response_format takes both json_object and json_schema, per its docs entry read November 28, 2026. Its context window is 1.05M tokens and its max output is listed as 944K per reply, the same ceiling as Kimi K3.
GLM-5.3 takes text input only, so structured output on this model is mostly extraction from long documents, codebases or logs, and agent steps that return a typed object. Those are the cases where the schema tends to grow: nested arrays of findings, each with a file path, line range and severity. Large schemas are exactly where a model that accepts the parameter may still produce output that does not match, so validate on your side even when the request succeeds.
GLM-5.3 lists default sampling values in its parameter table (temperature 1, top_p 0.95). For extraction tasks many teams lower temperature, but that is a tuning choice to test on your own data, not something the docs prescribe for JSON.
Our earlier piece on switching models behind one OpenAI-compatible API has a short paragraph on GLM, DeepSeek and Qwen response_format; this article is the five-model version of that paragraph.
05 · Qwen3.8 Max and MiniMax M3
Both accept json_object and json_schema. The differences that matter for JSON are output size and reasoning control.
qwen/qwen3.8-max-0902 has the smallest output limit of the five, 131K per reply. That is still far more than most JSON objects need, but it is the one to keep in mind if you plan to ask for very long arrays in a single call. Qwen also takes image and video input, which makes it a reasonable choice for "look at this screenshot and return the fields" tasks. For Qwen-specific schema details, see our Qwen structured JSON output guide and the Qwen3.8 base URL guide.
minimax/minimax-m3 has a docs parameter list that includes reasoning_effort, with none among the values. For a simple extraction where thinking adds latency without improving the result, reasoning_effort: "none" is the documented way to switch it off on this model. Whether it helps your schema is a test, not a given.

06 · Why valid requests still return broken JSON
There are three ways a JSON request can succeed at the HTTP level and still give your parser something it cannot use. Each has a different signal in the response.
The parameter was dropped. Our API reference is direct about this: a successful response is not evidence that every parameter took effect. It also names a response header, x-oceantoken-dropped-params, that names a parameter dropped on a given request even when the model supports it. A parameter the model does not support at all, or a schema it does not honour, may leave no trace in the header, so the real check is the content: does it parse and match your schema?
The answer was cut off. finish_reason is length when the answer reached max_tokens. On a reasoning model, the thinking can use most of that budget before any JSON is written, so the content may be empty or end mid-object. The docs say each model returns its reasoning in choices[0].message.reasoning_content and the answer in content, and that usage.completion_tokens_details.reasoning_tokens counts the tokens spent thinking. If reasoning_tokens is close to your max_tokens, raise the limit.
The model ignored the schema. Even when the parameter arrives, the model can return keys you did not ask for or miss a required one. This is what local validation is for.
| Symptom | Likely cause | What to check | Fix |
|---|---|---|---|
| Answer is prose, not JSON | response_format dropped or not honoured |
Does content parse? Also log x-oceantoken-dropped-params if present |
Send json_schema; on Kimi never send json_object |
| JSON ends mid-object | Hit max_tokens |
finish_reason == "length", reasoning_tokens |
Raise max_tokens, or lower reasoning where the model lists it |
Empty content, long reasoning_content |
Reasoning used the budget | reasoning_tokens |
Raise max_tokens |
| Valid JSON, wrong keys | Schema not applied or not followed | Validate against your schema | Retry once, then fail |
| Code fences around the JSON | Model wrapped the answer | First characters of content |
Strip fences before parsing |
07 · One Python function for all five models
This is the pattern we would ship: always send json_schema with strict, read the raw response so you can see the headers, check finish_reason, parse, validate, retry once, and then raise.

# pip install openai jsonschema
import json, os, re
from openai import OpenAI
from jsonschema import validate, ValidationError
client = OpenAI(base_url="https://api.oceantoken.ai/v1",
api_key=os.environ["OCEANTOKEN_API_KEY"])
SCHEMA = {
"type": "object",
"properties": {
"vendor": {"type": "string"},
"invoice_date": {"type": "string", "description": "YYYY-MM-DD"},
"total": {"type": "number"},
"line_items": {"type": "array", "items": {"type": "string"}},
},
"required": ["vendor", "invoice_date", "total", "line_items"],
"additionalProperties": False,
}
class StructuredOutputError(Exception):
pass
def _strip_fences(text):
m = re.match(r"^\s*```(?:json)?\s*(.*?)\s*```\s*quot;, text or "", re.S)
return m.group(1) if m else (text or "")
def extract(model, prompt, schema=SCHEMA, max_tokens=8000, attempts=2):
last_error = None
for _ in range(attempts):
raw = client.chat.completions.with_raw_response.create(
model=model,
messages=[{"role": "user", "content": prompt}],
# json_schema is the only form all five models list
response_format={"type": "json_schema",
"json_schema": {"name": "invoice", "schema": schema, "strict": True}},
max_tokens=max_tokens, # includes reasoning on these models
)
dropped = raw.headers.get("x-oceantoken-dropped-params")
resp = raw.parse()
choice = resp.choices[0]
if dropped:
last_error = f"dropped params: {dropped}"
if choice.finish_reason == "length":
last_error = "hit max_tokens before the JSON was complete"
max_tokens *= 2
continue
try:
data = json.loads(_strip_fences(choice.message.content))
validate(data, schema)
return data
except (json.JSONDecodeError, ValidationError) as e:
last_error = str(e)
raise StructuredOutputError(f"{model}: {last_error}")
for m in ["deepseek/deepseek-v4.1-flash", "qwen/qwen3.8-max-0902",
"z-ai/glm-5.3", "minimax/minimax-m3", "moonshotai/kimi-k3"]:
print(m, extract(m, "Acme Ltd invoice, 2026-11-02: 3 licences and 1 support plan, total 1250.00"))
A few choices in that code are deliberate. Doubling max_tokens on length is the cheapest retry for the most common failure on reasoning models. Retrying once on a parse or validation error, and then raising, keeps a bad schema from looping forever. Raising a named exception means the caller can decide whether to fall back to another model, queue the item for review, or show an error, which is better than quietly storing a half-filled record.
08 · The Kimi branch, if you keep a json_object path
If your codebase already uses json_object somewhere, for example a quick "return JSON" helper with no schema, add one guard rather than rewriting every caller:
SCHEMA_ONLY = {"moonshotai/kimi-k3"}
LOOSE = {"type": "object"}
def response_format_for(model, schema=None):
if schema is not None:
return {"type": "json_schema", "json_schema": {"name": "out", "schema": schema}}
if model in SCHEMA_ONLY:
# Kimi K3 docs: plain json_object is not supported; give a schema
return {"type": "json_schema", "json_schema": {"name": "out", "schema": LOOSE}}
return {"type": "json_object"}
Keep the set of schema-only models in config, not in code. Model behavior changes, and when another model joins that set you want a one-line change. We still recommend migrating callers to real schemas over time; the loose schema is a bridge, not a destination.
09 · Validation checklist before you ship
Run this list once per model you plan to use, not once for the whole set:
- The request sends
json_schema, neverjson_objectto Kimi K3. - Your code reads
finish_reasonand treatslengthas a failure, not a result. max_tokensleaves room for reasoning; you have looked atreasoning_tokenson a few real inputs.- Every answer is parsed and validated against the same schema you sent.
- Code fences are stripped before parsing.
x-oceantoken-dropped-paramsis logged during integration (it does not catch every ignored parameter).- Failures raise a named error with the model id, so you can see which model fails which schema.
How to test this on your workload
We have not run your schemas, so here is the test we would run before choosing a model:
- Pick three real inputs that represent easy, typical and hard cases for your extraction.
- Send each to all five models with the same
json_schemaandstrict: true, using the function in section 07. - Record per model: parse success, validation success,
finish_reason,reasoning_tokensand whetherx-oceantoken-dropped-paramsappeared. - Send
json_objectto Kimi K3 once on purpose, and record what comes back, so your team knows what that failure looks like. - Lower
max_tokenson the hard case until one model returnslength, so you know your headroom. - On MiniMax M3, compare
reasoning_effortnoneandlowon the same input, and check whether validation results change. - Try
reasoning_efforton each of the other four and checkreasoning_tokens, to see whether it was accepted or dropped. - Check DeepSeek V4.1 Flash's output limit on its model page, then send a request with the
max_tokensyou plan to use and confirm it is accepted. - Check the cost of each run in the
x-oceantoken-costresponse header and in Logs, rather than estimating it.
Our take: Treat json_schema as the only structured-output mode across Chinese models, because it is the only one all five list and the only one Kimi K3 accepts. Validate every answer locally, treat finish_reason: length as a failure, and give reasoning models generous max_tokens. That combination turns most silent failures into loud ones.
Running it on OceanToken
From our docs, as of November 28, 2026:
- One key for all five models. DeepSeek, Qwen, GLM, MiniMax and Kimi are called through the same OpenAI-compatible base URL,
https://api.oceantoken.ai/v1, so comparing them is a change ofmodelid. - Three request shapes on every text model. Chat Completions, Responses and Anthropic Messages, so the SDK you already use keeps working.
- Visible parameter handling. The
x-oceantoken-dropped-paramsheader names a parameter dropped on a request, and non-streamed responses carry their cost inx-oceantoken-cost. - Prepaid balance. You pay per request from your balance, and Logs in the console lists every call.
Price: see the current rate on /deepseek-api, /qwen-api, /glm-api, /kimi-api and /minimax-api. For GPT-specific schema rules, see our GPT structured outputs tutorial.
FAQ
Does Kimi K3 support JSON mode? It supports json_schema only. Its docs entry says plain json_object is not supported on this model, so give it a schema.
Which Chinese models support json_schema? All five covered here: DeepSeek V4.1 Flash, Qwen3.8 Max 0902, GLM-5.3, MiniMax M3 and Kimi K3, per their docs entries read November 28, 2026.
Why did my JSON request return plain text? A parameter a model does not support is dropped and the request still runs. Send json_schema, parse and validate the answer, and log the x-oceantoken-dropped-params header, which names a parameter dropped on that request.
Why is my JSON cut off halfway? On these reasoning models max_tokens includes reasoning. If finish_reason is length, raise max_tokens.
Does strict mode guarantee a valid object? Do not rely on it. Validate every answer against your schema on your side, whichever model you call.
Can I use the same code for all five? Yes, if it sends json_schema and validates the result. Only the model string changes.
Sources
- OceanToken docs: Text generation (checked 2026-11-28)
- OceanToken docs: API reference (checked 2026-11-28)
- OceanToken docs: Kimi K3 model spec (checked 2026-11-28)
- OceanToken docs: DeepSeek V4.1 Flash model spec (checked 2026-11-28)
- OceanToken docs: GLM-5.3 model spec (checked 2026-11-28)
- OceanToken docs: Qwen3.8 Max 0902 model spec (checked 2026-11-28)
- OceanToken docs: MiniMax M3 model spec (checked 2026-11-28)
Get your OceanToken API key
- Create an OceanToken account and an API key.
- Copy the snippet below, paste your key, and run it.
- Check the current rate on /deepseek-api.
curl https://api.oceantoken.ai/v1/chat/completions \
-H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek/deepseek-v4.1-flash", "messages": [{"role": "user", "content": "Acme Ltd, 2026-11-02, total 1250.00"}], "response_format": {"type": "json_schema", "json_schema": {"name": "invoice", "schema": {"type": "object", "properties": {"vendor": {"type": "string"}, "total": {"type": "number"}}, "required": ["vendor", "total"]}}}}'
More from the blog
HappyHorse 1.1 vs Wan 3.0 Prime by Job
HappyHorse 1.1 vs Wan 3.0 Prime on one video API: durations, aspect ratios, seed, sound, first and last frames and reference limits, and which job goes where.
AI Image Generator Text Rendering Compared
AI image generator text rendering compared across eight models: what each API takes, a five-step test for lettering, and when to add type after generation.
Voyage Code 4 vs Codestral Embed for Code
Voyage Code 4 vs Codestral Embed for code search and repository RAG: context windows, chunking, the parameters that reach each model, and a recall test to run.