POST
/
v1
/
chat
/
completions
Chat Compatible Vision
curl --request POST \
  --url https://api.example.com/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "temperature": 123,
  "max_tokens": 123,
  "stream": true
}
'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {}
  ],
  "usage": {}
}
Official documentation: https://ai.google.dev/gemini-api/docs/image-understanding
Analyze and understand images using Gemini models through the standard OpenAI Chat Completions API format.

Overview

This endpoint allows you to send images to Gemini models for analysis using the OpenAI-compatible chat format. You can provide images via URL or base64-encoded data.

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
The Gemini model ID. For example: gemini-1.5-pro-latest, gemini-2.5-pro.
messages
array
required
A list of messages with multimodal content. Include image_url objects for images.
temperature
number
default:"1"
Sampling temperature between 0 and 2.
max_tokens
integer
Maximum number of tokens to generate.
stream
boolean
default:"false"
Whether to stream responses.

Request Example

curl -X POST https://www.anyfast.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-1.5-pro-latest",
    "stream": false,
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is in this image?"},
          {"type": "image_url", "image_url": {"url": "https://example.com/image.png"}}
        ]
      }
    ],
    "temperature": 0.9,
    "max_tokens": 400
  }'

Response Example

{
  "id": "chatcmpl-gemini-vision-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gemini-1.5-pro-latest",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The image shows a logo featuring a cat character..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 300,
    "completion_tokens": 50,
    "total_tokens": 350
  }
}

Response Fields

id
string
Unique identifier for the completion.
object
string
Object type, which is chat.completion.
created
integer
Unix timestamp of when the completion was created.
model
string
The model used.
choices
array
List of completion choices.
usage
object
Usage statistics for the request.

Image Input Formats

Images can be provided in two ways:

URL

{"type": "image_url", "image_url": {"url": "https://example.com/image.png"}}

Base64

{"type": "image_url", "image_url": {"url": "data:image/png;base64,<BASE64_DATA>"}}

Available Models

  • gemini-1.5-pro-latest
  • gemini-2.0-flash
  • gemini-2.5-pro
  • gemini-2.5-flash