POST /v1/chat/completions
Method: POSTEndpoint: /v1/chat/completions
This section contains endpoint-specific behavior, parameters, or usage notes for this API. googleSearch codeExecution urlContext
Request Parameters
Header Parameters
text
Content-Type
string
Required
Example:
application/json
Accept
string
Required
Example:
application/json
Authorization
string
Optional
Default Value:
Bearer {{YOUR_API_KEY}}Body Parameters application/json
text
model
string
Required
messages
array
[object]
Required
role
string
Optional
content
string
Optional
tools
array
[object]
Required
type
string
Optional
function
object
Optional
Example
{
"model"
:
"gemini-3.1-flash-lite-preview"
,
"messages"
:
[
{
"role"
:
"user"
,
"content"
:
// provider-specific example normalized for English documentation
}
]
,
"tools"
:
[
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"googleSearch"
}
}
]
}Example Request
Shell
bash
curl --location --request POST '/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gemini-3.1-flash-lite-preview",
"messages": [
{
"role": "user",
// provider-specific example normalized for English documentation
}
],
"tools": [
{
"type": "function",
"function": {
"name": "googleSearch"
}
}
]
}'Response
🟢 200 OK
Content Type: application/json
Response Schema
text
id
string
Required
object
string
Required
created
integer
Required
choices
array
[object]
Required
index
integer
Optional
message
object
Optional
finish_reason
string
Optional
usage
object
Required
prompt_tokens
integer
Required
completion_tokens
integer
Required
total_tokens
integer
RequiredExample
json
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}