gateway.ngrok.ai that accepts OpenAI, Anthropic, and Gemini API requests, so your apps keep the SDKs they use today.
ngrok hosts and upgrades it, and its price is public: a processing fee of $0.05 per million tokens, paid from credits.
Pay for OpenAI, Anthropic, Google, and other supported models with those credits, or bring your own provider key for any built-in provider.
For agent traffic, Firewall checks each tool call a model returns and blocks risky ones before your agent runs them.
The ngrok AI Gateway doesn’t yet have a built-in Vertex AI provider, an MCP gateway, response caching, per-key budgets, or PII redaction.
It reaches Claude on Amazon Bedrock through the Anthropic and AWS SDKs, but not through OpenAI Chat Completions.
If your apps depend on those Portkey features, read the list of features without an equivalent yet before you decide.
model string.
What you’ll need
- Your Portkey account, with an Admin API key or Workspace API key that can read configs, providers, guardrails, and API keys.
- An ngrok.ai account at app.ngrok.ai with credits.
- An AI Gateway API key, if you want to script the setup instead of using the dashboard.
- The source code of the apps you’re moving.
Inventory your Portkey setup
Portkey splits its setup between your code and its dashboard.
A default config attached to an API key can route every request without any trace of it in your code, so check both places.Each match tells you what to change:Each file maps to something you create in ngrok.ai:
Search your code
Search your repositories for the strings that tie them to Portkey:Export your Portkey objects
Save the objects that hold your routing and credentials with the Portkey Admin API. Run this once for each Portkey workspace, with an API key for that workspace:In
portkey-api-keys.json, check each key’s defaults.config_id.
A key with a default config routes every request through that config, even when the app’s code never mentions it.If you manage Portkey with its Terraform provider, your state file already holds all of these.Add your provider keys
Each Portkey AI Provider, such as Name each key after its Portkey slug so you can match them up later.You don’t need a provider key for every provider.
For OpenAI, Anthropic, Google, xAI, and other providers that support it, skip the provider key and pay with credits.If you used several Portkey providers for the same upstream, such as two OpenAI keys for more rate-limit headroom, add both keys.
You order them in the next step.A
@openai-prod, holds one provider credential.
Add each credential as a provider key in ngrok.ai, on the Providers page or with the API:Amazon Bedrock
In Portkey, each Bedrock provider covers one AWS region, such as@bedrock-us-east-1 and @bedrock-us-west-2.
In ngrok.ai, each Bedrock provider key covers one region, so add one key for each region you use.ngrok.ai authenticates to Bedrock with a Bedrock API key.
If your Portkey Bedrock providers use IAM access keys or an assumed role, generate a long-term Bedrock API key in each AWS account first, as described in Amazon Bedrock.
Bedrock always uses your own key; you can’t pay for it with credits.A key you add in the dashboard uses us-east-1.
To add a key for another region, set aws.region with the API:us. model ID from Portkey, such as us.anthropic.claude-haiku-4-5-20251001-v1:0, works with a key in any region, because the key’s region decides where the request goes.
When the model doesn’t run in that region, the gateway uses the inference profile for the region’s geography.
A key in eu-west-1 keeps the request in the EU.
See Regions.Providers that aren’t built in
Connect any OpenAI- or Anthropic-compatible endpoint as a custom provider. For Azure OpenAI, follow the Azure OpenAI guide, with one custom provider per deployment or region. Vertex AI isn’t a built-in provider yet; see Features without an equivalent yet.Recreate your API keys
In Portkey, a workspace groups API keys, providers, and configs for one team.
ngrok.ai has no workspace layer.
Give each team or app its own access key, and use an access key configuration to control what that key can call.When the first OpenAI key hits a rate limit or an auth error, the gateway tries the second.
See Multi-key failover.Put your regional Bedrock keys in one
- On Keys → Configurations, create one configuration for each Portkey workspace or API key that had its own provider access.
- Under Access, allow only the providers and models that team used.
- Under Routing, add a rule for each provider: choose Bring your own API key and attach the provider keys from the previous step in the order to try them, or choose ngrok to pay with credits.
- Create one access key for each Portkey API key you’re replacing, and assign its configuration.
bedrock rule the same way, in the order to try their regions.
A rate limit in one region moves the request to the next region’s key.
A server error or timeout doesn’t: it skips your other Bedrock keys and moves to the next model.
If a Portkey config fails over between Bedrock regions during an outage, list a model on another provider after the Bedrock model in a virtual model, as in Try Amazon Bedrock before Anthropic.app.ngrok.ai shows each access key token once, when you create it.
Store each token, which starts with ng-, where the app reads its Portkey key today.Turn fallback configs into virtual models
A Portkey config with Create the equivalent virtual model:Apps then send
"mode": "fallback" becomes a virtual model: a name your apps send as model, which stands for an ordered list of models.This Portkey config tries OpenAI, then Anthropic:Portkey config
"model": "chat-default".
To change the models later, edit the virtual model; apps don’t change.Some config fields work differently:Recreate guardrails with Firewall
Firewall checks what an app sends to a model and each tool call the model returns.
It covers some of what Portkey guardrails do:
Attach a policy to the access key configuration for each team, or apply it to every key as your baseline.
Start in dry run mode to see what it would block on real traffic.
See Guard agent tool calls with Firewall.Blocks look different to your app.
Portkey returns HTTP
446 when a guardrail denies a request.
Firewall returns HTTP 200 with an assistant message that explains the block and a safeguard_results field, so the model or agent can continue.
Update any error handling that checks for 246 or 446.Change your client code
Your apps keep their OpenAI or Anthropic SDK.
Change the base URL, the key, and the The routing that Calls that only exist in the Portkey SDK, such as Replace The
model string, and remove Portkey headers.OpenAI SDK with a Portkey key
OpenAI SDK with createHeaders
Apps that pass Portkey settings throughcreateHeaders send a provider key or a placeholder as api_key.
Replace it with your access key and drop the headers.virtualKey and config did now lives in the access key’s configuration and in the virtual model your app sends as model.Portkey SDK
ReplacePortkey with the OpenAI client.
Portkey accepts the same calls as the OpenAI SDK, so client.chat.completions.create(...) calls don’t change.portkey.prompts.completions.create and portkey.feedback, have no equivalent.Anthropic SDK
@slug/claude-… model names the same way as for the OpenAI SDK.
The Google Gen AI SDK follows the same pattern; see Google Gen AI SDK.Models on Amazon Bedrock
Portkey translates OpenAI Chat Completions requests for any Bedrock model. The ngrok AI Gateway doesn’t translate them for Claude or most other Bedrock models yet, so apps that reach Bedrock through the OpenAI SDK switch SDKs as well as base URLs:This example moves an app’s calls to Claude Haiku 4.5 on Bedrock from the OpenAI SDK to the Anthropic SDK:
bedrock: prefix keeps the request on Bedrock.
Without it, anthropic/claude-haiku-4-5 goes to Anthropic first.
To try Bedrock first and fall back to Anthropic, list both in a virtual model; see Try Amazon Bedrock before Anthropic.For the AWS SDK, point the client’s endpoint_url at https://gateway.ngrok.ai and set AWS_BEARER_TOKEN_BEDROCK to your ngrok.ai access key, the token that starts with ng-.
See Native Bedrock requests.Map model names
The gateway picks the provider key from the access key’s configuration, not from the model string.
See Choose a model.
Run both gateways and cut over
Before you move an app, send one request with its new access key and read the headers:
ngrok-aig-model names the model that answered, the first one in chat-default here, and ngrok-aig-attempts counts the upstream attempts the gateway made.
An error names what blocked the request, such as a provider the key’s configuration doesn’t allow; see Error codes.Then move traffic over:- Point one app, or one environment of it, at ngrok.ai and leave the rest on Portkey.
- Check each response’s
Ngrok-AIG-Modelheader to confirm the model you expect answered, andNgrok-AIG-Removed-Paramsfor request fields a provider didn’t accept. - Compare cost and token counts on the Activity page, or with the Usage API, against your Portkey logs.
- Move the remaining apps.
- Revoke the Portkey API keys once their traffic stops.
model values.Log each response’s Ngrok-AIG-Request-Id in your app.
It’s how you look up a request later; see Why a request failed over.Map Portkey headers
ngrok.ai doesn’t readx-portkey-* headers.
Remove them, or replace them as follows:
Features without an equivalent yet
Next steps
- Virtual models: Change models for every app without changing code.
- Access key configurations: Control what each key can call.
- Firewall: Check requests and tool calls.
- Handle gateway errors: Learn which failures the gateway retries.
- AI Gateway API: Automate the setup in this guide.