Skip to main content
Last edited: 23 Nov 2026 (Asia/Hong Kong)
This feature is in preview. It is not a fully supported product feature, and you should not use it as a guaranteed API. NexLLM does not yet guarantee that a strict schema is fully enforced on every route. Until the platform checks the result and fails clearly when the output does not match your schema, always validate the returned JSON in your application. An HTTP 200 response is not proof that the output matches your schema.
You can request JSON that follows a schema on the Chat Completions API by sending the OpenAI-compatible response_format parameter, with type set to json_schema and strict set to true. This page covers non-streaming requests only. Streaming was not tested. Authenticate with a Bearer token, the same way you authenticate other NexLLM API calls. See Authentication.

Endpoint

Request

Use the usual Chat Completions fields (model, messages, and optionally max_tokens and temperature), plus:
object
Set type to json_schema. Inside json_schema, provide a name, set strict to true, and include your JSON Schema in schema.

Code examples

Routes tested on 23 November 2026

These results are from non-streaming production tests on official text routes. They are a snapshot for that date, not a guarantee for every model on a channel. The following routes returned valid JSON that matched a simple weather schema:
  • nexllm/gpt-6-luna
  • aws-mantle/gpt-6-luna
  • runware/deepseek-v4-flash-0731
  • novita/qwen3.8-flash
  • aliyun/qwen3.7-flash
These routes also returned valid JSON on a simple schema, but further tests found important limits, so they should not be treated as strictly enforced:
  • runware/claude-haiku-5-5
  • runware/gemini-3.5-flash-lite

Known limits

Results can vary by route. Some official text routes accepted response_format but did not return usable JSON on the cheapest route tested:
  • aws-runtime/gpt-oss-20b returned reasoning text instead of JSON
  • geodd/glm-5.3-flash returned HTTP 200 with empty content
Other routes on those channels were not fully tested. A successful HTTP 200 can still contain output that does not fully match a strict schema. In testing:
  • A Gemini route returned a required field with the wrong constant value and still returned HTTP 200
  • On a conflicting or strict schema, a Claude route returned HTTP 200 with empty content and still billed completion tokens
  • An invalid or unsatisfiable schema may return a generic server error, such as a message that the channel is unavailable, rather than a clear schema-validation error
  • On some routes, max_tokens may not cap reasoning tokens. In testing, aliyun/qwen3.7-flash returned valid JSON but billed a large number of reasoning tokens
These limits are not only the model provider’s issue. NexLLM does not yet guarantee strict enforcement. Until the platform checks the result and fails clearly when the output does not match the schema, you should validate the JSON yourself. An HTTP 200 is not proof that the output matches the schema.

What to do in your application

Parse the assistant message as JSON and validate it against your schema before you use it. If you need a guaranteed shape, do not rely on this preview alone.