What you’ll need
- OpenCode installed.
- An access key from app.ngrok.ai.
Add the gateway as a provider
Export your access key so OpenCode can read it:~/.config/opencode/opencode.json, or in an opencode.json beside your project:
models is the model name OpenCode sends to the gateway.
Use any model ID from the model catalog, or provider:model to pin a provider.
The limit values are optional, but they let OpenCode track how much context is left.
Test the connection
Start OpenCode, run/models, and pick one of the models under ngrok AI Gateway.
Or send a single prompt from the command line:
-m value is your provider ID, a slash, then the model key from opencode.json.
Confirm the request in AI Gateway observability in app.ngrok.ai.
Use a model you run yourself
To reach a model on your own machine, register it as a custom provider, then add itsprovider:model name to models, such as ollama:llama3.2.
See Use a model you run yourself for the full setup.
Next steps
- Restrict providers and models: Scope what an access key can call
- Configure fallback models: Try another model when the first one fails
- Observability: See which model served each request