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": "Extract order fields and return JSON." }]
}
],
"generationConfig": {
"responseMimeType": "application/json"
}
}
cURL 예
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [{ "text": "Extract order fields and return JSON." }]
}
],
"generationConfig": {
"responseMimeType": "application/json"
}
}'
파이썬 예제
import requests
response = requests.post(
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",
headers={
"x-goog-api-key": "<GEMINI_API_KEY>",
"Content-Type": "application/json",
},
json={
"contents": [
{
"role": "user",
"parts": [{"text": "Extract order fields and return JSON."}],
}
],
"generationConfig": {
"responseMimeType": "application/json",
},
},
)
print(response.json())
Node.js 예
const response = await fetch(
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",
{
method: "POST",
headers: {
"x-goog-api-key": process.env.GEMINI_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
contents: [
{
role: "user",
parts: [{ text: "Extract order fields and return JSON." }]
}
],
generationConfig: {
responseMimeType: "application/json"
}
}),
}
);
console.log(await response.json());
모범 사례
- 구조화된 출력을 위해
responseMimeType를 명시적으로 설정
- 출력 요구 사항이 엄격한 경우 예상되는 필드 모양을 프롬프트에 넣습니다.
- 다운스트림에 노출하기 전에 서버에서 JSON을 구문 분석하고 검증합니다.