> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured Outputs

> Return predictable JSON with json_object or json_schema output formats.

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

```bash theme={null}
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

```json theme={null}
{
  "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](./structured-outputs-schemas)
2. [Validation and Fallback Patterns](./structured-outputs-validation)
