Skip to main content

AI Gateway Quickstart

You adopt the AI Gateway by pointing your existing AI SDK at your agent’s gateway URL and using a phantom token as the API key. No new SDK, no code rewrite.

1. Create an agent

In the dashboard, go to AI Gateway → New gateway, then add an agent. Pick the upstream provider (Anthropic or OpenAI) and the route that injects your provider key. When the agent is created you get two things:
  • an agent URLhttps://<your-slug>.knoxcall.com/v1/ai/<agent-slug> (sandbox: https://sandbox-<your-slug>.knoxcall.com/...)
  • a phantom tokenkc_live_a_… (shown once at mint time)
The data plane is served on your tenant’s proxy subdomain (<slug>.knoxcall.com), not api.knoxcall.com. Always use the agent_url returned at agent creation as your base URL.

2. Swap your base URL

Anthropic SDK

OpenAI SDK

curl

That’s it. The call is now authenticated by the phantom token, screened by the prompt firewall, PII-redacted if a policy applies, counted against the agent’s budget, and recorded with per-call cost attribution.

3. Authentication schemes

The phantom token can be sent three ways — use whichever your SDK makes easiest:
For DPoP-bound tokens, also send a DPoP proof header on every request.

4. Streaming

Streaming works unchanged — set stream: true (or Accept: text/event-stream). PII redaction runs inside the stream, so redactions appear as the tokens arrive rather than after the response completes:

Useful request/response headers

Response caching

Set cache_mode on an agent to exact (byte-identical requests replay a saved response) or semantic (a request that means the same thing as a prior one replays it, matched by embedding similarity).
The X-KC-Conversation-Id header is the cache’s isolation boundary. Exact and semantic cache hits only ever occur within the same conversation id, so a cached response can never cross conversations. Because of this, your conversation ids must be unguessable and unique per end-user conversation — never a constant or a value one end-user could guess for another. A request with no conversation id is cached byte-exact only (never semantically), and never shares with a conversation.

Next steps

Bring your own key

Why AI features use your own Anthropic key, and how to add it.

Tokens & DPoP

Mint scoped, sender-constrained tokens for agents and CI.