Native Mode

Native Mode

Use any provider’s SDK as-is, pointed at your gateway

Native mode is the simplest way to integrate with Gateway AI. You keep using your existing provider SDK — OpenAI, Anthropic, or Google — and just change the base URL and API key. Everything else stays the same.

How it works

Your SDK sends requests to Gateway AI instead of directly to the provider. The gateway:

  1. Authenticates your proxy key
  2. Enforces your access policies (rate limits, budgets, IP allowlists, model restrictions)
  3. Replaces your proxy key with the real provider credential
  4. Forwards the request to the provider unmodified
  5. Streams the response back to you
  6. Logs the request and tracks cost

Because the request is forwarded verbatim, every feature of the provider’s API works: streaming, function calling, tool use, vision, JSON mode, and anything new they add.

Provider base URLs

ProviderSDK base_urlAuth header used upstream
OpenAIhttps://api.trygateway.ai/openai/v1Authorization: Bearer
Anthropichttps://api.trygateway.ai/anthropicx-api-key
Geminihttps://api.trygateway.ai/geminix-goog-api-key

Authentication

Pass your Gateway AI proxy key where the SDK expects the provider’s API key:

  • OpenAI SDK: api_key="sk-proxy-..." (sent as Authorization: Bearer)
  • Anthropic SDK: api_key="sk-proxy-..." (sent as x-api-key)
  • Gemini SDK / REST: api_key="sk-proxy-..." (sent as x-goog-api-key)

The gateway accepts your proxy key from any of these headers: Authorization: Bearer, x-api-key, or x-goog-api-key. It strips the key, validates it, and replaces it with the real provider API key before forwarding.

What changes in your code

Exactly two things:

  1. API key → your sk-proxy-... proxy key
  2. Base URL → your gateway URL with the provider path

Note that OpenAI’s SDK includes /v1 in its default base URL (https://api.openai.com/v1), so your gateway base URL must also include /v1 (e.g., https://api.trygateway.ai/openai/v1). Anthropic and Gemini SDKs append their API version paths automatically, so their base URLs do not need /v1.

Nothing else changes. Your prompts, parameters, streaming logic, error handling, and response parsing all stay the same.

Next steps