Skip to main content

Overview

This guide explains how to connect OpenCode to the Agnes-2.0-Flash model. After configuration, you can use Agnes models in OpenCode for code generation, project analysis, code editing, and multi-turn development conversations.
This guide is based on OpenCode 1.15.13.

Prerequisites

Before you start, make sure you have completed the following steps:
  1. Registered an Agnes AI account
  2. Logged in to the Agnes API Platform
  3. Created and copied your API Key
  4. Confirmed that your network can access the Agnes API Gateway
Only paste the API Key itself. Do not add Bearer before the key.

OpenCode CLI Configuration

Use Case

This method is for users who use OpenCode through the terminal. If you already have an OpenCode configuration file, you only need to add the agnes provider and set the default model to:

Configuration Example

Open your OpenCode configuration file and add the following configuration:
If your configuration file already contains other providers, do not overwrite the entire file. Add agnes under provider, then set model to agnes/agnes-2.0-flash.

Configure the Environment Variable

Set your Agnes API Key in the terminal:
To make it permanent, add it to your shell configuration file. For bash users:
For macOS or zsh users:

Verify CLI Configuration

Start OpenCode and run:
If the configuration is successful, you should see:
Select:
You can now use Agnes in OpenCode CLI.

OpenCode Desktop Configuration

Use Case

This method is for users who use the OpenCode Desktop graphical interface.

Configuration Steps

1

Open Settings

Launch OpenCode Desktop and click the settings button in the lower-left corner.
2

Go to Providers

In the settings page, click Providers from the left-side menu.
3

Choose Custom Provider

Find Custom Provider in the provider list and click Connect.
4

Fill in Provider Information

Enter the Agnes provider information according to the table below.

Provider Configuration

Example:
After completing the form, click Submit.

Verify Desktop Configuration

Return to the OpenCode Desktop main interface. In the model selector, choose:
Send a test message:
If the model responds normally, the configuration is complete.

Common Issues

Agnes model does not appear

Check the following items:
  1. The Provider ID is agnes
  2. The Base URL is https://apihub.agnes-ai.com/v1
  3. The Model ID is agnes-2.0-flash
  4. The API Key is correct
  5. The API Key does not include Bearer

API Key error

Make sure the API Key is copied from Agnes Platform and does not contain extra spaces. Correct example:
Incorrect example:

Request failed or cannot connect

Check the following items:
  1. Your network can access the Agnes API Gateway
  2. The Base URL only ends with /v1
  3. The Base URL is not written as /v1/chat/completions
  4. Your API Key is still valid
Correct Base URL:


Quick Reference