Skip to main content
Use a custom provider when you want the AI Gateway to call a model running on your machine, private network, or cloud GPU. Custom providers can point to self-hosted tools like Ollama, vLLM, LM Studio, or any OpenAI- or Anthropic-compatible API. You can use the same access key for your local model and for cloud providers like OpenAI, Anthropic, and Google. If your local model fails, the gateway can fall back to a cloud model in the same request.

What you’ll need

Your model server must:
  1. Expose a supported API surface, such as OpenAI Chat Completions, OpenAI Responses, or Anthropic Messages.
  2. Be reachable from the AI Gateway.
  3. Have at least one model ID configured on the provider.

Connect a local model with an internal endpoint

If your model runs on your machine or private network, expose it with an ngrok internal endpoint. For example, if your model server listens on port 11434:
Use the internal endpoint URL as the custom provider base URL.
Internal endpoints (.internal domains) are private to your ngrok account, meaning they’re not reachable from the public internet. Use the same ngrok account here and in the AI Gateway, otherwise the gateway can’t reach the endpoint.

Create a custom provider

In app.ngrok.ai:
  1. Go to Providers.
  2. Open the Custom tab.
  3. Select Add provider.
  4. Choose External URL or Local.
  5. Enter a provider ID, base URL, API format, and model IDs.
  6. Add a provider key if the upstream requires authentication.

Create a custom provider with the API

See the Providers API reference for every field.

Allow the provider on an access key

An access key without a configuration can call a custom provider as soon as you create it. If you haven’t added a provider key, the gateway sends the request without credentials. An access key with a configuration can call the provider only when the configuration’s access scope allows it. To route authenticated traffic to the provider, or to control which access keys can call it:
  1. Add a provider key if the upstream requires authentication.
  2. Create or update an access key configuration.
  3. Allow the custom provider ID.
  4. Assign the configuration to an access key.

Call the model

Use provider:model in the request.

Use a local model with cloud providers

Your app keeps one base URL and one access key for local models and cloud providers. The model value decides where each request goes: my-ollama:llama3.2 goes to your hardware, and openai:gpt-4o-mini goes to OpenAI. To try your local model first and use a cloud model as a backup, list the cloud model in models:
The gateway tries the cloud model when the request to the local model fails with a server error, a rate limit, a timeout, or a connection error. If the access key has a configuration, it must allow both providers. See Configure fallback models and what triggers failover.

URL requirements

HTTP is only allowed for ngrok .internal endpoints. External URLs must use HTTPS.

Next steps