Skip to main content
Endpoint: POST /projects/cognition/locations/us/publishers/google/models/{model}:generateContent Generate text or multimodal content with Google’s Gemini models.
Most integrations should use Create Chat Completion. Use this endpoint when you specifically need Google’s generateContent request format.
import os
import requests

url = "https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-1.5-pro-latest:generateContent"

response = requests.post(
    url,
    headers={
        "Authorization": f"Bearer {os.environ['YOUROUTER_API_KEY']}",
        "Content-Type": "application/json",
        "vendor": "google"
    },
    json={
        "contents": [
            {"role": "user", "parts": [{"text": "hello gemini"}]}
        ]
    }
)
print(response.json())

Parameters

model
string
required
The Gemini model to use, e.g. gemini-1.5-pro-latest.
contents
array
required
Input text or multimedia parts for the model.
safetySettings
object
Optional safety settings to control content thresholds.

Image Input

Use inlineData for image bytes encoded as base64.
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
  -H "Authorization: Bearer $YOUROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "vendor: google" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Describe this image in one sentence." },
          {
            "inlineData": {
              "mimeType": "image/jpeg",
              "data": "<BASE64_IMAGE>"
            }
          }
        ]
      }
    ]
  }'

PDF Input

The Gemini-native generateContent format can send PDFs through inlineData. Set mimeType to application/pdf, and pass the base64-encoded raw PDF bytes in data.
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
  -H "Authorization: Bearer $YOUROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "vendor: google" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          { "text": "Summarize this PDF's key content." },
          {
            "inlineData": {
              "mimeType": "application/pdf",
              "data": "<BASE64_PDF>"
            }
          }
        ]
      }
    ]
  }'
PDF support depends on the selected Gemini model. Long documents consume more context window; in production, control file size and page count, and split documents when needed.
See the Multimodal guide for the broader integration path.