Skip to main content
Some coding agents let you replace their built-in model with any OpenAI-compatible endpoint. Point one at https://gateway.ngrok.ai/v1 and it can call a self-hosted model on your own machine, a hosted GPU, or anywhere else it can run.

What you’ll need

Getting started

1

Register your model with the gateway

Expose your model server with an ngrok internal endpoint. For a server listening on port 11434:
Create a custom provider in app.ngrok.ai:
  1. Go to Providers and open the Custom tab.
  2. Select Add provider.
  3. Enter a provider ID, the base URL, the API format, and your model IDs.
  4. Add a provider key if the upstream requires authentication.
For the full setup, including the API method and URL requirements, see Use a model you run yourself or the specific Ollama, LM Studio, and vLLM guides.
2

Connect your agent

Every agent below needs the same three values:
OpenCode is a terminal coding agent.Add the gateway as a provider in ~/.config/opencode/opencode.json, or in an opencode.json beside your project:
Replace these required fields:
  • apiKey with your ngrok.ai access key
  • Keys in the models field with your full provider:model name and display-friendly name
Then test it with a prompt, replacing ngrok/ollama:llama3.2 with your model:
Double-check that your self-hosted model served the request with AI Gateway observability in app.ngrok.ai.

Next steps