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

# Chat Completions (Gemini)

> Chat with Gemini models through the OpenAI Chat Completions API format — works with the official OpenAI SDKs.

This endpoint speaks the **OpenAI Chat Completions API** format: request body, response body, streaming chunks and
error shapes are the same as OpenAI's. Point the official OpenAI SDK at our base URL and use your ModelHunter.AI API key.

## Models

| Model | Input / 1M tokens | Output / 1M tokens | Cached input / 1M tokens |
| - | - | - | - |
| `gemini-4-neon` | \$3 | \$15 | \$0.15 |
| `gemini-4-argon` | \$2 | \$10 | \$0.10 |
| `gemini-4-carbon` | \$2 | \$10 | \$0.10 |
| `gemini-4-hydrogen` | \$1.50 | \$7.50 | \$0.075 |
| `gemini-3-8-flash` | \$0.75 | \$3.75 | — |

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.modelhunter.ai/api/v1",
)

completion = client.chat.completions.create(
    model="gemini-4-neon",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)
```

```javascript JavaScript theme={null}
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://api.modelhunter.ai/api/v1',
})

const completion = await client.chat.completions.create({
  model: 'gemini-4-neon',
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(completion.choices[0].message.content)
```

```bash cURL theme={null}
curl https://api.modelhunter.ai/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "gemini-4-neon", "messages": [{ "role": "user", "content": "Hello!" }] }'
```

## Body Parameters

The body follows the OpenAI Chat Completions API. The most common fields:

**model** `string` *required*

One of the models above.

**messages** `object[]` *required*

Conversation: `[{ "role": "system" | "user" | "assistant", "content": string | content parts }]`.
Content parts may include `image_url` images.

**max\_tokens** `integer`

Maximum output tokens. `max_completion_tokens` is also accepted.

**stream** `boolean` (default: false)

Stream the response as `chat.completion.chunk` server-sent events, ending with `data: [DONE]`.
The final chunk always includes `usage`.

**temperature** `number`

Sampling temperature.

Other Chat Completions fields (`top_p`, `stop`, `response_format`, `stream_options`) are passed through unchanged.

> [!WARNING]
>
> Gemini models currently support chat requests; tool calling for agents may not work yet.

## Long requests and streaming

> [!TIP]
>
> **Use `"stream": true` for reasoning models and long outputs.** Tokens arrive as they are generated, so long
> answers never sit idle on the connection. While a stream is waiting for the model (for example while it is
> thinking), we send `: keepalive` SSE comments every 15 seconds; SSE clients and the official SDKs ignore them.
>
> Non-streaming requests that take longer than 15 seconds are also kept alive: the response starts with
> `200 OK` and leading whitespace (ignored by JSON parsers) until the result is ready. If such a request fails
> after that point, the error is returned in the response body with status `200` instead of an error status,
> so check the body for an `error` field.

## Billing

Each call is billed per token at the official price. When the request starts, an upper bound on its cost
(estimated input + at least 8,192 output tokens, since Gemini thinking is not capped by `max_tokens`) is held from
your balance. When it finishes you are charged for the tokens actually used and the rest is released.
Failed requests are not charged.

```json 200 theme={null}
{
  "id": "chatcmpl-2dd2...",
  "object": "chat.completion",
  "model": "gemini-4-neon",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": { "role": "assistant", "content": "Hello! How can I help you today?" }
    }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}
```

```json 400 theme={null}
{
  "error": {
    "message": "\"messages\" is required and must be a non-empty array.",
    "type": "invalid_request_error",
    "code": null
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.