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 a lot of programming experience. OpenCode can work more independently than Aider and can therefore make many changes faster.

More information is available on the OpenCode website and in the official OpenCode documentation.

When should you choose OpenCode?

Choose OpenCode if the user:

  • has experience with terminal, code editors and git
  • understands how local files are modified
  • can check changes before using them
  • wants to work through more complex programming tasks

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

Install

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

Connect to Coding

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

Use the Coding endpoint and the allowed models:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ai-school-coderen": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI-School Coding",
"options": {
"baseURL": "https://europe-west1-ai-school-pro.cloudfunctions.net/coderenOpenAiCompatibleApi/v1",
"apiKey": "{env:AI_SCHOOL_CODEREN_API_KEY}"
},
"models": {
"gpt-5.4-mini": {
"name": "GPT-5.4 mini"
},
"gpt-5.4": {
"name": "GPT-5.4"
},
"gpt-5.5": {
"name": "GPT-5.5"
}
}
}
},
"model": "ai-school-coderen/gpt-5.4-mini",
"small_model": "ai-school-coderen/gpt-5.4-mini"
}

Then set the API key as an environment variable.

macOS and Linux

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

Windows

setx AI_SCHOOL_CODEREN_API_KEY "ais.your-api-key"

Open a new terminal afterwards.

Start OpenCode

Go to the project folder:

cd path/to/your/project

Start OpenCode:

opencode

Use the model picker in OpenCode to select the AI-School Coding model if it is not selected automatically.

Work safely with OpenCode

Because OpenCode works agentically, it is important to check changes.

Recommended workflow:

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

For students with little experience, it is best to demonstrate OpenCode first under teacher supervision.

Environment variables and OpenCode

For OpenCode, you can store the coding API key in a local .env file in the project folder:

AI_SCHOOL_CODEREN_API_KEY=ais.your-api-key

Make sure OpenCode actually loads this environment variable. In PowerShell you can also set it temporarily for the current terminal:

$env:AI_SCHOOL_CODEREN_API_KEY="ais.your-api-key"

If you see Authorization header met Bearer token is verplicht, the tool did not send the key as Authorization: Bearer .... If you see Unknown parameter, remove provider-specific settings that the AI-School coding endpoint does not support.