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

# Gemini API

> Use Gemini-compatible requests through APIXO

Use APIXO as a Gemini-compatible API gateway. Keep the Gemini request format, replace the base URL, and use your APIXO API key.

## What to change

| Setting        | APIXO value                                                                |
| -------------- | -------------------------------------------------------------------------- |
| Base URL       | `https://llm.apixo.ai`                                                     |
| Request URL    | `https://llm.apixo.ai/v1beta/models/{model}:generateContent`               |
| API key        | `APIXO_API_KEY` from [APIXO API Keys](https://apixo.ai/dashboard/api-keys) |
| API key header | `x-goog-api-key`                                                           |
| Model location | URL path `{model}`                                                         |

## Quickstart

```bash theme={null}
export APIXO_API_KEY="your_apixo_api_key"
```

```bash theme={null}
curl -X POST "https://llm.apixo.ai/v1beta/models/gemini-3.1-pro-preview:generateContent" \
  -H "x-goog-api-key: $APIXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{"text": "Say hello in one sentence."}]
      }
    ]
  }'
```

## Streaming

```bash theme={null}
curl -N -X POST "https://llm.apixo.ai/v1beta/models/gemini-3.1-pro-preview:streamGenerateContent" \
  -H "x-goog-api-key: $APIXO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [{"text": "Stream a short hello message."}]
      }
    ]
  }'
```

## JavaScript fetch example

Use a Gemini-compatible request URL with your APIXO API key.

```javascript theme={null}
const model = "gemini-3.1-pro-preview";
const response = await fetch(
  `https://llm.apixo.ai/v1beta/models/${model}:generateContent`,
  {
    method: "POST",
    headers: {
      "x-goog-api-key": process.env.APIXO_API_KEY,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      contents: [
        {
          role: "user",
          parts: [{ text: "Give me 3 rollout risk checks." }]
        }
      ]
    })
  }
);

const data = await response.json();
console.log(data);
```

## Supported Gemini models

* `gemini-3.1-pro-preview`
* `gemini-3.1-flash-lite-preview`
* `gemini-3-pro-preview`
* `gemini-3-flash-preview`
* `gemini-2.5-pro`
* `gemini-2.5-flash`
* `gemini-2.5-flash-lite`

## Troubleshooting

* `401`: missing or invalid API key
* `400`: invalid Gemini request body, endpoint, or unsupported model id
* `429`: rate limit or temporary capacity limit
* `502` / `504`: upstream provider error or timeout

Retry `429`, `502`, and `504` with backoff. Fix `400` and `401` before retrying.

## Related

* [LLM Gateway Overview](/docs/llm)
* [Supported Models](/docs/llm/supported-models)
* [LLM Authentication](/docs/llm/authentication)
* [LLM Streaming](/docs/llm/streaming)
* [LLM Errors and Retry](/docs/llm/errors-retry)
* [Pricing](https://apixo.ai/pricing)
