Skip to main content
Crusoe Support Help Center home page
Crusoe

How-To: Use Crusoe Managed Inference with OpenCode

Akram Boudhraa
Akram Boudhraa
Updated

Last Updated: April 15, 2026

Introduction

OpenCode is an open-source, terminal-based AI coding assistant. By default it connects to third-party model providers, but it supports any OpenAI-compatible API endpoint, including Crusoe Managed Inference. This guide walks you through installing OpenCode and pointing it at Crusoe so that you can run models like gpt-oss-120b directly from your terminal, using your own Crusoe API key and keeping your data within the Crusoe platform.

 

Prerequisites

  • An active Crusoe Cloud account with access to Managed Inference
  • A machine running macOS or Linux with a terminal
  • Node.js 18 or later (required by OpenCode)
  • Access to the Crusoe Cloud Console: https://console.crusoecloud.com

 

Step-by-Step Instructions

Install OpenCode

  • Run the one-liner installer in your terminal:
curl -fsSL https://opencode.ai/install | bash
  • Alternatively, install via npm:
npm install -g opencode-ai
  • Verify the installation:
opencode --version

Note:  OpenCode requires Node.js 18 or later. If installation fails, check your Node version with node --version and upgrade if needed. Visit https://nodejs.org or use nvm.

Create a Managed Inference API Key

  • Log in to the Crusoe Cloud Console
  • In the top right of the Console click the Apps option and select Intelligence Foundry
  • In the left navigation select API Keys
  • Click Create API Key in the top right
  • Give the key a name (e.g. opencode-dev) and click Create
  • Copy the key immediately — it is only displayed once

Security:  Treat this key like a password. Do not paste it directly into config files or commit it to source control. You will reference it via an environment variable in the next step.

Export Your API Key as an Environment Variable

  • Add the following line to your shell profile (~/.zshrc, ~/.bashrc, or equivalent):
export CRUSOE_API_KEY="your-api-key-here"
  • Reload your profile to apply it in the current session:
source ~/.zshrc
# or
source ~/.bashrc
  • Confirm the variable is set:
echo $CRUSOE_API_KEY

Configure OpenCode to Use Crusoe

  • Create or open the OpenCode config file at ~/.config/opencode/opencode.json
  • Add the following configuration:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openai/gpt-oss-120b",
  "provider": {
    "crusoe": {
      "name": "Crusoe Cloud",
      "options": {
        "baseURL": "https://api.inference.crusoecloud.com/v1",
        "apiKey": "{env:CRUSOE_API_KEY}"
      },
      "models": {
        "openai/gpt-oss-120b": {
          "name": "gpt-oss-120b"
        }
      }
    }
  }
}
  • model — the default model OpenCode will use
  • baseURL — the Crusoe Managed Inference endpoint
  • apiKey{env:CRUSOE_API_KEY} reads the key from your environment rather than hardcoding it
  • models — declares available models; the key is used by OpenCode internally, and name is sent to the Crusoe API

Launch OpenCode

  • Open a terminal and navigate to any project directory
  • Start OpenCode:
opencode
  • OpenCode will load your config and connect to Crusoe Managed Inference. You can select your model by typing /models.  Select `gpt-oss-120b` (or your configured default) from the models and start coding.

Example

The following shows a complete opencode.json for a developer using gpt-oss-120b as their default, with gemma4:31b also available as an alternative:

 

{
  "$schema": "https://opencode.ai/config.json",
  "model": "gpt-oss-120b",
  "provider": {
    "crusoe": {
      "name": "Crusoe Cloud",
      "options": {
        "baseURL": "https://api.inference.crusoecloud.com/v1",
        "apiKey": "{env:CRUSOE_API_KEY}"
      },
      "models": {
        "openai/gpt-oss-120b": {
          "name": "gpt-oss-120b"
        },
        "google/gemma-4-31b-it": {
          "name": "gemma-4-31b-it"
        }
      }
    }
  }
 }

 

To see all models available in your Managed Inference account, run:

curl https://api.inference.crusoecloud.com/v1/models \
-H "Authorization: Bearer $CRUSOE_API_KEY" | jq '.data[].name'

 

Troubleshooting

 

ProblemFix
401 authentication errorRun echo $CRUSOE_API_KEY to check the variable is set. Re-export the key if empty, then relaunch OpenCode.
Model not found / 404Check that the name field in your models config matches the exact model name from your Managed Inference dashboard. Names are case-sensitive.
Connection refused or timeoutConfirm the baseURL ends with a trailing slash: .../v1/. Test connectivity using the curl models command above.
opencode command not foundEnsure ~/.local/bin or the npm global bin path is in your PATH. Run which opencode — if empty, add the bin directory to PATH in your shell profile.

Related to

Was this article helpful?

0 out of 0 found this helpful

Still need help?

Our support team is ready to assist you with any questions.

Have more questions? Submit a request

Recently Viewed

Comments

0 comments

Article is closed for comments.