POST
/
v1
/
chat
/
completions
Chat Compatible File Reading
curl --request POST \
  --url https://api.example.com/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "temperature": 123,
  "top_p": 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/document-processing
Read and analyze documents and files using Gemini models through the standard OpenAI Chat Completions API format.

Overview

This endpoint allows you to send files (images, PDFs, documents) to Gemini models for analysis using the OpenAI-compatible chat format. Files can be provided via URL.

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-2.5-flash-all, gemini-2.5-pro.
messages
array
required
A list of messages with multimodal content. Include file URLs via image_url objects.
temperature
number
default:"1"
Sampling temperature between 0 and 2.
top_p
number
default:"1"
Nucleus sampling parameter.
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-2.5-flash-all",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "What is in this image? Please describe in detail."},
          {"type": "image_url", "image_url": {"url": "https://example.com/document.png"}}
        ]
      }
    ],
    "temperature": 0.5,
    "top_p": 1.0,
    "stream": true
  }'

Response Example

{
  "id": "chatcmpl-gemini-file-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gemini-2.5-flash-all",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The document contains..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 500,
    "completion_tokens": 150,
    "total_tokens": 650
  }
}

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.

Supported File Types

Files can be provided via URL in the image_url field:
  • Images (PNG, JPEG, GIF, WebP)
  • PDFs
  • Documents

Available Models

  • gemini-2.5-flash-all
  • gemini-2.5-pro
  • gemini-2.0-flash