Documentation Index
Fetch the complete documentation index at: https://docs.apigo.ai/llms.txt
Use this file to discover all available pages before exploring further.
권장 엔드포인트
최소한의 요청
{
"model": "gemini-2.5-flash",
"contents": [
{
"role": "user",
"parts": [{ "text": "Explain SSE streaming while streaming the answer." }]
}
]
}
cURL 예
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-N \
-d '{
"contents": [
{
"role": "user",
"parts": [{ "text": "Explain SSE streaming while streaming the answer." }]
}
]
}'
파이썬 예제
from google import genai
client = genai.Client(api_key="<GEMINI_API_KEY>")
stream = client.models.generate_content_stream(
model="gemini-2.5-flash",
contents="Explain SSE streaming while streaming the answer.",
)
for chunk in stream:
if chunk.text:
print(chunk.text, end="")
Node.js 예
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const stream = await ai.models.generateContentStream({
model: "gemini-2.5-flash",
contents: "Explain SSE streaming while streaming the answer."
});
for await (const chunk of stream) {
if (chunk.text) process.stdout.write(chunk.text);
}
모범 사례
- 청크당 완전한 문장을 가정하는 대신
parts[].text를 점진적으로 누적합니다.
- 구조화된 출력도 스트리밍할 수 있지만 부분 JSON 서버 측을 구문 분석합니다.
- 플래시급 모델은 일반적으로 지연 시간에 민감한 스트리밍 채팅에 가장 적합합니다.