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

# AI Gateway

> Call hundreds of models from every major lab through api.pre.dev/v1 with your pre.dev key and credits.

The pre.dev AI Gateway is a metered, OpenAI-compatible inference API. Point an OpenAI-compatible client at **`https://api.pre.dev/v1`**, send your pre.dev API key, and call any model in the pre.dev catalog — hundreds of models from every major lab — by the id listed in [`GET /v1/models`](/ai-gateway/api/models). Calls are paid with pre.dev credits.

<CardGroup cols={2}>
  <Card title="Quickstart" icon="play" href="/ai-gateway/quickstart">
    First request with curl, the OpenAI SDK, the Vercel AI SDK, or the Anthropic SDK.
  </Card>

  <Card title="API key" icon="key" href="/ai-gateway/api-key">
    Where the key lives, which headers carry it, and how it reaches your deployed app.
  </Card>

  <Card title="Pricing" icon="coins" href="/ai-gateway/pricing">
    Credits per call, the trial allowance, and what happens when credits run out.
  </Card>

  <Card title="Models" icon="list" href="/ai-gateway/models">
    Browse the catalog with credit prices attached.
  </Card>
</CardGroup>

## What you send

Model ids are `<author>/<slug>` strings exactly as listed by [`GET /v1/models`](/ai-gateway/api/models), for example `anthropic/claude-sonnet-5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3.8-flash`, or `openai/gpt-5.6-luna`. There are no separate pre.dev-specific model names. Variant suffixes such as `:free`, `:nitro`, `:online`, and `:batch` are accepted.

The standard chat completion fields (`messages`, `temperature`, `max_tokens`, `stop`, and so on) work as you would expect. On top of those, the pre.dev AI API supports these advanced options, described on [routing and fallbacks](/ai-gateway/routing-and-fallbacks):

| Field                                         | Purpose                                                                                 |
| --------------------------------------------- | --------------------------------------------------------------------------------------- |
| `models`, `route`                             | Fallback model list and routing                                                         |
| `provider`                                    | Provider preferences: `order`, `sort`, `ignore`, `only`, `max_price`, `data_collection` |
| `transforms`                                  | Prompt transforms                                                                       |
| `reasoning`, `reasoning_effort`               | Reasoning controls                                                                      |
| `plugins`                                     | `web`, `file-parser`, `response-healing`, `context-compression`                         |
| `web_search_options`                          | Web search settings                                                                     |
| `response_format`, `structured_outputs`       | JSON and schema-constrained output                                                      |
| `tools`, `tool_choice`, `parallel_tool_calls` | Tool calling                                                                            |
| `prediction`, `verbosity`, `session_id`       | Predicted outputs, verbosity, session grouping                                          |
| `stream`                                      | Server-sent event streaming                                                             |

## What the gateway changes

The gateway edits four things and nothing else:

1. Replaces your pre.dev key with pre.dev's own model-provider credentials.
2. Sets `stream_options.include_usage` on streaming chat completions, so the final chunk carries `usage.cost`.
3. Sets, or prefixes, the `user` field with a workspace hash for abuse attribution.
4. Adds attribution headers.

Request and response bodies are otherwise the standard OpenAI-compatible shapes, and the Anthropic Messages shape on `/v1/messages`.

## Endpoints

| Method            | Path                                                                                                                                                         | Reference                                            |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| POST              | `/v1/chat/completions`, `/v1/completions`, `/v1/responses`                                                                                                   | [Chat completions](/ai-gateway/api/chat-completions) |
| POST              | `/v1/messages`                                                                                                                                               | [Messages](/ai-gateway/api/messages)                 |
| POST              | `/v1/embeddings`, `/v1/rerank`                                                                                                                               | [Embeddings and rerank](/ai-gateway/api/embeddings)  |
| POST, GET         | `/v1/images`, `/v1/videos`, `/v1/videos/{jobId}`, `/v1/videos/{jobId}/content`                                                                               | [Images and video](/ai-gateway/api/images-and-video) |
| POST              | `/v1/audio/speech`, `/v1/audio/transcriptions`                                                                                                               | [Audio](/ai-gateway/api/audio)                       |
| POST, GET, DELETE | `/v1/files`, `/v1/files/{id}`, `/v1/files/{id}/content`                                                                                                      | [Files](/ai-gateway/api/files)                       |
| GET               | `/v1/models`, `/v1/models/count`, `/v1/models/{author}/{slug}/endpoints`, `/v1/embeddings/models`, `/v1/images/models`, `/v1/videos/models`, `/v1/providers` | [Model catalog](/ai-gateway/api/models)              |
| GET               | `/v1/usage`, `/v1/generation`                                                                                                                                | [Usage](/ai-gateway/api/usage)                       |

## Response headers

Every inference call returns `x-predev-request-id` (`pdr_…`), `x-predev-credits-charged`, and `x-predev-credits-remaining` (omitted on unlimited plans). Send `x-predev-project-id` to attribute usage to one of your projects. See [usage](/ai-gateway/api/usage).

## Billing in one line

1 credit = \$0.10. Each call is charged in credits based on the model's metered cost for that call, reported in `usage.cost`; the credit price per model is listed on [`GET /v1/models`](/ai-gateway/api/models) under `predev.credits_per_m_input` and `predev.credits_per_m_output`. Catalog reads are free. Details and the trial rule are on [pricing](/ai-gateway/pricing).
