엔드포인트: POST /projects/cognition/locations/us/publishers/google/models/{model}:generateContent
Google Gemini 모델로 텍스트 또는 멀티모달 콘텐츠를 생성합니다.
import os
import requests
url = "https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-1.5-pro-latest:generateContent"
response = requests.post(
url,
headers={
"Authorization": f"Bearer {os.environ['YOUROUTER_API_KEY']}",
"Content-Type": "application/json",
"vendor": "google"
},
json={
"contents": [
{"role": "user", "parts": [{"text": "hello gemini"}]}
]
}
)
print(response.json())
매개변수
사용할 Gemini 모델(예: gemini-1.5-pro-latest).
모델에 전달할 텍스트 또는 멀티미디어 parts.
이미지 입력
이미지 콘텐츠에는 base64로 인코딩한 이미지 바이트를 inlineData로 전달하세요.
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "vendor: google" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Describe this image in one sentence." },
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "<BASE64_IMAGE>"
}
}
]
}
]
}'
PDF 입력
Gemini 네이티브 generateContent 형식은 inlineData로 PDF를 보낼 수 있습니다. mimeType을 application/pdf로 설정하고, PDF 원본 바이트를 base64로 인코딩한 값을 data에 전달하세요.
curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-2.5-flash:generateContent \
-H "Authorization: Bearer $YOUROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "vendor: google" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Summarize this PDF's key content." },
{
"inlineData": {
"mimeType": "application/pdf",
"data": "<BASE64_PDF>"
}
}
]
}
]
}'
PDF 지원은 선택한 Gemini 모델에 따라 다릅니다. 긴 문서는 더 많은 컨텍스트 창을 사용하므로, 프로덕션에서는 파일 크기와 페이지 수를 관리하고 필요하면 문서를 분할하세요.
더 자세한 연동은 멀티모달 가이드를 참고하세요.