Skip to main content

AI Gateway

Models

Use any model id from the pre.dev catalog and read credit prices from it.

The gateway serves hundreds of models from every major lab. Use the model id exactly as listed by GET /v1/models: if the catalog lists it, model: "<author>/<slug>" works here.

Example ids: anthropic/claude-sonnet-5, deepseek/deepseek-v4.1-flash-1017, google/gemini-3.8-flash, and openai/gpt-6-luna.

Some models also have variant ids in the catalog, such as a :free or :batch suffix; use them exactly as listed. Append :online to a model id to add web search, the same as the web plugin. See fallbacks and advanced options.

List models with prices

curl --fail-with-body https://api.pre.dev/v1/models \
  -H "Authorization: Bearer $PREDEV_API_KEY"

Each row describes the model (id, name, context_length, supported modalities and parameters, and so on) and carries a predev object with its prices in credits:

{
  "id": "deepseek/deepseek-v4.1-flash-1017",
  "name": "DeepSeek: DeepSeek V4.1 Flash 1017",
  "context_length": 1048576,
  "predev": {
    "credits_per_m_input": 2.5,
    "credits_per_m_output": 10
  }
}

The numbers above are illustrative; read the live row for current prices. The catalog reference lists every predev field.

The catalog refreshes every 15 minutes. The x-predev-catalog-age response header reports seconds since the last refresh. Catalog reads are free and not rate-limited.

Other catalog endpoints: /v1/models/count, /v1/embeddings/models, /v1/images/models, and /v1/videos/models. See the catalog reference.

Pick a model in code

Filter the catalog rather than hard-coding assumptions about price or context length:

const response = await fetch('https://api.pre.dev/v1/models', {
  headers: { Authorization: `Bearer ${process.env.PREDEV_API_KEY}` },
});
const { data } = await response.json();
const cheapest = data
  .filter((m: any) => m.context_length >= 128000)
  .sort((a: any, b: any) => a.predev.credits_per_m_output - b.predev.credits_per_m_output)[0];
console.log(cheapest.id, cheapest.predev);
import os
import requests

rows = requests.get(
    "https://api.pre.dev/v1/models",
    headers={"Authorization": f"Bearer {os.environ['PREDEV_API_KEY']}"},
).json()["data"]
cheapest = min(
    (m for m in rows if m["context_length"] >= 128000),
    key=lambda m: m["predev"]["credits_per_m_output"],
)
print(cheapest["id"], cheapest["predev"])

Invalid ids

An id the catalog does not serve returns a 4xx error in the OpenAI error shape. The message keeps what the model service said about the request; check the id against GET /v1/models. See errors.

Send several ids in models to fall back automatically. See fallbacks and advanced options.

Was this page helpful?

On this page