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

# AI gateway

> Call any major LLM with your Crevio API key. One endpoint, OpenAI-compatible, billed to your credit balance — no provider account and no second key to manage.

**Your Crevio API key is also an LLM key.** Point any OpenAI-compatible SDK at `https://ai-gateway.crevio.co/v1`, pass the key you already have, and call GPT, Claude, Gemini, Grok, or any other model in the catalog. Tokens are billed to your Crevio credit balance at the provider's list price.

There is no separate signup, no provider account, and no second key to rotate. Apps that Crevio builds and deploys for you get the endpoint wired up automatically.

## Quickstart

<CodeGroup>
  ```ts TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.CREVIO_API_KEY,
    baseURL: "https://ai-gateway.crevio.co/v1",
  });

  const completion = await client.chat.completions.create({
    model: "anthropic/claude-sonnet-5",
    messages: [{ role: "user", content: "Write a product tagline for a ceramics studio." }],
  });

  console.log(completion.choices[0].message.content);
  ```

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

  client = OpenAI(
      api_key=os.environ["CREVIO_API_KEY"],
      base_url="https://ai-gateway.crevio.co/v1",
  )

  completion = client.chat.completions.create(
      model="anthropic/claude-sonnet-5",
      messages=[{"role": "user", "content": "Write a product tagline for a ceramics studio."}],
  )
  ```

  ```bash curl theme={null}
  curl https://ai-gateway.crevio.co/v1/chat/completions \
    -H "Authorization: Bearer $CREVIO_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "anthropic/claude-sonnet-5",
      "messages": [{"role": "user", "content": "Write a product tagline for a ceramics studio."}]
    }'
  ```
</CodeGroup>

<Warning>
  **Server-side only.** The gateway spends your credits, so treat the key like any other secret. Never ship it to a browser, and never put an unauthenticated route in front of it — an open chat endpoint is a free LLM for anyone who finds it, billed to you.
</Warning>

## Inside a Crevio-built app

Apps that Crevio deploys already have `CREVIO_API_KEY` and `CREVIO_AI_GATEWAY_URL` in their environment. Nothing to configure:

```ts theme={null}
const client = new OpenAI({
  apiKey: process.env.CREVIO_API_KEY,
  baseURL: process.env.CREVIO_AI_GATEWAY_URL,
});
```

## Streaming

Set `stream: true` and read the response as you would from OpenAI. Tokens are forwarded as they arrive — the gateway adds no buffering of its own.

```ts theme={null}
const stream = await client.chat.completions.create({
  model: "openai/gpt-5.6-luna",
  messages: [{ role: "user", content: "Draft a launch email." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
```

## Models

Models are addressed as `provider/model`, the same slugs the [OpenRouter](https://openrouter.ai/models) catalog uses.

### Aliases

A slug you pin today is a slug that retires. The gateway also answers to three stable names, and Crevio repoints them as models are released and retired — an app built against an alias keeps working without a redeploy.

| Alias       | Resolves to                                                              |
| ----------- | ------------------------------------------------------------------------ |
| `automatic` | A strong general-purpose model. Use this unless you have a reason not to |
| `fast`      | The lowest-latency model, for high-volume or interactive work            |
| `smart`     | The most capable model, for reasoning and long-form output               |

```ts theme={null}
const completion = await client.chat.completions.create({
  model: "automatic",
  messages: [{ role: "user", content: "Summarise this order in one line." }],
});
```

The response's `model` field names the slug that actually served the request, and that is what the charge is recorded against.

| Model                          | Good for                             |
| ------------------------------ | ------------------------------------ |
| `anthropic/claude-sonnet-5`    | Long-form writing, careful reasoning |
| `openai/gpt-5.6-luna`          | Code and structured output           |
| `google/gemini-3.5-flash-lite` | High-volume, latency-sensitive work  |
| `z-ai/glm-5.2`                 | General purpose, low cost            |

`GET /v1/models` returns the aliases followed by the full live catalog:

```bash theme={null}
curl https://ai-gateway.crevio.co/v1/models \
  -H "Authorization: Bearer $CREVIO_API_KEY"
```

A `model` that isn't in that list is rejected with `model_not_found` rather than silently substituted.

## What it costs

Gateway usage is billed **at the provider's list price** — Crevio adds no markup on top. The cost of a request is converted to credits and deducted from your balance once the response completes, including for streamed responses.

Every request answers with your remaining balance:

```
X-Credits-Balance: 8412
```

Charges appear in your credit history as **AI gateway**, tagged with the model. See [Usage & billing](/docs/developer/guides/usage-billing) for how credits work.

<Note>
  Credits are only deducted for requests that reach a model. A rejected request — bad model, failed auth, provider error — costs nothing.
</Note>

## Limits and errors

Errors use the same envelope as the OpenAI API, so SDK error handling works unchanged:

```json theme={null}
{
  "error": {
    "message": "Account balance too low. Add credits to continue.",
    "type": "invalid_request_error",
    "code": "insufficient_credits"
  }
}
```

| Status | Code                      | Meaning                                             |
| ------ | ------------------------- | --------------------------------------------------- |
| `401`  | `authentication_required` | Missing or unrecognised API key                     |
| `400`  | `model_not_found`         | The `model` isn't in the catalog                    |
| `402`  | `insufficient_credits`    | No spendable balance — top up to continue           |
| `429`  | `daily_limit_exceeded`    | This key hit its daily spend cap                    |
| `503`  | `gateway_unavailable`     | The gateway couldn't reach its control plane; retry |

Each key carries a **daily credit cap** that bounds the damage from a leaked key or a runaway loop. Contact support if your workload needs a higher one.

Errors returned by the model provider itself — rate limits, context-length overruns, content filters — pass through unchanged, so you see the real reason rather than a rewritten one.
