Skip to main content

The ngrok.ai API lets you manage ngrok.ai directly from your code, so you don’t have to rely on the dashboard. You can use it to create access keys, add provider keys, set up routing and access rules, register custom providers, check usage, and keep an eye on your credit balance. Note, that the API doesn’t handle model requests itself. To call models, send your requests to https://gateway.ngrok.ai using an access key.

Base URL

When you make requests to the ngrok.ai API, send them to:
https://api.ngrok.ai
Note that the ngrok.ai API uses JSON for both requests and responses, and all calls must be made over HTTPS.

Authentication

To authenticate, include your ngrok.ai API key in the Authorization header of each request:
curl https://api.ngrok.ai/access-keys \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY"
You can create and manage your ngrok.ai API key on the settings page in the dashboard. Treat this key like a secret, since it allows you to manage the resources in your account.

What you can manage

Use the AI Gateway API to manage:
  • Access keys: Manage keys for making gateway requests
  • Access key configurations: Manage access controls and rules for which providers, models, and keys an access key can use
  • Providers: Manage which providers the gateway can route to
  • Provider keys: Manage your credentials for providers
  • API keys: Manage keys that grant ngrok.ai API access
  • Configuration: Manage your account level gateway settings
  • Credits: View your credit balance and transactions
  • Usage: View data on requests, tokens, providers, models, and costs

Common workflows

Use the ngrok.ai API to automate common setup and operational tasks.

Create access keys

Create access keys for applications, environments, teams, or customers. Each access key can have its own configuration for routing, model access, and provider credentials.

Add provider keys

Store upstream provider credentials so ngrok.ai can call providers on your behalf without exposing those credentials in your application code.

Configure routing and access

Define access key configurations to control which providers and models an access key can call, and which provider keys are used for upstream authentication.

Register custom providers

Create custom providers for self-hosted models, private deployments, or other OpenAI-compatible and Anthropic-compatible APIs.

Monitor usage and credits

Query usage and credit data to track requests, tokens, costs, and remaining balance.

Next steps