Use AI Code With with OpenCode

Use a single AI Code With API key to access Claude, Kimi, GLM and other coding models inside OpenCode.

Estimated setup time: 2 minutes

OpenAI-compatible API
Multiple coding models
Pay as you go

Step 1

Get an API key

Don't have an AI Code With API key yet? Sign up and get an API key

Step 2

Choose a model

Step 3

Add it to OpenCode

Add AI Code With as an OpenAI-compatible custom provider. Pick how you want to store your key.

Store your API key as an environment variable so it never touches your config files:

bash
export AICODEWITH_API_KEY="sk-xxxxxxxx"
opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["oh-my-opencode"],
  "model": "aicodewith-anthropic/claude-sonnet-4-6",
  "provider": {
    "aicodewith-anthropic": {
      "npm": "@ai-sdk/anthropic",
      "name": "AICodeWith Anthropic",
      "options": {
        "baseURL": "https://api.aicodewith.ai/v1",
        "apiKey": "{env:AICODEWITH_API_KEY}"
      },
      "models": {
        "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" }
      }
    }
  }
}

Base URL

https://api.aicodewith.ai/v1

Model ID

claude-sonnet-4-6

Step 4

Add the config to OpenCode

Place the config in the OpenCode config file for your platform:

~/.config/opencode/opencode.json

Refer to the latest OpenCode documentation for the exact path.

Step 5

Start and verify

Reopen your terminal or IDE and run OpenCode (the model is already set in the config):

bash
opencode

Type in the chat: Hello!

If it replies and you see the request logged in your AI Code With dashboard, the setup works.

Setup complete

Troubleshooting

Ready to code with AI Code With in OpenCode?

Grab an API key and paste the config above to get started.

Get an API key
    OpenCode API Setup: Use Claude, Kimi & GLM | AI Code With | AI Code With