Skip to main content
POST
/
v1
/
models
/
{model}
:generateContent
curl -X POST https://qingbo.dev/v1/models/gemini-2.5-flash:generateContent \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {"text": "解释一下冒泡排序算法。"}
        ]
      }
    ],
    "generationConfig": {
      "temperature": 0.7,
      "maxOutputTokens": 1024
    }
  }'
The Gemini native format API provides a native interface for interacting with Google Gemini models, supporting multimodal input and advanced features.
curl -X POST https://qingbo.dev/v1/models/gemini-2.5-flash:generateContent \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {"text": "解释一下冒泡排序算法。"}
        ]
      }
    ],
    "generationConfig": {
      "temperature": 0.7,
      "maxOutputTokens": 1024
    }
  }'

Overview

Supported Models

Gemini 2.5 Pro

Professional version with powerful reasoning capabilities

Gemini 2.5 Flash

Fast version, balancing speed and performance

Gemini 2.5 Flash Lite

Ultra-lightweight version for maximum response speed

Gemini 3 Pro Preview

Latest generation preview with deep thinking support

Request Parameters

model
string
required
Model ID, as a URL path parameter:
  • gemini-2.5-pro
  • gemini-2.5-flash
  • gemini-2.5-flash-lite
  • gemini-2.5-pro-thinking
  • gemini-3-pro-preview
  • gemini-3-pro-preview-thinking
contents
array
required
Conversation content array.
generationConfig
object
Generation configuration.

Request Examples

curl https://qingbo.dev/v1/models/gemini-2.5-flash:generateContent \
  -H "Content-Type: application/json" \
  -H "x-goog-api-key: YOUR_API_KEY" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "解释量子计算的基本原理"
          }
        ]
      }
    ],
    "generationConfig": {
      "temperature": 0.7,
      "maxOutputTokens": 1000,
      "topP": 0.95
    }
  }'

Response Format

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "量子计算是一种利用量子力学原理..."
          }
        ]
      },
      "finishReason": "STOP",
      "safetyRatings": [...]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 12,
    "candidatesTokenCount": 156,
    "totalTokenCount": 168
  }
}

Multimodal Input

Gemini supports mixed text and image input:
import PIL.Image

# Load image
img = PIL.Image.open('image.jpg')

# Send text and image
response = model.generate_content([
    "描述这张图片中的内容",
    img
])

print(response.text)

Streaming Output

response = model.generate_content(
    "写一个关于AI的故事",
    stream=True
)

for chunk in response:
    print(chunk.text, end="")

Safety Settings

Control content filtering levels:
from google.generativeai.types import HarmCategory, HarmBlockThreshold

response = model.generate_content(
    "你的提示词",
    safety_settings={
        HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_ONLY_HIGH,
        HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_ONLY_HIGH,
    }
)

Feature Comparison

FeatureGemini 2.0 FlashGemini 1.5 ProGemini 1.5 Flash
Context window1M tokens2M tokens1M tokens
Multimodal inputYesYesYes
Code generationYesYesYes
SpeedVery fastFastVery fast
Long context processing: Gemini 1.5 Pro supports up to 2 million tokens of context, making it ideal for processing long documents and video analysis.