SalpXXAPI News
Gateway Basics 2 min read

What is an AI API relay? The full path of one request to Claude and GPT

A relay is not just a proxy. Auth, routing, rewriting, retries, billing and logging — six gates per request. Here is why changing one base_url line is enough to switch models.

The one-sentence definition

An API relay — also called an AI model gateway — is a single ingress between your code and the model vendors. You call one domain with one key; the gateway decides which upstream actually serves the request, which upstream key it uses, and at what price it settles.

To the caller it looks like an OpenAI-SDK-compatible /v1 endpoint. To the upstream it looks like a client that picks vendors, retries, and keeps the books.

Six gates per request

  • Authentication — validate the key, group and quota, and decide whether this model is callable at all.
  • Routing — pick a channel by model name. A single claude request may have three upstreams behind it, ordered by priority and health.
  • Rewriting — translate the OpenAI-shaped body into what the upstream expects. Claude's native API authenticates with x-api-key and sends an anthropic-version header, nothing like OpenAI's Authorization: Bearer2; the gateway performs that translation.
  • Retry — on a 5xx or timeout, switch channel and try again. The client just sees a slightly slower response.
  • Billing — settle on input/output tokens, or per call for task-style models. Pre-authorise, settle, refund.
  • Logging — keep request id, latency, status code and the channel used, so incidents are traceable.

Why base_url instead of a code rewrite

Every OpenAI-compatible SDK lets you override base_url. That is the cheapest possible seam to cut along:

from openai import OpenAI

client = OpenAI(
    base_url="https://www.salpx.com/v1",
    api_key="sk-...",
)
resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello"}],
)

Request fields are identical to the official SDK1. No new library, no business-logic change, no prompt-management rewrite — one domain swap. To go back to a direct vendor connection, delete the base_url line.

The three problems a relay actually solves

Availability. A single upstream will rate-limit you, go into maintenance, or pull a model without notice. A relay puts several channels behind one model name, so a single-point failure is no longer an outage.

One bill. One provider, one bill, one billing model, and month-end reconciliation turns into a chore. A gateway folds all consumption into one quota system and can report by user, key or model.

Control. Who called what, and what it cost, in one place. For team deployments that is a hard requirement, not a nice-to-have.

When you do not need one

If you are one team, on one vendor, at a volume where direct rate limits never bite, direct is simpler. One less layer is one less failure mode.

The relay starts paying for itself the moment any of these is true: more than two models, more than three callers, per-project billing, or a requirement that upstream failures do not drop requests.

Four questions before you choose

  • When an upstream dies, does it fail over automatically — and how is that billed?
  • How is success rate computed, per request or per retry? Counting retries turns one failure into several.
  • If a model has no explicit price, does billing silently degrade to token-based and distort the invoice?
  • How long are logs kept, and can you join every retry of one call by request id?

Answer those four and most "we just forward bytes" offerings drop out.

Sources & attribution

This article references the public materials listed below. Analysis and wording are SalpX's own; quoted material remains the property of its original authors and publishers.

  1. Chat Completions — OpenAI API Reference — OpenAI · accessed 2026-11-12Note:Request-body fields and base_url usage described here follow this official reference.
  2. Messages API — Anthropic API Reference — Anthropic · accessed 2026-11-12Note:Claude's native endpoint uses different auth and version headers than OpenAI; this is the reference used for comparison.

One key for Claude, GPT and 50+ models

The SalpX gateway is OpenAI-SDK compatible. Point base_url at https://www.salpx.com/v1 and you are done.