Chat with Structured Outputs
Last updated
POST /v1/chat/completions HTTP/1.1
Host: llm.onerouter.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 528
{
"model": "openai/gpt-5.4",
"messages": [
{
"role": "user",
"content": "What's the weather like in London?"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "weather",
"strict": true,
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or location name"
},
"temperature": {
"type": "number",
"description": "Temperature in Celsius"
},
"conditions": {
"type": "string",
"description": "Weather conditions description"
}
},
"required": [
"location",
"temperature",
"conditions"
],
"additionalProperties": false
}
}
}
}{
"id": "chatcmpl-DL28X0Shp6uFdggB0HWMDJDePQj1t",
"model": "openai/gpt-5.4",
"object": "chat.completion",
"created": 1773905473,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"conditions\":\"Cloudy\",\"location\":\"London\",\"temperature\":12}"
},
"finish_reason": "stop",
"logprobs": null
}
],
"request_id": "386e633a3c254d5a8940d73645b7bb90",
"usage": {
"prompt_tokens": 71,
"completion_tokens": 21,
"total_tokens": 92,
"prompt_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0,
"audio_tokens": 0,
"video_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"image_tokens": 0,
"audio_tokens": 0
}
}
}