Gemini 3.5 Flash API
Google による Gemini 3.5 Flash LLMの完全な API リファレンスです。
モデルバリアント {#}
この API は 3 種類の Gemini 3.5 Flash モデルバリアントをサポートしています:
クイック比較
Gemini 3.5 Flash Text to Text
エンドポイント
POST /api/v1/chat/completions
リクエストパラメータ
必須
メッセージ対応
任意
リクエスト例
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-3.5-flash-text-to-text',
messages: [
{
role: 'user',
content: 'Write a concise summary of how transformer models work.'
}
],
stream: true,
max_tokens: 2048
})
});
Gemini 3.5 Flash Image to Text
エンドポイント
POST /api/v1/chat/completions
リクエストパラメータ
必須
メッセージ対応
任意
リクエスト例
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-3.5-flash-image-to-text',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe the image and extract any visible text.' },
{
type: 'image_url',
image_url: {
url: 'https://example.com/sample-image.jpg'
}
}
]
}
],
stream: true,
max_tokens: 2048
})
});
Gemini 3.5 Flash File Analysis
エンドポイント
POST /api/v1/chat/completions
リクエストパラメータ
必須
メッセージ対応
任意
リクエスト例
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-3.5-flash-file-analysis',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Summarize this file and extract the key risks.' },
{
type: 'file',
file: {
filename: 'demo.pdf',
file_data: 'https://example.com/demo.pdf'
}
}
]
}
],
stream: true,
max_tokens: 4096
})
});
レスポンス形式
Gemini 3.5 Flash LLMモデルは Google 互換の completion レスポンスを返します。stream: true の場合は Server-Sent Events、stream: false の場合は単一の JSON オブジェクトです。
成功レスポンス
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.5-flash-text-to-text","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.5-flash-text-to-text","choices":[{"index":0,"delta":{"content":"Here is a concise summary"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.5-flash-text-to-text","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.5-flash-text-to-text","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}
data: [DONE]
エラーレスポンス
event: error
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
ベストプラクティス
- 構造化メッセージを使用する: コンテキストを 1 つの prompt に平坦化するのではなく、
messages[] で会話履歴を送信します。
- 適切なモデルバリアントを選択する: テキストのみのタスクには Text to Text、画像理解には Image to Text、ドキュメントまたは混合コンテンツには File Analysis を使用します。
- SSEイベントを処理する: ストリーミング表示では
choices[0].delta.content を追加し、data: [DONE] を成功完了として扱います。
- 対応している入力のみを送信する: 現在のクライアントでは、テキストモデルは非対応のファイルおよび画像パートを無視します。