Create A Chat Completion
Header parameters
AuthorizationstringRequiredExample:
sk-Yf4DNBody
modelstringRequired
parallel_tool_callsbooleanOptional
temperaturenumberOptional
top_pnumberOptional
frequency_penaltynumberOptional
presence_penaltynumberOptional
max_completion_tokensintegerOptional
max_tokensintegerOptional
seedintegerOptional
stopstring[]Optional
logprobsbooleanOptional
top_logprobsintegerOptional
streambooleanOptionalDefault:
falseResponses
200Success
application/json
costnumberRequired
createdintegerRequired
idstringRequired
modelstringRequired
objectstringRequired
request_idstringRequired
post/v1/chat/completions
POST /v1/chat/completions HTTP/1.1
Host: llm.onerouter.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 4143
{
"model": "google/gemini-3.1-pro-preview",
"messages": [
{
"role": "system",
"content": "You are a highly capable AI assistant with access to tools. Respond concisely and accurately."
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please analyze this image and tell me what you see, then search the web for related information.",
"cache_control": {
"type": "ephemeral"
}
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png",
"detail": "high"
}
}
]
},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "web_search",
"arguments": "{\"query\": \"PNG transparency image format history\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "[{\"title\": \"PNG format overview\", \"url\": \"https://www.w3.org/TR/PNG/\", \"snippet\": \"PNG is a lossless image format supporting transparency.\"}]"
},
{
"role": "assistant",
"content": "Based on the image and search results, PNG (Portable Network Graphics) is a lossless format that supports alpha-channel transparency."
},
{
"role": "user",
"content": "Great! Now use the get_weather tool to check the weather in San Francisco."
}
],
"provider": {
"order": [
"openai",
"azure",
"amazon-bedrock",
"google-vertex"
],
"allow_fallbacks": true,
"require_parameters": true,
"data_collection": "allow",
"zdr": false,
"enforce_distillable_text": false,
"only": [
"openai",
"azure",
"amazon-bedrock",
"google-vertex"
],
"quantizations": [
"fp16",
"fp8",
"int8",
"int4"
],
"sort": "latency",
"preferred_min_throughput": {
"p50": 100,
"p75": 80,
"p90": 60,
"p99": 40
},
"preferred_max_latency": {
"p50": 2,
"p75": 3.5,
"p90": 5,
"p99": 10
}
},
"tools": [
{
"type": "function",
"function": {
"name": "web_search",
"description": "Search the web for real-time information on any topic.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query string"
},
"max_results": {
"type": "integer",
"description": "Maximum number of results to return",
"default": 5
}
},
"required": [
"query"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather information for a specific location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name or coordinates, e.g. 'San Francisco, CA' or '37.7749,-122.4194'"
},
"units": {
"type": "string",
"enum": [
"metric",
"imperial",
"standard"
],
"description": "Unit system for temperature and wind speed",
"default": "metric"
},
"include_forecast": {
"type": "boolean",
"description": "Whether to include a 7-day forecast",
"default": false
}
},
"required": [
"location"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "calculator",
"description": "Perform arithmetic and mathematical calculations.",
"parameters": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "A valid mathematical expression, e.g. '(2 + 3) * 4 / 2'"
}
},
"required": [
"expression"
],
"additionalProperties": false
}
}
}
],
"tool_choice": {
"type": "function",
"function": {
"name": "get_weather"
}
},
"parallel_tool_calls": true,
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "structured_response",
"strict": true,
"schema": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "A concise summary of the answer"
},
"details": {
"type": "array",
"items": {
"type": "string"
},
"description": "A list of detailed points"
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Confidence score between 0 and 1"
},
"sources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"title",
"url"
]
}
}
},
"required": [
"summary",
"details",
"confidence"
],
"additionalProperties": false
}
}
},
"reasoning": {
"effort": "none",
"max_tokens": 1024
},
"temperature": 0.7,
"top_p": 0.9,
"frequency_penalty": 0.3,
"presence_penalty": 0.2,
"max_completion_tokens": 4096,
"max_tokens": 4096,
"seed": 42,
"stop": [
"\n\nHuman:",
"\n\nUser:",
"###END###",
"<|end|>"
],
"logprobs": true,
"top_logprobs": 5,
"logit_bias": {
"198": -50,
"1234": 10,
"5678": 15,
"50256": -100
},
"stream": false,
"stream_options": {
"include_usage": true
},
"usage": {
"include": true
}
}200Success
{
"choices": [
{
"finish_reason": "tool_calls",
"index": 0,
"logprobs": null,
"message": {
"content": "",
"role": "assistant",
"thought_signature": "CucHAY89a19WiiCxol8cDyGplJGbGQYCPxurh5AclB7PqCd9tRgOzdz8UuqoKGMy39nO8uIrLAagVitxez6ApBJi4SeivMvvo6sQLUz+t/VsVR1egmK4r4mrACocsMmqp2TUoQdQTZMP4iAt/fz6MmyC2skjzY50TkXgFlUNpOmToXPA5nbWtb/4lWyhS1YWm9j2U3O3bdQDJ7VN7Xsov5CDeypC4bum9TCrm3U1ILaRLo/SZZWZnN8jTqzr2DDyRtV+Haps4QQYF8LcEfECWGCNp2zTBzET8vnfDYqqefAAYKylgZvYQR0wX3DB2+ZmrR3e012WzkxdLkHQ7icIIP+j6PjRIDcTNnmGciSXO31rulpN7uiUEPF0wYJ2HeJdFjRdy02/MAZn12EN54M4bY5dY1TD6EEXO5lOiY65JBjb8MmC4BUl0bCTTuvawyrNWDyi7XcfwczuZ26t7hqTtAx+lVlUxAJAXCussNbJ1nsSG4s/ftypdUvtaqcbFTt4Ar1plGQIJcWsrzyGG3KYSu4yKkkyH6HiuIlcFATe62j4KhrLiSNxa02JGY1d24TInLj40JESJsgEWJ64B5xaTvxNVbAw8SZLK/h22vmNPANU8NJE1xZix/+OJCiveos0qlF5OAcNyy9SWnyT1QY89oK73jByZwvMhVGelcAeB1YuQQSYRfBJ8HckTos8Y51Vbqjmj5pgN2bZtnCGVZmVf+/jEwJF13xyVi1ThTeeXO9DWd1Met2bapK+tXoBDcDrRo/Ps8pOB+sjCh0FSqGf+HMAuQwZSRS5PjtpXEbiir1j7+GEBJcQi4C/Krpl7mxNOh1n7Nu1YLKpqkt+QKtFQER2ouzQtP9aM8sP9s+UAMRG8v3g0wImZnZxyzhtuWRvpIcwyauZTbk/KwMXbYMbJNuHyIMvxGVs5nVlhPKYaTVRMoUvLZrtz29HaTXFl9H/Nvs2ExmJWeg3mH0IjdU8yeqigtT6HY7+iXxVZeyHYkfFE7i1eHmv8KUmdp8Kp7yUCO0UdQyp5OYXvoD7/z72J4LxvYfFQrw5HAY+SjU0enZwy+89lkoyxNhW2JT77zbAajJU5qDauY1TkOMLbznDlJUh2WrPS8dLEtGebDaMU327L2VFO3OTE8bmk5TI0SXKMgyigMUfXw9R0Xsp9WYz/PbNFvai8C5Z2Lywxpbnmi2/jmvAPEmzphBpXS5SRYKE1iynMD+X24P7qauH23nc4PoymkasLO90mI/TU7ywToiUdAun1mJXgvEIgdYfqZLABHqlaOp8dmMR52yyI4W+P/MQYyi4sn8hdPJZot9+cSf1sBpZwmO6VvFR",
"tool_calls": [
{
"function": {
"arguments": "{\"location\":\"San Francisco, CA\"}",
"name": "get_weather"
},
"id": "call_27fd260305044be1bc2816527d88ae7d",
"index": 0,
"thought_signature": "CucHAY89a19WiiCxol8cDyGplJGbGQYCPxurh5AclB7PqCd9tRgOzdz8UuqoKGMy39nO8uIrLAagVitxez6ApBJi4SeivMvvo6sQLUz+t/VsVR1egmK4r4mrACocsMmqp2TUoQdQTZMP4iAt/fz6MmyC2skjzY50TkXgFlUNpOmToXPA5nbWtb/4lWyhS1YWm9j2U3O3bdQDJ7VN7Xsov5CDeypC4bum9TCrm3U1ILaRLo/SZZWZnN8jTqzr2DDyRtV+Haps4QQYF8LcEfECWGCNp2zTBzET8vnfDYqqefAAYKylgZvYQR0wX3DB2+ZmrR3e012WzkxdLkHQ7icIIP+j6PjRIDcTNnmGciSXO31rulpN7uiUEPF0wYJ2HeJdFjRdy02/MAZn12EN54M4bY5dY1TD6EEXO5lOiY65JBjb8MmC4BUl0bCTTuvawyrNWDyi7XcfwczuZ26t7hqTtAx+lVlUxAJAXCussNbJ1nsSG4s/ftypdUvtaqcbFTt4Ar1plGQIJcWsrzyGG3KYSu4yKkkyH6HiuIlcFATe62j4KhrLiSNxa02JGY1d24TInLj40JESJsgEWJ64B5xaTvxNVbAw8SZLK/h22vmNPANU8NJE1xZix/+OJCiveos0qlF5OAcNyy9SWnyT1QY89oK73jByZwvMhVGelcAeB1YuQQSYRfBJ8HckTos8Y51Vbqjmj5pgN2bZtnCGVZmVf+/jEwJF13xyVi1ThTeeXO9DWd1Met2bapK+tXoBDcDrRo/Ps8pOB+sjCh0FSqGf+HMAuQwZSRS5PjtpXEbiir1j7+GEBJcQi4C/Krpl7mxNOh1n7Nu1YLKpqkt+QKtFQER2ouzQtP9aM8sP9s+UAMRG8v3g0wImZnZxyzhtuWRvpIcwyauZTbk/KwMXbYMbJNuHyIMvxGVs5nVlhPKYaTVRMoUvLZrtz29HaTXFl9H/Nvs2ExmJWeg3mH0IjdU8yeqigtT6HY7+iXxVZeyHYkfFE7i1eHmv8KUmdp8Kp7yUCO0UdQyp5OYXvoD7/z72J4LxvYfFQrw5HAY+SjU0enZwy+89lkoyxNhW2JT77zbAajJU5qDauY1TkOMLbznDlJUh2WrPS8dLEtGebDaMU327L2VFO3OTE8bmk5TI0SXKMgyigMUfXw9R0Xsp9WYz/PbNFvai8C5Z2Lywxpbnmi2/jmvAPEmzphBpXS5SRYKE1iynMD+X24P7qauH23nc4PoymkasLO90mI/TU7ywToiUdAun1mJXgvEIgdYfqZLABHqlaOp8dmMR52yyI4W+P/MQYyi4sn8hdPJZot9+cSf1sBpZwmO6VvFR",
"type": "function"
}
]
}
}
],
"cost": 0.005862,
"cost_details": {
"audio_cost": 0,
"byok_cost": 0,
"completion_cost": 0.003132,
"discount_rate": 1,
"image_cost": 0,
"is_byok": false,
"native_web_search_cost": 0,
"plugin_web_search_cost": 0,
"prompt_cache_read_cost": 0,
"prompt_cache_write_1_h": 0,
"prompt_cache_write_5_min": 0,
"prompt_cache_write_cost": 0,
"prompt_cost": 0.00273,
"reasoning_cost": 0,
"tools_cost": 0,
"video_cost": 0
},
"created": 1773839047,
"id": "chatcmpl-20260318130400477330345rgzpjPsg",
"model": "gemini-3.1-pro-preview",
"object": "chat.completion",
"request_id": "f722c91d744a494c8aec97355b4351ab",
"usage": {
"completion_tokens": 261,
"completion_tokens_details": {
"audio_tokens": 0,
"image_tokens": 0,
"reasoning_tokens": 249
},
"prompt_tokens": 1365,
"prompt_tokens_details": {
"audio_tokens": 0,
"cache_write_tokens": 0,
"cached_tokens": 0,
"video_tokens": 0
},
"total_tokens": 1626
}
}Last updated