Structured Output (JSON Mode)
- Endpoint:
POST https://api.olddog.shop/v1/chat/completions - Purpose: Force strictly valid JSON output for reliable parsing and storage (aligned with OpenAI JSON mode).
Tip: When using JSON mode, explicitly instruct the model in
systemorusermessages to “output JSON only, no extra text”.
Request parameters (common set)
| Name | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID. |
| messages | array | Yes | Chat messages. |
| response_format | object | No | Structured output format, e.g. { "type": "json_object" }. |
| temperature | number | No | Recommended low (e.g. 0) for stability. |
cURL example (JSON only)
bash
curl --request POST "https://api.olddog.shop/v1/chat/completions" \
--header "Authorization: Bearer $OLD_DOG_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "gpt-4o-mini",
"response_format": { "type": "json_object" },
"messages": [
{
"role": "system",
"content": "你是数据提取器。只输出 JSON,不要输出任何解释性文字。"
},
{
"role": "user",
"content": "从这段话里提取姓名和手机号:张三的电话是 13800138000。"
}
],
"temperature": 0
}'