> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yourouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini Generate Content

> 호환 API를 통해 Google Gemini 모델을 호출합니다.

**엔드포인트:** `POST /projects/cognition/locations/us/publishers/google/models/{model}:generateContent`

Google Gemini 모델로 텍스트 또는 멀티모달 콘텐츠를 생성합니다.

<Note>
  대부분의 연동에는 여전히 [Create Chat Completion](/ko/api-reference/chat/create) 사용을 권장합니다. Google 네이티브 `generateContent` 요청 형식이 반드시 필요할 때만 이 엔드포인트를 사용하세요.
</Note>

<CodeGroup>
  ```python Python theme={null}
  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())
  ```

  ```bash cURL theme={null}
  curl https://api.yourouter.ai/v1/projects/cognition/locations/us/publishers/google/models/gemini-1.5-pro-latest:generateContent \
    -H "Authorization: Bearer $YOUROUTER_API_KEY" \
    -H "Content-Type: application/json" \
    -H "vendor: google" \
    -d '{"contents": [{"role": "user", "parts": [{"text": "hello gemini"}]}]}'
  ```
</CodeGroup>

## 매개변수

<ResponseField name="model" type="string" required>
  사용할 Gemini 모델(예: `gemini-1.5-pro-latest`).
</ResponseField>

<ResponseField name="contents" type="array" required>
  모델에 전달할 텍스트 또는 멀티미디어 parts.
</ResponseField>

<ResponseField name="safetySettings" type="object">
  콘텐츠 임계값을 제어하는 선택적 안전 설정.
</ResponseField>

## 이미지 입력

이미지 콘텐츠에는 base64로 인코딩한 이미지 바이트를 `inlineData`로 전달하세요.

```bash theme={null}
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`에 전달하세요.

```bash theme={null}
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>"
            }
          }
        ]
      }
    ]
  }'
```

<Note>
  PDF 지원은 선택한 Gemini 모델에 따라 다릅니다. 긴 문서는 더 많은 컨텍스트 창을 사용하므로, 프로덕션에서는 파일 크기와 페이지 수를 관리하고 필요하면 문서를 분할하세요.
</Note>

더 자세한 연동은 [멀티모달 가이드](/ko/guides/multimodal)를 참고하세요.
