Skip to main content
Edgee’s OpenAI-compatible API works with OpenCode, letting you use OpenCode’s CLI agent while routing every request through Edgee for compression and observability. The fastest way to connect OpenCode to Edgee is the CLI. It authenticates, merges an Edgee provider into your OpenCode config (populated from the live Edgee model catalog), and starts OpenCode, no config file to edit by hand.
1

Install the Edgee CLI

2

Launch OpenCode through Edgee

The CLI authenticates, adds the edgee provider, and starts OpenCode. Token compression is enabled automatically. Pick an Edgee model from OpenCode’s model picker.
After the session ends, the CLI prints a link to view token usage, compression savings, and cost breakdown in the Edgee Console.

Manual setup (advanced)

Prefer to configure OpenCode yourself? Open or create ~/.config/opencode/opencode.json and add the following configuration:
Make sure to replace "sk-edgee-..." with your actual Edgee API key.

Usage

Once configured, you can select the configured models directly within the OpenCode CLI interface. When you launch OpenCode, you will be able to choose from the models you defined in the models section of your configuration (e.g., “mistral small (edgee)”, “gpt-4 (edgee)”, etc.).

Authentication

Edgee uses standard Bearer token authentication. Your API key configured in opencode.json is automatically used to authenticate requests to the Edgee API.
Token compression is only available when routing through Edgee. You can use your own provider keys via BYOK — compression still applies as long as requests go through Edgee.

Benefits of Using OpenCode with Edgee

Unified Infrastructure

Access all LLM providers through Edgee while using OpenCode’s developer-friendly CLI.

Cost Control

Leverage Edgee’s cost tracking and routing while building applications with OpenCode.

Reliability

Combine OpenCode’s agent capabilities with Edgee’s automatic failover and load balancing.

Observability

Monitor your OpenCode sessions with Edgee’s built-in observability features.

Next Steps