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

# Gemini 이미지 생성(OpenAI 형식)

> <ul><li>Gemini 이미지 생성</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request POST \
    --url 'https://api.elkapi.com/v1/chat/completions' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "gemini-3.1-pro-preview",
    "stream": false,
    "messages": [
      {
        "role": "user",
        "content": "안녕하세요, 자기소개를 해 주세요"
      }
    ],
    "contents": [
      "안녕하세요, 자기소개를 해 주세요"
    ]
  }'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/v1/chat/completions"
  headers = {
      "Authorization": "Bearer <token>"
  }
  headers["Content-Type"] = "application/json"
  payload = {
      "model": "gemini-3.1-pro-preview",
      "stream": False,
      "messages": [
          {
              "role": "user",
              "content": "안녕하세요, 자기소개를 해 주세요"
          }
      ],
      "contents": [
          "안녕하세요, 자기소개를 해 주세요"
      ]
  }

  response = requests.request("POST", url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://api.elkapi.com/v1/chat/completions";

  const headers = {
    "Authorization": "Bearer <token>"
  };
  headers["Content-Type"] = "application/json";
  const payload = {
    "model": "gemini-3.1-pro-preview",
    "stream": false,
    "messages": [
      {
        "role": "user",
        "content": "안녕하세요, 자기소개를 해 주세요"
      }
    ],
    "contents": [
      "안녕하세요, 자기소개를 해 주세요"
    ]
  };

  const response = await fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(payload)
  });

  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "id": "id",
    "model": "gemini-3.1-pro-preview",
    "object": "object",
    "created": 1,
    "choices": [
      {
        "index": 1,
        "message": {
          "role": "user",
          "content": "안녕하세요, 자기소개를 해 주세요"
        },
        "finish_reason": "finish_reason"
      }
    ],
    "usage": {
      "prompt_tokens": 1,
      "completion_tokens": 1,
      "total_tokens": 1
    }
  }
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  모든 엔드포인트는 Bearer Token 인증이 필요합니다.

  요청 헤더에 추가하세요:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" required default="gemini-3.1-pro-preview">
  예시: `gemini-3.1-pro-preview`
</ParamField>

<ParamField body="stream" type="boolean" required />

<ParamField body="messages" type="array<object>" required>
  <ParamField body="messages.role" type="string" />

  <ParamField body="messages.content" type="string" />
</ParamField>

<ParamField body="extra_body" type="object">
  <ParamField body="extra_body.google" type="object" required>
    <ParamField body="extra_body.google.image_config" type="object" required>
      <ParamField body="extra_body.google.image_config.aspect_ratio" type="string" required />

      <ParamField body="extra_body.google.image_config.image_size" type="string" required />
    </ParamField>
  </ParamField>
</ParamField>

<ParamField body="contents" type="array<object>" required>
  <ParamField body="contents.role" type="string" />

  <ParamField body="contents.parts" type="array<object>">
    <ParamField body="contents.parts.text" type="string" />
  </ParamField>
</ParamField>

## Response

<ResponseField name="id" type="string" />

<ResponseField name="model" type="string" default="gemini-3.1-pro-preview">
  예시: `gemini-3.1-pro-preview`
</ResponseField>

<ResponseField name="object" type="string" />

<ResponseField name="created" type="integer" />

<ResponseField name="choices" type="array<object>">
  <ResponseField name="choices.index" type="integer" />

  <ResponseField name="choices.message" type="object">
    <ResponseField name="choices.message.role" type="string" required />

    <ResponseField name="choices.message.content" type="string" required />
  </ResponseField>

  <ResponseField name="choices.finish_reason" type="string" />
</ResponseField>

<ResponseField name="usage" type="object">
  <ResponseField name="usage.prompt_tokens" type="integer" required />

  <ResponseField name="usage.completion_tokens" type="integer" required />

  <ResponseField name="usage.total_tokens" type="integer" required />
</ResponseField>
