# Gemini 3.7 Flash API Google が提供する Gemini 3.7 Flash LLM モデルの完全な API リファレンスです。 ## モデルバリエーション この API は、3 つの Gemini 3.7 Flash モデルバリエーションをサポートしています。 | モデル | ID | 説明 | |-------|----|-------------| | **Gemini 3.7 Flash Text to Text** | `gemini-3.7-flash-text-to-text` | 高速なテキスト推論と生成 | | **Gemini 3.7 Flash Image to Text** | `gemini-3.7-flash-image-to-text` | 高速な画像理解と分析 | | **Gemini 3.7 Flash File Analysis** | `gemini-3.7-flash-file-analysis` | 高速なファイルおよび画像分析 | ## クイック比較 | 機能 | テキストからテキスト | 画像からテキスト | ファイル分析 | |---------|--------------|---------------|---------------| | テキスト入力 | 必須 ✅ | 任意 | 任意 | | 画像入力 | 非対応 ❌ | 任意 | 任意 | | ファイル入力 | 非対応 ❌ | 非対応 ❌ | 任意 | | ストリーミングレスポンス | SSE | SSE | SSE | | `max_tokens` | 任意 | 任意 | 任意 | ## Gemini 3.7 Flash Text to Text ### エンドポイント ```http POST /api/v1/chat/completions ``` ### リクエストパラメータ #### 必須 | パラメータ | 型 | 説明 | |-----------|------|-------------| | `model` | string | `"gemini-3.7-flash-text-to-text"` である必要があります | | `messages` | array | 順序付きメッセージ。メッセージ構造については LLM API を参照してください。 | | `stream` | boolean | SSE の場合は `true`、単一の JSON レスポンスの場合は `false`。 | #### メッセージ対応 | フィールド | テキスト | ファイル | 画像 | |-------|------|------|-------| | `messages` | 必須 ✅ | 非対応 ❌ | 非対応 ❌ | #### 任意 | パラメータ | 型 | 範囲 | 説明 | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | 最大出力トークン数。 | ### リクエスト例 ```javascript 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.7-flash-text-to-text', messages: [ { role: 'user', content: 'Write a concise summary of how transformer models work.' } ], stream: true, max_tokens: 2048 }) }); ``` ## Gemini 3.7 Flash Image to Text ### エンドポイント ```http POST /api/v1/chat/completions ``` ### リクエストパラメータ #### 必須 | パラメータ | 型 | 説明 | |-----------|------|-------------| | `model` | string | `"gemini-3.7-flash-image-to-text"` である必要があります | | `messages` | array | 順序付きメッセージ。LLM API とメッセージ添付を参照してください。 | | `stream` | boolean | SSE の場合は `true`、単一の JSON レスポンスの場合は `false`。 | #### メッセージ対応 | フィールド | テキスト | ファイル | 画像 | |-------|------|------|-------| | `messages` | 任意 | 非対応 ❌ | 任意 | #### 任意 | パラメータ | 型 | 範囲 | 説明 | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | 最大出力トークン数。 | ### リクエスト例 ```javascript 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.7-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.7 Flash File Analysis ### エンドポイント ```http POST /api/v1/chat/completions ``` ### リクエストパラメータ #### 必須 | パラメータ | 型 | 説明 | |-----------|------|-------------| | `model` | string | `"gemini-3.7-flash-file-analysis"` である必要があります | | `messages` | array | 順序付きメッセージ。LLM API とメッセージ添付を参照してください。 | | `stream` | boolean | SSE の場合は `true`、単一の JSON レスポンスの場合は `false`。 | #### メッセージ対応 | フィールド | テキスト | ファイル | 画像 | |-------|------|------|-------| | `messages` | 任意 | 任意 | 任意 | #### 任意 | パラメータ | 型 | 範囲 | 説明 | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | 最大出力トークン数。 | ### リクエスト例 ```javascript 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.7-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.7 Flash LLM モデルは、OpenAI 互換の補完レスポンスを返します。`stream: true` の場合、レスポンスは Server-Sent Events となり、`stream: false` の場合は単一の JSON オブジェクトとなります。 ### 成功レスポンス ```text data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.7-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.7-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.7-flash-text-to-text","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gemini-3.7-flash-text-to-text","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}} data: [DONE] ``` ### エラーレスポンス ```text event: error data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}} ``` ## ベストプラクティス 1. **構造化メッセージを使用する:** コンテキストを 1 つのプロンプトにまとめるのではなく、`messages[]` を通じて会話履歴を送信します。 2. **適切なモデルバリエーションを選択する:** テキストのみのタスクには Text to Text、画像理解には Image to Text、ドキュメントまたは混合コンテンツが必要な場合は File Analysis を使用します。 3. **SSE イベントを処理する:** ストリーミング表示では `choices[0].delta.content` を追加し、`data: [DONE]` を正常完了として扱います。 4. **対応する入力のみを送信する:** 現在のクライアントでは、テキストモデルは未対応のファイルおよび画像部分を無視します。