# Gemini 3.7 Flash API Google이 제공하는 Gemini 3.7 Flash LLM 모델의 전체 API 레퍼런스입니다. ## 모델 변형 이 API는 세 가지 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` | 빠른 파일 및 이미지 분석 | ## 빠른 비교 | 기능 | Text to Text | Image to Text | 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 호환 completion 응답을 반환합니다. `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. **구조화된 메시지 사용:** 컨텍스트를 하나의 프롬프트로 합치지 말고 `messages[]`를 통해 대화 기록을 전송하세요. 2. **적합한 모델 변형 선택:** 텍스트 전용 작업에는 Text to Text를, 이미지 이해에는 Image to Text를, 문서 또는 혼합 콘텐츠가 필요할 때는 File Analysis를 사용하세요. 3. **SSE 이벤트 처리:** 스트리밍 표시를 위해 `choices[0].delta.content`를 이어 붙이고 `data: [DONE]`을 성공적인 완료로 처리하세요. 4. **지원되는 입력만 전송:** 현재 클라이언트에서 텍스트 모델은 지원되지 않는 파일 및 이미지 부분을 무시합니다.