Connect Your Proxy Gateway to OpenCode in 15 Minutes
This guide shows you how to set up your Mycelis models and agents as a provider in OpenCode and use them directly in your coding workflow.
Prerequisites
- At least one model deployed — if not done yet: Deploy Your First Model in 5 Minutes
- Optional: A configured agent — if you want to use an agent instead of a raw deployment: Build Your First Agent in 10 Minutes
The same approach works for other OpenAI-compatible clients such as OpenClaw, LibreChat, Lobe Chat, Kilo Code, and similar tools. This guide focuses on OpenCode.
Since Mycelis is not yet natively integrated into OpenCode (we're working on it), a small manual setup is required — we'll get through it in just a few steps.
Step 1 — Create an API Key
In your dashboard, navigate to API Keys in the left sidebar.
Click Create API Key and give it a name (e.g., OpenCode). You can optionally set an expiry date.
After creation, the API key is shown once — copy it immediately and store it somewhere safe. For security reasons, it cannot be viewed again after this point.
Important: Treat your API key like a password. Never share it or commit it to public repositories.
On the API Keys page you'll also find the URLs you need for configuration:
- Gateway Endpoint — the base URL for the Proxy Gateway (used in
opencode.json) - MCP Hub Endpoint — the URL for the MCP Hub (used for MCP tool integrations)
The same API key is valid for both endpoints.
Step 2 — Install OpenCode
If OpenCode is not yet installed, follow the official installation guide: opencode.ai/docs
Step 3 — Configure opencode.json
Open (or create if it doesn't exist yet) the opencode.json file at the following location:
- macOS / Linux:
~/.config/opencode/opencode.json - Windows:
C:\Users\<Username>\AppData\Roaming\opencode\opencode.json
Add the following provider block — replace the model slugs with the actual slugs from your Mycelis workspace:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"mycelis": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://app.mycelis.ai/api/proxy/v1"
},
"models": {
"my-agent": {
"name": "my-agent"
},
"second-model": {
"name": "second-model"
}
}
}
}
}
Important notes about this configuration:
mycelisis the provider name — you can rename it freely, but it must be used consistently inauth.jsonas wellbaseURL— find the exact value on the API Keys page under Gateway Endpoint- The model key and
namemust exactly match the slug of the agent or model in Mycelis. For an agent, the slug is found under General → Slug (API Model ID) in the agent settings
You can add as many models and agents under models as you like.
Step 4 — Store the API Key in auth.json
The API key is not stored in opencode.json but in a separate auth.json file. Open or create this file at the following location:
- macOS / Linux:
~/.local/share/opencode/auth.json - Windows:
C:\Users\<Username>\AppData\Local\opencode\auth.json
Add your provider name and API key as follows:
{
"mycelis": {
"type": "api",
"key": "pat_..."
}
}
Replace pat_... with the API key you copied in Step 1. The property key (mycelis) must match the provider name in your opencode.json.
Step 5 — Use Mycelis in OpenCode
OpenCode is now configured. Start OpenCode in your project directory and select the provider:
/providers— lists all configured providers; selectmycelis/models— lists the models for the active provider; select the model or agent you want to use
All requests will now be routed through the Mycelis Proxy Gateway.
That's it!
You've successfully connected the Mycelis Proxy to OpenCode. Every request from OpenCode now runs through your configured deployment or agent — including the system prompt, Knowledge Bases, and MCP Tools if you're using an agent.
Next steps:
- Build Your First Agent — configure routing, Knowledge Bases, and MCP Tools
- MCP Tools — use external APIs directly in your model context
- API Reference — all available API parameters