Set Up OpenCode with the RC LLM API
Level: Beginner · Time: 15–20 min · Category: How-to
Tags: OpenCode · AI coding assistant · Custom Provider
OpenCode is a free AI coding assistant. You describe what you want in plain English, and it reads your project, writes and edits files, and runs commands for you. This guide connects OpenCode to the Research Computing LLM gateway so it uses your RC API key and the models available to your account.
This page assumes no prior setup. If a step already applies to you, skip it.
Getting Started with AI covers this setup plus everything around it — choosing a tool, the Voyager config generator, agents, the RC skills library, and the prompting habits that make locally hosted models work well. This page is the detailed OpenCode reference.
New to this? What is an "AI coding assistant"?
An AI coding assistant is a program that talks to a large language model (LLM) and can act on your project — creating files, editing code, and running commands — based on instructions you type in plain language. OpenCode is one such assistant. It does not include a model of its own; you point it at a model provider. Here, that provider is the Research Computing LLM gateway.
What you will do
- Get your RC API key and a model ID from the portal.
- Install OpenCode.
- Store your API key as an environment variable so it stays out of your files.
- Add the RC gateway as a provider so OpenCode knows the endpoint and models.
- Open OpenCode (desktop app or terminal), select an RC model, and send a test message.
If you only want to try OpenCode, there is a shorter path that needs no API key: sign in with your ASU account, below.
Quickest path: sign in with your ASU account
Voyager can install OpenCode with a plugin that signs in with your ASU account, so you need no API key and no config file. Run the installer for your system. The Download opencode button in Voyager, under AI LLM → OpenCode, shows the same commands.
- macOS / Linux
- Windows (PowerShell)
curl -fsSL https://voyager.rc.asu.edu/install | bash
irm https://voyager.rc.asu.edu/install | iex
The script installs OpenCode if it is missing (on Windows with Scoop, Chocolatey, or npm, whichever it
finds first, asking you to install Node.js if it finds none) and saves the plugin as ~/.config/opencode/plugins/voyager.ts. It does not create or
change opencode.json. Then:
- Run
opencode auth loginand choose ASU Voyager. - Open the link OpenCode shows (Voyager's Authorize a CLI device page), enter the code if asked, check that the device is yours, and click Approve. The terminal finishes signing in on its own.
- Run
opencode. The default model is Auto under ASU Voyager (voyager/auto), which picks a model for each request.
Each signed-in computer is listed in Voyager under AI LLM → OpenCode → Signed-in computers,
and on the Keys tab under OpenCode sign-ins. Log out cuts a computer off within 15 minutes. A
sign-in lasts up to 90 days, or 30 days without use; after that, run opencode auth login again.
This path has two limits. OpenCode renews the sign-in through Voyager every 15 minutes, so it works only on the ASU network or the VPN. It also sets up only the Auto model, without the model list and agents that a Voyager-generated config gives you. For either of those, and for any tool other than OpenCode, use an API key as described in the rest of this page.
1. Get your API key and a model ID
OpenCode needs two values from the portal before anything else.
- In the Voyager portal, open your profile's Keys tab and click Create API key. The full key is shown only once, so copy it then. The LLM API Guide has more on keys.
- In Voyager, open AI LLM → LLMs and copy one model ID available to your account
(for example
muse-glimmer-30b). You will use it in the provider config below. Choose one with the Tools badge — without tool calling, OpenCode cannot edit files.
Keep the key somewhere safe for the next step. Treat it like a password — never paste it into shared files, screenshots, or Git.
2. Install OpenCode
Pick your operating system. The curl and package-manager installers below do not require
Node.js.
- macOS / Linux
- Windows
The one-line installer works on both:
curl -fsSL https://opencode.ai/install | bash
Or, if you use a package manager:
# macOS (Homebrew)
brew install anomalyco/tap/opencode
# Arch Linux
sudo pacman -S opencode
Windows has two routes to PowerShell in the Start menu: Terminal and PowerShell. Opening Terminal will usually open PowerShell in your user files, while opening PowerShell will open it in system files.
Windows also has package managers, and we specifically note Scoop and Chocolatey as options. These enable installation of software through PowerShell. Either will work, though Scoop is easier to install.
Once you have either installed, continue in PowerShell:
# Scoop
scoop install opencode
# or Chocolatey
choco install opencode
Confirm it installed. This should print a version number:
opencode --version
Fully quit and reopen your terminal so it picks up the newly installed command, then run
opencode --version again. Prefer to install with npm instead? Run
npm install -g opencode-ai — but that route needs Node.js, so set up
Node.js first.
3. Understand the two pieces you are about to set up
Connecting OpenCode to RC takes two pieces that work together — not one or the other:
- A provider config — a small JSON file that tells OpenCode where the RC gateway is
(
https://openai.rc.asu.edu/v1) and which models exist. Without it, OpenCode has no idea RC exists. - Your API key — the secret that proves the request is yours. The config file references the key from an environment variable so your secret never sits inside the file itself.
You need both. The next two steps set up one each.
4. Store your API key as an environment variable
An environment variable is a named value your shell hands to every program it launches. Storing the key here keeps it out of your project files.
This page names the variable ASU_AIR_API_KEY, because that is the name a Voyager-generated
opencode.json reads by default.
OPENAI_API_KEY?If you followed Getting Started with AI,
your key is already in OPENAI_API_KEY. Instead of pasting the key again, add
export ASU_AIR_API_KEY="$OPENAI_API_KEY" below that line (on Windows, run
[Environment]::SetEnvironmentVariable("ASU_AIR_API_KEY", $env:OPENAI_API_KEY, "User")). Or keep one
variable and write {env:OPENAI_API_KEY} in the config in step 5; in Voyager's generator, type
OPENAI_API_KEY into Variable that holds the key.
- macOS / Linux
- Windows (PowerShell)
Open your shell's startup file in a text editor so it is set every time you open a terminal — use
~/.zshrc on macOS (the default shell is zsh) or ~/.bashrc on most Linux systems:
nano ~/.zshrc # macOS; use ~/.bashrc on most Linux systems
Add this line at the bottom, pasting your key between the quotes, then save and exit (Ctrl+O, Enter, Ctrl+X in nano):
export ASU_AIR_API_KEY="paste-your-key-here"
Editing the file, rather than echoing the line into it, keeps the key out of your shell history.
Now source the file. Sourcing re-reads it into your current terminal, so you do not have to close and reopen it:
source ~/.zshrc
What does "source" mean, and why do I need it?
Your shell only reads ~/.zshrc (or ~/.bashrc) once, when a
terminal first opens. Editing the file afterward does not change terminals that are already
open. source ~/.zshrc re-runs the file in your current terminal so the new
export takes effect immediately. New terminals you open later pick it up
automatically.
Confirm it is set (this should print your key):
echo $ASU_AIR_API_KEY
This prompts you to paste the key, then stores it permanently for your user account. Using a prompt rather than typing the key into the command keeps it out of your PowerShell history:
[Environment]::SetEnvironmentVariable("ASU_AIR_API_KEY", (Read-Host "Paste your key"), "User")
Then close and reopen PowerShell — the value only reaches terminals opened after it is set. Confirm it is set (this should print your key):
echo $env:ASU_AIR_API_KEY
Because the key lives in an environment variable, it never needs to appear in your project. Do not paste it into code, commit it, or share a screenshot that shows it.
Bear in mind that anything you type at a prompt is written to your shell history in plain text —
~/.zsh_history, ~/.bash_history, or PowerShell's
ConsoleHost_history.txt. Keep the key out of commands as well as files. If it ends
up somewhere it should not, regenerate it in the portal; rotating a key invalidates the exposed
one.
5. Add the RC gateway as a provider
OpenCode reads its settings from ~/.config/opencode/opencode.json (macOS/Linux) or
%USERPROFILE%\.config\opencode\opencode.json (Windows). This is the global config, so RC is
available in every project.
The Voyager portal → AI LLM →
OpenCode tab builds this file for you in four steps (Starting
point, Models, Agents, Get the file),
with the endpoint and your real model list already filled in, plus agent roles, thinking levels,
and tool permissions. On Get the file, keep From your environment
for the API key so your secret stays out of the file: the file then reads
{env:ASU_AIR_API_KEY}, the variable from step 4. Then use
Download opencode.json or Copy to clipboard and save it to the
path above. The walkthrough is in
Getting Started with AI.
The manual version below is here so you understand what the generator produces.
To write it by hand, paste the following and replace the model IDs with real ones from your Voyager model list:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"asu": {
"npm": "@ai-sdk/openai-compatible",
"name": "ASU Air",
"options": {
"baseURL": "https://openai.rc.asu.edu/v1",
"apiKey": "{env:ASU_AIR_API_KEY}"
},
"models": {
"muse-glimmer-30b": { "name": "muse-glimmer-30b" },
"devstral2-123b": { "name": "devstral2-123b" }
}
}
},
"model": "asu/muse-glimmer-30b"
}
What each part does:
provider.asu— the short ID for this provider. Agents and themodelfield reference models asasu/model-id, so if you change this key you must change those references too. The Voyager generator usesasu.name— the display label in the model picker. The generator uses "ASU Air".npm: "@ai-sdk/openai-compatible"— the adapter for any OpenAI-compatible gateway like RC. Leave this exactly as shown.options.baseURL— the RC gateway endpoint. Already correct; do not change it.options.apiKey: "{env:ASU_AIR_API_KEY}"— reads the key from the environment variable you set in step 4. The{env:...}syntax keeps the secret out of this file.models— the model IDs your key can use. Each key must match a model ID from the portal exactly; thenameis just a friendly label. Add or remove entries to match your account. Pick at least one with the Tools badge, or OpenCode will not be able to edit files. The generator also gives each model that takes a reasoning level avariantsblock, for example"high": { "reasoningEffort": "high" }, so you can step through the levels with Ctrl+T in a session.model— the default model, written asprovider-id/model-id. Optional, but it saves you from picking one every time.
If the ~/.config/opencode/ folder does not exist yet, create it first:
mkdir -p ~/.config/opencode (macOS/Linux). Then create
opencode.json inside it with the content above.
6. Open OpenCode and select an RC model
OpenCode has two interfaces that use the same config and key you just set up. Use whichever you prefer — they are fully equivalent for this tutorial.
- Desktop app (visual)
- Terminal (TUI)
The desktop app is the most approachable if you are new to the terminal.
- Install the OpenCode desktop app from opencode.ai and open it.
- Click
Default Projectto open the projects menu and make a new one instead, at the directory of your choosing. - Open the model picker and choose a model under ASU Air. Make sure you pick one with the Tools badge, or OpenCode will not be able to edit files.
- Type a message in the chat box and send it (see step 7).
The app reads the same ~/.config/opencode/opencode.json from step 5 — make sure you
saved it, then fully quit and reopen the app so it reloads the config. If a model returns an
authentication error, the app may not see your shell's environment variable; in that case run
opencode auth login once in a terminal, choose the ASU Air
provider, and paste your key. That stores the key in OpenCode's own auth
store, which both interfaces can use.
The terminal interface (a "TUI", or text user interface) runs entirely in your terminal.
-
Move into a project folder (any folder works for a first test):
mkdir opencode-testcd opencode-test -
Start OpenCode:
opencode -
Open the model list with the
/modelscommand (type it and press Enter), then choose a model under ASU Air. If you set themodeldefault in step 5, it is already selected. -
Type a message at the prompt and press Enter (see step 7).
Quit OpenCode (press Esc then type /exit) and restart it so it reloads
opencode.json. Confirm your key is set with echo $ASU_AIR_API_KEY — if
it prints nothing, redo step 4 and remember to source your shell file.
7. Send a test message
With an RC model selected, send a harmless prompt to confirm the whole chain works:
Reply with exactly: OpenCode is connected to ASU Air.
A normal reply — with no authentication, provider, or model-not-found error — means OpenCode is talking to the RC gateway with your key. You are ready to build.
A good next prompt, once connected:
Look at the files in this folder and summarize what this project does. Do not edit anything yet.
Troubleshooting
opencode: command not found— quit and reopen your terminal after installing. If you installed vianpm, confirm Node.js is set up (node --version).- Authentication failed / 401 — your key is wrong, expired, or not visible to OpenCode. Confirm
echo $ASU_AIR_API_KEY(macOS/Linux) orecho $env:ASU_AIR_API_KEY(Windows) prints your key, then restart OpenCode. In the desktop app, useopencode auth loginas described in step 6. - No RC provider or models in the picker — the config was not loaded. Re-check the path and JSON in step 5, then fully restart OpenCode (config changes need a restart).
- Model not found — a model ID in
opencode.jsondoes not match the portal. Copy the exact ID from the model list and update themodelsblock. - Key works in
curlbut not OpenCode — the environment variable is not set in the session that launched OpenCode. Re-run step 4,sourceyour shell file, and start OpenCode from that same terminal. For the desktop app, preferopencode auth login.
Related guides
- LLM API Guide — create a key, find model IDs, and test the endpoint directly.
- Connect VS Code to the RC API — prefer VS Code Chat? Use BYOK instead.
- Create a Basic Lab Web Portal — put OpenCode to work on a real beginner project.