Gemini 2.5 Pro
Google Gemini 2.5 Pro chat completion model. Supports text, images, video, audio, and document inputs with built-in reasoning (thinking), function calling, Google Search grounding, and structured JSON output.
Model
| Model Name | Context Window | Reasoning |
|---|---|---|
gemini-2.5-pro | 1M tokens | Yes (thinking enabled by default) |
Pricing
Per-token billing:
| Type | Credits / 1M tokens | Price / 1M tokens |
|---|---|---|
| Input | 57 credits | $0.285 |
| Output | 450 credits | $2.25 |
Create Chat Completion
curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
]
}'
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be gemini-2.5-pro |
messages | array | Yes | Conversation messages, see Messages |
stream | boolean | No | Enable streaming (default: true) |
tools | array | No | Function definitions for tool calling |
include_thoughts | boolean | No | Include reasoning thoughts (default: true) |
reasoning_effort | string | No | low or high (default: high) |
response_format | object | No | JSON Schema for structured output |
Note:
toolsandresponse_formatare mutually exclusive. Google Search and function calling are also mutually exclusive.
Messages
Each message has a role and content:
| Role | Description |
|---|---|
system | System instructions |
developer | Developer instructions |
user | User input (text, images, etc.) |
assistant | Model response |
tool | Tool call result |
Text Message
{
"role": "user",
"content": "What is the meaning of life?"
}
Image Message
{
"role": "user",
"content": [
{ "type": "text", "text": "What's in this image?" },
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }
]
}
Images, videos, audio, and documents all use the same
image_urlformat.
Response (Non-Streaming)
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "gemini-2.5-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum bits (qubits)..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 86,
"total_tokens": 98
}
}
Response (Streaming)
When stream: true, the response is a stream of server-sent events (SSE):
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"role":"assistant","content":"Quantum"},"index":0}]}
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":" computing"},"index":0}]}
data: {"id":"chatcmpl-abc123","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":86,"total_tokens":98}}
data: [DONE]
Examples
Multimodal (Image Input)
curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe this image in detail" },
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }
]
}
]
}'
Function Calling
curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{ "role": "user", "content": "What is the weather in Tokyo?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string", "description": "City name" }
},
"required": ["location"]
}
}
}
]
}'
Structured Output (JSON Schema)
curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{ "role": "user", "content": "List 3 famous scientists" }
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "scientists",
"schema": {
"type": "object",
"properties": {
"scientists": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"field": { "type": "string" }
}
}
}
}
}
}
}
}'
Low Reasoning Effort
curl -X POST https://api.aivideoapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{ "role": "user", "content": "What is 2+2?" }
],
"reasoning_effort": "low"
}'
Error Codes
When a request fails, the API returns a JSON error response:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
Error Reference
| HTTP Status | Code | Type | Description |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | Missing or invalid parameters |
| 401 | invalid_api_key | authentication_error | API key is invalid, disabled, or deleted |
| 402 | insufficient_credits | billing_error | Credit balance too low, please top up |
| 403 | ip_not_allowed | permission_error | Request IP not in the key's allowlist |
| 404 | model_not_found | invalid_request_error | Model does not exist or is inactive |
| 404 | task_not_found | invalid_request_error | Task ID does not exist |
| 429 | rate_limit_exceeded | rate_limit_error | Too many requests, please slow down |
| 429 | spend_limit_exceeded | billing_error | Key spend limit reached (hourly/daily/total) |
| 500 | internal_error | api_error | Unexpected server error |
| 503 | upstream_error | upstream_error | Upstream AI provider returned an error |
Common Scenarios
invalid_request (400)
Returned when required fields are missing or invalid.
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
Your balance is too low. Check your balance with GET /v1/credits and top up in Dashboard > Billing.
invalid_api_key (401)
Possible causes:
- The key does not start with
sk- - The key has been disabled or deleted
- The user account has been banned
upstream_error (503)
The upstream AI provider returned an error. This may happen when:
- The input contains sensitive or prohibited content
- The provider is temporarily unavailable
- The request parameters are not supported by the provider
Credits are automatically refunded when a task fails due to upstream errors.