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

# Gemini via OpenAI Format — Files, Search, Thinking

> Use Gemini models at POST /v1/chat/completions with the OpenAI SDK. Supports PDF, image, audio, video, web search grounding, and thinking budgets.

KiosAPI lets you call Gemini models using the standard OpenAI request format — pass files including PDFs, images, audio, and video directly in the `content` array of your messages. You can use the same OpenAI SDK and endpoint you use for other models; no additional configuration is required to switch to Gemini.

## Supported File Types

| Extension        | MIME Type         |
| ---------------- | ----------------- |
| `.pdf`           | `application/pdf` |
| `.mp3`           | `audio/mp3`       |
| `.mp4`           | `video/mp4`       |
| `.wav`           | `audio/wav`       |
| `.png`           | `image/png`       |
| `.jpg` / `.jpeg` | `image/jpeg`      |
| `.txt`           | `text/plain`      |
| `.mov`           | `video/mov`       |
| `.mpeg`          | `video/mpeg`      |
| `.mpg`           | `video/mpg`       |
| `.avi`           | `video/avi`       |
| `.wmv`           | `video/wmv`       |
| `.flv`           | `video/flv`       |

## Request

**POST** `https://kiosapi.com/v1/chat/completions`

### Headers

| Header          | Required | Description        |
| --------------- | -------- | ------------------ |
| `Content-Type`  | Yes      | `application/json` |
| `Authorization` | Yes      | `Bearer sk-xxx`    |

### Request Body

<ParamField body="model" type="string" required>
  Gemini model name (e.g. `gemini-2.5-pro`).
</ParamField>

<ParamField body="messages" type="array" required>
  Array of message objects forming the conversation.

  <Expandable title="messages properties">
    <ParamField body="messages[].role" type="string" required>
      Role of the message author: `user` or `assistant`.
    </ParamField>

    <ParamField body="messages[].content" type="string | array" required>
      The message content. Pass a plain string for text-only messages, or an array of content objects for multimodal input.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="max_tokens" type="number">
  Maximum number of tokens to generate in the response.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature.
</ParamField>

<ParamField body="stream" type="boolean">
  Set to `true` to stream the response using server-sent events.
</ParamField>

<ParamField body="tools" type="array">
  Function calling tools, or the special `googleSearch` tool for web search.
</ParamField>

<ParamField body="reasoning_effort" type="string">
  Thinking level for reasoning models. One of `high`, `medium`, or `low`.
</ParamField>

<ParamField body="extra_body" type="object">
  Advanced configuration, including `thinking_config` for fine-grained control over the thinking budget.
</ParamField>

<ParamField body="response_format" type="object">
  Structured output configuration.
</ParamField>

### Content Types for File Analysis

When passing `content` as an array, each element uses one of the following types:

| Type        | Fields                            | Description                               |
| ----------- | --------------------------------- | ----------------------------------------- |
| `text`      | `text`                            | Plain text prompt                         |
| `file`      | `file.filename`, `file.file_data` | File passed as base64 data or a URL       |
| `file_url`  | `file_url.url`                    | File accessible by URL (images and files) |
| `image_url` | `image_url.url`                   | Image URL (base64 data URI or web URL)    |

<Tip>
  For files over 20 MB, use the URL method rather than base64 to avoid hitting request size limits.
</Tip>

## Dynamic Thinking Models

When a model name ends with `thinking-*` (e.g. `gemini-2.5-flash-thinking-2000`), it supports dynamic thinking token limits. The number after `thinking-` sets the maximum number of tokens the model may use for internal reasoning.

## Web Search

You can enable web search in two ways:

1. Add the `-search` suffix to the model name (e.g. `gemini-2.5-flash-search`).
2. Include the `googleSearch` tool in your request body:

```json theme={null}
{
  "tools": [
    {
      "type": "function",
      "function": {"name": "googleSearch"}
    }
  ]
}
```

### Examples

<Tabs>
  <Tab title="cURL (Chat)">
    ```bash theme={null}
    curl https://kiosapi.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxx" \
      -d '{
        "model": "gemini-2.5-pro",
        "messages": [
          {
            "role": "user",
            "content": "Hello, who are you?"
          }
        ],
        "max_tokens": 1688,
        "temperature": 0.5,
        "stream": false
      }'
    ```
  </Tab>

  <Tab title="cURL (File Analysis)">
    ```bash theme={null}
    curl https://kiosapi.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer sk-xxx" \
      -d '{
        "model": "gemini-2.5-pro",
        "messages": [
          {
            "role": "user",
            "content": [
              {
                "type": "text",
                "text": "Summarize this document"
              },
              {
                "type": "file",
                "file": {
                  "filename": "document.pdf",
                  "file_data": "data:application/pdf;base64,JVBERi0xLjQK..."
                }
              }
            ]
          }
        ],
        "max_tokens": 6000,
        "stream": false
      }'
    ```
  </Tab>

  <Tab title="Python (Web Search)">
    ```python theme={null}
    import openai

    openai.api_key = "sk-xxx"
    openai.base_url = "https://kiosapi.com/v1/"

    response = openai.chat.completions.create(
        model="gemini-2.5-flash-search",
        messages=[{"role": "user", "content": "What is today's date?"}],
        max_tokens=1688,
        temperature=0.5,
        stream=False
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="Python (Thinking Budget)">
    ```python theme={null}
    response = openai.chat.completions.create(
        model="gemini-2.5-flash",
        messages=[{"role": "user", "content": "Complex reasoning task..."}],
        max_tokens=8000,
        extra_body={
            "google": {
                "thinking_config": {
                    "include_thoughts": True,
                    "thinking_budget": 8192
                }
            }
        }
    )
    ```
  </Tab>
</Tabs>

## Response

```json theme={null}
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1724972230,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm Gemini, a multilingual AI model..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 38,
    "total_tokens": 50
  }
}
```
