Key takeaways

Structured output failures cause more production incidents than chat quality gaps. Treat JSON as a contract: schema → model mode → parse → validate → retry/failover. OpenAI-compatible endpoints vary on strict JSON and tool argument shapes—see /en/articles/china-llm-openai-compatible-sdk-2026 and agent guide.

Implementation pattern

Define JSON Schema or Zod/Pydantic models → ask for JSON only → enable vendor JSON mode when available → parse → validate → on failure, one repair prompt or switch vendor (/en/articles/china-llm-latency-failover-2026). Log raw text for debugging.

Vendor caveats

Do not assume GPT-identical strict mode. Test nested objects, enums, and empty arrays on DeepSeek, Qwen, GLM. Tool calling often needs separate tests from pure JSON chat (/en/articles/china-llm-agent-tool-calling-2026).

Next steps on Swift Horse

SDK /en/articles/china-llm-openai-compatible-sdk-2026 → agents /en/articles/china-llm-agent-tool-calling-2026 → pricing /en/articles/china-llm-api-pricing-2026 → access /en/articles/access-china-llm-api-overseas.

FAQ

Do Chinese LLMs support JSON mode?

Many expose JSON or schema-like controls—names differ. Verify on each vendor console and test nested schemas.

JSON mode vs tool calling?

JSON mode shapes assistant content; tools return function arguments. Pick based on whether you need side effects.

How to handle invalid JSON in production?

Validate, one repair retry, then failover model; never silently pass bad payloads downstream.

Is this official API documentation?

No—independent Swift Horse engineering guide. Defer to vendor docs for parameters.