Skip to main content

Install and Use OpenCode

OpenCode is an agentic coding tool. The tool is available as a terminal application, desktop application, and IDE extension.

AI-School recommends OpenCode mainly for teachers, administrators, and students with substantial programming experience. OpenCode can operate more autonomously than Aider and can therefore execute many changes more quickly.

For more information, see the OpenCode website and the official OpenCode documentation.

When to choose OpenCode?

Choose OpenCode if the user:

  • has experience with terminals, code editors, and git
  • understands how local files are modified
  • can review changes before they are used
  • wants to work out more complex programming tasks

For classroom teaching of programming with beginners, Aider is usually more suitable.

Installing

The simplest installation according to the OpenCode documentation is:

curl -fsSL https://opencode.ai/install | bash

You can also install OpenCode with Node.js:

npm install -g opencode-ai

Or with Homebrew on macOS and Linux:

brew install anomalyco/tap/opencode

Connecting with Coding

OpenCode supports custom OpenAI-compatible providers. Create a file opencode.json in the project folder.

Use there the Coderen endpoint and the allowed models:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ai-school-coderen": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI-School Coderen",
"options": {
"baseURL": "https://europe-west1-ai-school-pro.cloudfunctions.net/coderenOpenAiCompatibleApi/v1",
"apiKey": "{env:AI_SCHOOL_CODEREN_API_KEY}"
},
"models": {
"gpt-5.6-luna": {
"name": "GPT-5.6 Luna"
},
"gpt-5.6-terra": {
"name": "GPT-5.6 Terra"
},
"gpt-5.6-sol": {
"name": "GPT-5.6 Sol"
}
}
}
},
"model": "ai-school-coderen/gpt-5.6-luna",
"small_model": "ai-school-coderen/gpt-5.6-luna"
}

Then set the API key as an environment variable.

You can also use a .env file in the project folder:

AI_SCHOOL_CODEREN_API_KEY=ais.your-api-key

After opening a new terminal, verify that OpenCode can read this variable. If OpenCode does not send a key, AI-School will report that an Authorization header with a Bearer token is required.

macOS and Linux

export AI_SCHOOL_CODEREN_API_KEY="ais.your-api-key"

Windows

setx AI_SCHOOL_CODEREN_API_KEY "ais.your-api-key"

Then open a new terminal.

Start OpenCode

Navigate to the project folder:

cd path/to/your/project

Start OpenCode:

opencode

In OpenCode, use the model selection to choose the AI-School Coding model if it isn’t automatically selected.

Troubleshooting

Authorization header with Bearer token is required

This message usually means that OpenCode did not send an API key. Check:

  • that AI_SCHOOL_CODEREN_API_KEY is spelled exactly like that
  • that the value starts with ais.
  • that you opened a new terminal after setx
  • that the .env file is in the project folder where you start OpenCode

Unknown parameter

Some tools send extra provider-specific parameters. If you see a message like Unknown parameter, remove that setting from the OpenCode configuration or use a simpler provider configuration. The Coderen endpoint expects OpenAI-compatible chat requests with model, messages, and the usual base settings.

Safe work with OpenCode

Because OpenCode operates agentically, it’s important to review changes.

Recommended workflow:

  1. Work in a git repository.
  2. Start with small tasks.
  3. Review diffs before using code.
  4. Test the application after changes.
  5. Commit only changes you understand.

For students with little experience, it’s advisable to use OpenCode demonstratively first, under the guidance of a teacher.

WhatsApp