All news
/1 min readAPI

JSON mode and structured outputs

Ask any model for valid JSON, or pin the exact shape with a JSON schema, using OpenAI's response_format parameter.

> response_format

response_format now works through boldrouter, in OpenAI's shape:

  • { "type": "json_object" } asks for any valid JSON object.
  • { "type": "json_schema", "json_schema": { ... } } also pins the shape of the result.
curl https://boldrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $BOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "messages": [{ "role": "user", "content": "Extract the name and age: Ada is 36." }],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "person",
        "schema": {
          "type": "object",
          "properties": { "name": { "type": "string" }, "age": { "type": "integer" } },
          "required": ["name", "age"]
        }
      }
    }
  }'

Provider support

JSON mode works almost everywhere. Schema support varies: OpenAI-compatible providers receive response_format as is, Gemini gets it translated to its own format, and a provider that can't honour a schema returns an error instead of silently ignoring it.

Details are in JSON mode and structured outputs.

JSON mode and structured outputs - boldrouter