API Docs

5-Minute Migration to One OpenAI-Compatible Gateway

ToAPIs keeps the OpenAI request shape, so migration is a configuration change rather than a rewrite: swap the endpoint, issue a key, map your model names, then tune retries. This page is the reference for that path, and for routing, billing, and error handling afterwards.

OpenAI-compatible50+ Models99.9% Uptime SLA5min Migration

Quickstart

Four steps take an existing OpenAI SDK client onto the gateway. Keep your SDK version, your request bodies, and your streaming handlers.

Base URLhttps://api.toapis.com/v1
01Point your client at the gateway

Set the OpenAI base_url to https://api.toapis.com/v1. Keep the /v1 suffix and your existing SDK version so request bodies stay untouched.

02Issue a platform key

Create a key in the console, store it as an environment variable, and send it as a Bearer token in the Authorization header.

03Map your model names

Replace the model id with the ToAPIs model name from the catalog. Text, image, and video models all sit behind the same host.

04Set retry and timeout budgets

Add exponential backoff with jitter for 429 and 5xx responses, and pin a request timeout per workload class.

example.py
from openai import OpenAI client = OpenAI(    base_url="https://api.toapis.com/v1",    api_key="your-toapis-key") response = client.chat.completions.create(    model="gpt-5.6-terra",    messages=[{"role": "user", "content": "Hello!"}])

Keys and Access

One key covers every model on the gateway. Scope a key per environment instead of sharing a single key across development and production.

  1. Create a key in the console for the environment it serves (development, staging, production).
  2. Store it in your secret manager or environment file, never in client-side code.
  3. Send it on every request as Authorization: Bearer <key>.
  4. Rotate the key from the console if it leaks; a replacement key works without a redeploy.

Routing, Failover, and Fallback

Route pools keep one logical call working when a provider degrades. Choose the pool by task, then name a primary and a fallback for each pool.

One host per modality

Chat, image, and video models are addressed through the same host and the same Authorization header, so a single client reaches all of them.

Primary and fallback

Name a primary model and at least one fallback per workload, so a retryable error or a rate limit on the primary does not end the user request.

Failover on transient failures

Retry 429 and 5xx with exponential backoff, then move to the fallback model instead of surfacing the failure.

Cost-tiered routing

Send high-priority traffic to the quality tier and batch or low-priority traffic to the lower-cost tier, then reconcile consumption against the quotas on the pricing page.

Keep a fallback inside the same capability class as its primary. Swapping across classes changes output shape and quality mid-conversation.

Billing and Credits

One account, one credit balance, and one invoice across every model family on the gateway.

  • Text models are metered by token, image models per request, and video models by duration; the billing unit is stated next to each model.
  • Credits are consumed while requests are served, so you are not billed for output that was never produced.
  • Monthly and annual plans include a credit allowance for the billing period; unused subscription credits expire with that period.
  • Consumption, invoices, and payment methods live under Settings, in Billing.

Error Reference

The gateway keeps OpenAI error codes, so existing error handling keeps working.

401Invalid keyConfirm the key exists, is not revoked, and is sent as Authorization: Bearer <key>.
402 / 403No credit or no permissionConfirm the account has an active plan or a usable credit balance, then retry the request.
404Unknown modelUse a model id from the catalog verbatim. Ids that only exist at a single provider are not routable here.
429Rate limitBack off exponentially with jitter, lower concurrency, or shift traffic to the fallback model.
5xxUpstream failureRetry with backoff. If it persists, switch the pool to its fallback and send the model id to support.

Next Steps

Shortlist a model, confirm what it costs, then read the plan rules that apply to your account.

Ready to point one endpoint at 50+ models?

Change the endpoint, issue a key, then confirm cost and default routing on the pricing page.

View Pricing
API Docs: 5-Minute Migration Guide | ToAPIs