Gemini 3.1 Pro
Google Gemini 3.1 Pro — multimodal model exposed via the OpenAI-compatible /v1/chat/completions endpoint. Supports text, image, video, audio, and PDF input with Google Search grounding and streaming.
Model
| Model Name | Context Window | Reasoning |
|---|---|---|
gemini-3.1-pro | 1M tokens | Yes (reasoning_effort controls effort) |
Pricing
Per-token billing:
| Type | Credits / 1M tokens | Price / 1M tokens |
|---|---|---|
| Input | 160 credits | $0.80 |
| Output | 960 credits | $4.80 |
Endpoint
POST https://api.aivideoapi.ai/v1/chat/completions
OpenAI Chat Completions–compatible. Use the openai SDK with baseURL set to https://api.aivideoapi.ai/v1.
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-3.1-pro",
"messages": [
{ "role": "user", "content": "Hi, introduce yourself" }
]
}'
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Must be gemini-3.1-pro |
messages | array | Yes | Conversation messages |
stream | boolean | No | Enable streaming (default: true) |
tools | array | No | Tool definitions (only googleSearch supported) |
include_thoughts | boolean | No | Include reasoning thoughts (default: true) |
reasoning_effort | string | No | low or high (default: high) |
Multimodal Messages
All media types (image / video / audio / PDF) share the same image_url structure:
{
"role": "user",
"content": [
{ "type": "text", "text": "What is in this image?" },
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg" } }
]
}
Response
{
"id": "chatcmpl-20260417001546375193862M1p62g7j",
"object": "chat.completion",
"created": 1776356269,
"model": "gemini-3.1-pro-preview",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Tomorrow (April 17, 2026) Shanghai weather forecast:\n\n* **Conditions**: Mostly **cloudy to overcast**...\n* **Temperature**: Low 13–15°C, high around 21°C..."
}
}
],
"usage": {
"prompt_tokens": 194,
"completion_tokens": 229,
"total_tokens": 880,
"completion_tokens_details": {
"reasoning_tokens": 457,
"audio_tokens": 0,
"text_tokens": 0
}
},
"credits_consumed": 0.25
}
| Field | Type | Description |
|---|---|---|
id | string | Unique chat completion ID |
object | string | Always chat.completion |
created | int | Creation Unix timestamp |
model | string | Actual upstream model version (may carry suffixes like -preview) |
choices[].message.content | string | Assistant reply text |
choices[].finish_reason | string | stop / length / tool_calls etc. |
usage.prompt_tokens | int | Input tokens |
usage.completion_tokens | int | Output (text) tokens |
usage.completion_tokens_details.reasoning_tokens | int | Thinking tokens (when reasoning is on) |
usage.total_tokens | int | Total tokens (includes reasoning) |
credits_consumed | number | Credits actually charged for this call (computed at this platform's rate, independent of upstream's internal value) |
Billing:
credits_consumed = prompt_tokens × 160/1M + completion_tokens × 960/1M.reasoning_tokensare NOT billed — they are recorded for audit only in the response, inoutput.usage.reasoning_tokens, and inpricing_detail.
Examples
Google Search Grounding
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-3.1-pro",
"messages": [
{ "role": "user", "content": "Tomorrow weather forecast for Shanghai" }
],
"tools": [{ "type": "function", "function": { "name": "googleSearch" } }]
}'
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-3.1-pro",
"messages": [
{ "role": "user", "content": "What is the square root of 100?" }
],
"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.