模型 API 接入文件
Gemini 2.5 Flash API 接入文件
透過 Rivya Public API v1 呼叫 Gemini 2.5 Flash,包含模型 ID gemini-2-5-flash-chat、輸入類型、參數、Files API 規則、點數和回應範例。
API 可呼叫文字輸入可用對話
API 模型 ID
gemini-2-5-flash-chat
輸入類型
text, file
Files API
最小請求不需要
基礎點數
1
能力類型
對話
可用狀態
Chat API:non-streaming + SSE streaming
計費方式
TOKEN_BASED
Prompt 上限
20000 字元
請求欄位
Chat 請求一次傳送一則 message。歷史脈絡由 Rivya session 保存,不接受 raw messages array。
| Key | 類型 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|
| model | string | 是 | gemini-2-5-flash-chat | 使用 gemini-2-5-flash-chat 作為 API 模型 ID。 |
| session_id | string | 否 | - | 可選的 API 建立 chat session id。省略時會開始新的 session。 |
| message | string | 是 | - | 下一則使用者訊息。Chat API 的歷史脈絡來自伺服器端 session,不接受 raw messages array。 |
| attachments | array | 否 | - | 可選圖片 file_id,必須來自 Files API。這裡不接受外部附件 URL。 |
| enable_web_search | boolean | 否 | false | 僅在所選 Chat 模型支援網頁搜尋時生效。 |
| reasoning_effort | string | 否 | default | 可選 reasoning effort:default、minimal、low、medium、high 或 xhigh,依模型支援情況生效。 |
| client_request_id | string | 否 | - | 可選的用戶端請求 ID,方便你在自己的系統中追蹤請求。 |
模型參數
這個 Chat 模型使用上方共用 Chat API 欄位。網頁搜尋、圖片 file 附件、思考內容和 reasoning 支援情況會呈現在 readiness 資料中。
最小請求
{
"model": "gemini-2-5-flash-chat",
"message": "Write a concise launch plan for a new product image campaign"
}參考文件請求
{
"model": "gemini-2-5-flash-chat",
"message": "Write a concise launch plan for a new product image campaign",
"attachments": [
{
"file_id": "file_uploaded_image_id"
}
]
}建立回應
Chat endpoint 會直接回傳本輪 assistant message、token usage 和最終點數結算。
{
"id": "chatcmpl_msg_gemini_2_5_flash_chat_example",
"object": "chat.completion",
"session_id": "chat_session_gemini_2_5_flash_chat",
"model": "gemini-2-5-flash-chat",
"created_at": "2026-05-11T00:00:00.000Z",
"message": {
"id": "assistant_message_id",
"role": "assistant",
"content": "A concise launch plan with clear next steps."
},
"usage": {
"input_tokens": 1200,
"output_tokens": 320,
"total_tokens": 1520
},
"credits": {
"reserved": 1,
"final": 1
}
}常見錯誤
validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found, chat_model_not_supported, chat_session_conflict, chat_attachment_not_supported
Chat API 在 Public API v1 中支援 non-streaming 和 SSE streaming 回合。 圖片附件必須使用 Files API 回傳的 file_id。