Gemini 原生 generate
對 Google Gemini API 的直接透傳。model_path 參數形如
<model>:<action>,例如
google/gemini-2.5-flash:generateContent 或
google/gemini-2.5-flash:streamGenerateContent。
支持的 action:
| Action | 含義 |
|---|---|
:generateContent | 一次性響應(JSON) |
:streamGenerateContent | SSE 流式分片 |
在此接口上你能做什么(請求形態保持 Gemini 原生 JSON;按需選模型):
- Chat / 推理 —— 任意
gemini-*chat 模型,配合generationConfig.thinkingConfig控制預算。 - 多模態輸入 ——
inline_data項可與text項并列, 承載圖像 / 音頻 / 視頻 / 文件內容。 - 函數調用 ——
tools: [{functionDeclarations: [...]}]。 - 內置服務端工具 ——
tools: [{googleSearch: {}}]、tools: [{codeExecution: {}}]、tools: [{urlContext: {}}]。 - 文本轉語音 ——
*-tts預覽模型,配合generationConfig.responseModalities: ["AUDIO"]與speechConfig.voiceConfig。 - 圖像生成 ——
gemini-*-image*模型;響應將圖像作為inlineData項攜帶。
鑒權同時接受標準的 Authorization: Bearer sk-orca-… 頭,
以及 Gemini 風格的 x-goog-api-key 頭和 ?key= 查詢參數
以兼容 google-genai SDK——見
獲取 API 密鑰。
Authorizations
OrcaRouter API 密鑰形如 sk-orca-...。請在
Authorization: Bearer sk-orca-... 頭中傳入。
Path Parameters
Body
Gemini 原生請求體(Google 的 GenerateContentRequest
形態)。常見載荷請見 examples。
Response
成功響應。對于 :generateContent,響應體是 JSON
(GenerateContentResponse)。對于 :streamGenerateContent,
響應體是 SSE(text/event-stream);每個事件都是一個
部分的 GenerateContentResponse。
Gemini 原生 GenerateContentResponse。
