Relay365Multi-model API relay desk
← All desk bulletins
Agent shift notesEN655 desk reads

OpenCode: Multiple Model Providers, One Key

Using several model providers in a coding assistant does not have to mean maintaining separate API keys and billing accounts. OpenCode supports custom providers, so you can connect it to a relay and select models through one integration. This walkthrough uses Relay365, a pay-as-you-go relay desk for multiple model families, as the shared connection.

#1 · Understand what the shared key changes

Your Relay365 key authenticates requests to the relay, rather than directly to each underlying provider. OpenCode sends a model identifier with each request, and the relay routes it accordingly. That centralizes credentials, but it does not make every model identical: pricing, context limits, tool support, and availability can differ.

Relay365 fits when you want to compare models or change your coding assistant’s default without maintaining several direct integrations. Before proceeding, confirm that the models you want are available through its OpenAI-compatible interface.

#2 · Prepare OpenCode and your credentials

Install OpenCode using its official installation instructions, then open a terminal in a small test project. You will need a Relay365 API key and sufficient account balance before making requests. Keep that key out of source control, screenshots, and shared configuration files.

Store the key in an environment variable. In a macOS or Linux shell, run: export RELAY365_API_KEY='your-key'. In PowerShell, use: $env:RELAY365_API_KEY='your-key'. Replace the placeholder locally. These commands apply to the current shell session; launch OpenCode from that same session.

#3 · Find the exact model identifiers

Choose one model for the first test, such as Claude Sonnet 5.5 or GPT-6.1 Sol. Copy its exact API model identifier from Relay365’s current model listing or documentation. A display name is not necessarily the string the API expects, so do not construct an identifier from the name.

Also check the model’s current price and whether its relay route supports tool calling. Tool support matters because OpenCode needs more than text generation to inspect files, propose edits, and run development workflows.

#4 · Add a custom provider in OpenCode

Create an opencode.json file in your test project, or merge a provider entry into your existing configuration. The following configuration uses OpenCode’s OpenAI-compatible provider package. Replace MODEL_ID_FROM_RELAY365 with the identifier you copied:

{ "provider": { "relay365": { "npm": "@ai-sdk/openai-compatible", "name": "Relay365", "options": { "baseURL": "https://api.api365relay.com/v1", "apiKey": "{env:RELAY365_API_KEY}" }, "models": { "MODEL_ID_FROM_RELAY365": { "name": "My relay model" } } } } }

Relay365’s API base is https://api.api365relay.com. OpenAI-compatible clients use the /v1 suffix, which is why it appears here. The environment-variable reference keeps the credential itself outside the configuration file.

#5 · Run a small, low-risk test

Start OpenCode with opencode --model relay365/MODEL_ID_FROM_RELAY365, substituting the same identifier used in your configuration. Ask it to summarize a small source file first. Then try a narrowly scoped edit, reviewing any requested permissions and the resulting diff.

If authentication fails, check that the environment variable is available in the launching shell. If the model is not found, verify its identifier and account access. If ordinary chat works but tools fail, investigate that route’s tool-calling support rather than assuming the connection is fully compatible.

#6 · Add a second model and compare deliberately

Add another entry under models, using its exact identifier, then select it with the same provider/model command pattern. Compare both models on a repeatable task: explaining a function, proposing a test, or fixing a small bug. Review output quality, latency, and actual charges rather than assuming one model is always the best choice.

If this shared-key workflow suits your needs, create a Relay365 account and begin with a small usage budget. Check its data-handling terms before sending proprietary code, and remember that one shared credential also makes secure storage and prompt rotation especially important.

Further desk bulletins

Curious how it runs on your own code? Sign up →