跳轉到主要內容

快速開始

本頁針對的是現代的 google-genai Python SDK(pip install google-genai), 而非已廢棄的 google-generativeai 包。
Python
from google import genai

client = genai.Client(
    api_key="sk-orca-...",
    http_options={"base_url": "https://api.orcarouter.ai"},
)

response = client.models.generate_content(
    model="google/gemini-2.5-flash",
    contents="Hello",
)
print(response.text)
SDK 會以 Gemini 標準 JSON 形態請求 https://api.orcarouter.ai/v1beta/models/{model}:generateContent —— OrcaRouter 的一等公民 Gemini 接口表面。流式、函數調用、內聯多模態 數據(圖片、音頻)都可直接使用;尺寸限制和各模型約束請查閱 Google 官方 Gemini API 文檔。 SDK 通過 x-goog-api-key 頭(或 ?key=... 查詢參數)發送 api_key —— OrcaRouter 的鑒權中間件在 /v1beta/... 路徑上都識別這兩種形式。 完整鑒權頭清單見 獲取 API 密鑰

另見