Tích hợp API Gemini 2.5 Flash
Dùng Gemini 2.5 Flash qua Rivya Public API v1 với model id gemini-2-5-flash-chat, input được hỗ trợ, tham số, quy tắc Files API, tín dụng và ví dụ response.
gemini-2-5-flash-chat
text, file
Không bắt buộc cho minimal request
1
Chat
API chat: không streaming + SSE streaming
TOKEN_BASED
20000 ký tự
Hợp đồng yêu cầu
Chat request gửi từng tin nhắn một. Session history được Rivya lưu; đừng gửi raw messages array.
| Key | Type | Bắt buộc | Default | Mô tả |
|---|---|---|---|---|
| model | string | Có | gemini-2-5-flash-chat | Dùng API model id gemini-2-5-flash-chat. |
| session_id | string | Không | - | API-created chat session id tùy chọn. Bỏ qua để bắt đầu phiên mới. |
| message | string | Có | - | Tin nhắn người dùng tiếp theo. Lịch sử Chat API đến từ server-side session, không phải raw messages array. |
| attachments | array | Không | - | Giá trị image file_id tùy chọn trả về bởi Files API. Attachment URL bên ngoài không được chấp nhận. |
| enable_web_search | boolean | Không | false | Chỉ áp dụng khi mô hình chat đã chọn hỗ trợ web search. |
| reasoning_effort | string | Không | default | Reasoning effort tùy chọn: default, minimal, low, medium, high hoặc xhigh khi được hỗ trợ. |
| client_request_id | string | Không | - | Client-side id tùy chọn để trace request trong hệ thống của bạn. |
Tham số mô hình
Mô hình chat này dùng các trường Chat API dùng chung ở trên. Hỗ trợ riêng cho web search, image file attachments, thoughts và reasoning được phản ánh trong readiness data.
Yêu cầu tối thiểu
{
"model": "gemini-2-5-flash-chat",
"message": "Write a concise launch plan for a new product image campaign"
}Yêu cầu có tệp tham chiếu
{
"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"
}
]
}Phản hồi tạo
Chat endpoint trả về completed assistant message, token usage và final credit settlement cho lượt này.
{
"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
}
}Lỗi thường gặp
validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found, chat_model_not_supported, chat_session_conflict, chat_attachment_not_supported
Chat API hỗ trợ lượt non-streaming và SSE streaming trong Public API v1. Image attachments phải dùng giá trị file_id của Files API.