UniterRouter
API ReferenceGoogle Compatible

Vision

Gemini Vision API - Analyze images and videos with Gemini Pro Vision, Gemini 1.5. Multimodal AI for image understanding, video analysis, and document processing.

Vision (Image & Video Input)

Gemini models are natively multimodal and can understand images and videos. Use vision capabilities for image analysis, OCR, visual reasoning, and video understanding.

Supported Models: All Gemini 1.5+ models support vision input.

Supported Formats

Images

  • JPEG, PNG, GIF, WebP
  • Maximum size: 20MB per image
  • Up to 3,600 images per request

Videos

  • MP4, MOV, MPEG, AVI, FLV, MKV, WebM
  • Maximum length: 1 hour
  • Maximum size: 2GB

Image Input Methods

1. Base64 Inline Data

# First, encode your image
BASE64_IMAGE=$(base64 -i image.jpg)

curl -X POST "https://api.uniterouter.ai/v1beta/models/gemini-2.0-flash:generateContent" \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: $UNITEROUTER_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "'$BASE64_IMAGE'"
            }
          },
          {"text": "Describe this image in detail"}
        ]
      }
    ]
  }'
import google.generativeai as genai
import PIL.Image

genai.configure(
    api_key="your_uniterouter_api_key",
    transport="rest",
    client_options={"api_endpoint": "api.uniterouter.ai"}
)

model = genai.GenerativeModel("gemini-2.0-flash")

# Using PIL Image
image = PIL.Image.open("image.jpg")
response = model.generate_content([
    "Describe this image in detail",
    image
])
print(response.text)

# Or using base64
import base64
with open("image.jpg", "rb") as f:
    image_data = base64.b64encode(f.read()).decode()

response = model.generate_content([
    {
        "inline_data": {
            "mime_type": "image/jpeg",
            "data": image_data
        }
    },
    "Describe this image"
])
import { GoogleGenerativeAI } from "@google/generative-ai";
import * as fs from "fs";

const genAI = new GoogleGenerativeAI("your_uniterouter_api_key", {
  baseUrl: "https://api.uniterouter.ai"
});

const model = genAI.getGenerativeModel({ model: "gemini-2.0-flash" });

const imageData = fs.readFileSync("image.jpg").toString("base64");

const result = await model.generateContent([
  {
    inlineData: {
      mimeType: "image/jpeg",
      data: imageData
    }
  },
  { text: "Describe this image in detail" }
]);

console.log(result.response.text());

2. URL Reference

response = model.generate_content([
    {
        "file_data": {
            "mime_type": "image/jpeg",
            "file_uri": "https://example.com/image.jpg"
        }
    },
    "What's in this image?"
])

Video Input

import google.generativeai as genai

genai.configure(
    api_key="your_uniterouter_api_key",
    transport="rest",
    client_options={"api_endpoint": "api.uniterouter.ai"}
)

# Upload video file first
video_file = genai.upload_file("video.mp4")

# Wait for processing
import time
while video_file.state.name == "PROCESSING":
    time.sleep(2)
    video_file = genai.get_file(video_file.name)

# Generate content with video
model = genai.GenerativeModel("gemini-2.0-flash")
response = model.generate_content([
    video_file,
    "Summarize what happens in this video"
])
print(response.text)
import { GoogleGenerativeAI, FileState } from "@google/generative-ai";

const genAI = new GoogleGenerativeAI("your_uniterouter_api_key", {
  baseUrl: "https://api.uniterouter.ai"
});

const fileManager = genAI.getFileManager();

// Upload video
let file = await fileManager.uploadFile("video.mp4", {
  mimeType: "video/mp4"
});

// Wait for processing
while (file.state === FileState.PROCESSING) {
  await new Promise(resolve => setTimeout(resolve, 2000));
  file = await fileManager.getFile(file.name);
}

// Generate content
const model = genAI.getGenerativeModel({ model: "gemini-2.0-flash" });
const result = await model.generateContent([
  { fileData: { fileUri: file.uri, mimeType: file.mimeType } },
  { text: "Summarize what happens in this video" }
]);

console.log(result.response.text());

Media Resolution

Control input quality with mediaResolution:

{
  "generationConfig": {
    "mediaResolution": "MEDIA_RESOLUTION_HIGH"
  }
}
ValueDescription
MEDIA_RESOLUTION_LOWFaster processing, lower quality
MEDIA_RESOLUTION_MEDIUMBalanced
MEDIA_RESOLUTION_HIGHBest quality, more tokens

Use Cases

Use CaseExample Prompt
Image Description"Describe this image in detail"
OCR"Extract all text from this image"
Object Detection"List all objects you can see"
Visual Q&A"What color is the car?"
Document Analysis"Summarize this document"
Video Summary"What happens in this video?"
Timestamp Analysis"At what timestamp does X happen?"

Multiple Images

response = model.generate_content([
    image1,
    image2,
    image3,
    "Compare these three images and describe the differences"
])

Best Practices

  1. Use appropriate resolution - Lower resolution for simple tasks, higher for detail
  2. Compress large images - Reduce file size before sending
  3. Be specific - Clear prompts get better results
  4. Batch images - Send multiple related images together for comparison tasks

How is this guide?