Create an chat message
Bearer Auth (In: header)Authorization: Bearer <YOUR_API_KEY>Bearer <YOUR_API_KEY>. Format: Authorization: Bearer sk-xxxxxx.| Field | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | ✅ | - | The model identifier to use for this request, e.g. gemini-2.5-flash. |
messages | array | ✅ | - | An array of message objects representing the conversation history. Messages are processed in order. |
>messages.role | string | ✅ | - | The role of the message author. Valid values: system, user, assistant. |
>messages.content | string/array | ✅ | - | The content of the message. Can be a simple string or an array of content blocks for multimodal inputs. |
>>messages.content.type | string | ✅ | - | The type of content block. Supported: text, image_url. |
>>messages.content.text | string | ✅ | - | The text content. Required when type is text. |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
max_tokens | integer | - | - | The maximum number of tokens the model can generate in the response. |
temperature | float | - | 1.0 | Controls the randomness of the output. Lower values produce more focused responses, higher values produce more creative outputs. Range in 0.0 - 2.0. |
top_p | float | - | 1.0 | Nucleus sampling parameter. The model considers tokens with top_p cumulative probability mass. Range in 0.0 - 1.0. |
stream | boolean | - | false | If true, returns a stream of server-sent events (SSE) as the response is generated. |
stop | string/array | - | - | Up to 4 sequences where the API will stop generating further tokens. |
n | integer | - | 1 | How many chat completion choices to generate for each input message. |
presence_penalty | float | - | 0 | Penalizes new tokens based on whether they appear in the text so far. Range in -2.0 - 2.0. |
frequency_penalty | float | - | 0 | Penalizes new tokens based on their existing frequency in the text so far. Range in -2.0 - 2.0. |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
tools | array<object> | - | - | A list of tools the model may call. Use this to provide functions the model can generate JSON inputs for. |
tool_choice | string/object | - | auto | Controls which tool is called. none: no tool, auto: model decides, required: must call a tool. |
user | string | - | - | A unique identifier representing your end-user, which can help to monitor and detect abuse. |
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
type | string | - | - | Utility types, currently generally functions |
function | object | - | - | Function definition |
>function.name | string | - | - | The function name |
>function.description | string | - | - | Function usage description |
>function.parameters | object | - | - | Function parameter definition |
>>function.parameters.location | string | ✅ | - | City name |
>>function.parameters.unit | string | - | - | Can be celsius fahrenheit |