Skip to main content
Structured outputs let you enforce machine-readable output instead of free-form text.

Endpoint support

Use structured outputs on:
  • /v1/chat/completions with response_format
  • /v1/responses with text.format
  • /v1/messages can still return JSON text, but does not use the same response_format contract

Request

curl https://api.phaseo.app/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "messages": [
      { "role": "user", "content": "Return a JSON object with city and weather for London." }
    ],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "weather_schema",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "city": { "type": "string" },
            "weather": { "type": "string" }
          },
          "required": ["city", "weather"],
          "additionalProperties": false
        }
      }
    }
  }'

Response

{
  "id": "chatcmpl_...",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "{\"city\":\"London\",\"weather\":\"Cloudy\"}"
      }
    }
  ]
}

Contract notes

  • response_format.type should be text, json_object, or json_schema.
  • For json_schema, include a schema object (response_format.json_schema.schema on chat-style payloads, or text.format.schema on responses-style payloads).
  • Validate JSON on your server before downstream use.

Next guides

  1. Structured Output Schemas
  2. Validation and Fallback Patterns
Last modified on February 18, 2026