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

# 结构化输出

> 生成符合指定 JSON Schema 的响应

EzTokens 支持结构化输出，确保模型返回符合指定格式的有效 JSON。

## JSON 模式

设置 `response_format` 参数为 `{ "type": "json_object" }` 即可启用 JSON 模式。

```bash theme={null}
curl https://api.eztokens.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $EZTOKENS_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "输出一个包含 name 和 age 的 JSON 对象"}
    ],
    "response_format": { "type": "json_object" }
  }'
```
