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-Public recommends OpenCode for developers, administrators, and other advanced users. OpenCode can autonomously edit files and implement tasks. Always verify the proposed changes.

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

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

Connecting to Coding

OpenCode supports custom OpenAI-compatible providers. Create a file opencode.json in your project directory.

Use it to specify the Coding endpoint and the allowed models:

{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ai-public-coderen": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI-Public Coding",
"options": {
"baseURL": "https://europe-west1-ai-public-pro.cloudfunctions.net/coderenOpenAiCompatibleApi/v1",
"apiKey": "{env:AI_PUBLIC_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-public-coderen/gpt-5.6-luna",
"small_model": "ai-public-coderen/gpt-5.6-luna"
}

Then set the API key as an environment variable.

macOS and Linux

export AI_PUBLIC_CODEREN_API_KEY="aip.your-api-key"

Windows

setx AI_PUBLIC_CODEREN_API_KEY "aip.your-api-key"

Then open a new terminal.

Start OpenCode

Navigate to the project directory:

cd path/to/your/project

Start OpenCode:

opencode

In OpenCode, use the model selection to choose the AI-Public Coding model if it hasn’t automatically.

Safe working with OpenCode

Because OpenCode is agentic, it’s important to verify changes.

Recommended workflow:

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

Environment variables and OpenCode

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

AI_PUBLIC_CODEREN_API_KEY=aip.your-api-key

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

$env:AI_PUBLIC_CODEREN_API_KEY="aip.your-api-key"

If you see Authorization header with Bearer token is required, the tool is not sending the key as Authorization: Bearer .... If you see Unknown parameter, remove provider-specific settings that the Coding endpoint from AI-Public does not support.

WhatsApp