aigwdocs

Quickstart

aigw is an OpenAI-compatible, governed AI gateway: point any OpenAI SDK at one base URL, use a virtual key, and reach every model behind a single contract - with per-key budgets, DLP, and a full audit log.

Zero to your first completion in three steps. Everything past step 1 is copy-paste, then governance is a 60-second add-on.

1. Get a key

Virtual keys are created in the console (you need a browser once for the magic-link sign-in):

  1. console.aigw.app → sign in.
  2. API keys → New key.
  3. Set a monthly budget (in cents) and, optionally, an allow-list of models.
  4. Copy the aigw_… secret - it’s shown exactly once.

A virtual key is not a provider key. It’s your key, scoped and capped by you; aigw resolves it to the right upstream provider on each request.

2. Point your OpenAI client here

The base URL is https://gateway.aigw.app/v1 (or your own gateway host). Use the virtual key as the bearer. Any OpenAI-compatible SDK works unchanged - only base_url and api_key change.

curl:

curl https://gateway.aigw.app/v1/chat/completions \
  -H "Authorization: Bearer aigw_…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt",
    "messages": [{"role": "user", "content": "Hello from aigw"}]
  }'

OpenAI Python SDK:

from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.aigw.app/v1",
    api_key="aigw_…",
)

resp = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Hello from aigw"}],
)
print(resp.choices[0].message.content)

OpenAI Node SDK:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://gateway.aigw.app/v1",
  apiKey: "aigw_…",
});

const resp = await client.chat.completions.create({
  model: "gpt",
  messages: [{ role: "user", content: "Hello from aigw" }],
});
console.log(resp.choices[0].message.content);

That is the whole integration. Streaming, embeddings (POST /v1/embeddings), and the model list (GET /v1/models) all work the same way.

3. Switch models without changing code

Change the model string to route to a different provider. The same request shape reaches OpenAI-, Anthropic-, and OpenAI-compatible providers - aigw translates as needed.

resp = client.chat.completions.create(
    model="mistral-large",        # was claude-sonnet-4-6
    messages=[{"role": "user", "content": "Same code, different model."}],
)

Add governance in 60 seconds

Everything above already runs through per-key budgets, DLP redaction, and a sealed audit log. To govern what your agents may do, add these in the console - each takes about a minute:

See the full walkthrough in agentic governance - tools & A2A.

What happens on every request

  1. Your virtual key is authenticated and rate-limited.
  2. The model allow-list and monthly budget are enforced - over budget returns 402.
  3. DLP redacts configured PII before the request leaves your tenant.
  4. Any tool or agent call is checked against your policy (allow / deny / approve).
  5. The request is forwarded to the best healthy provider (with automatic failover + retries) and metered.
  6. A sealed record lands in your audit log.

Next