CodeBuddy Code
Connect Tencent's CodeBuddy Code to RealRelay.ai as a custom model: install it, add the model to models.json with the full Chat Completions URL, check the connection and switch models.
- Protocol
- OpenAI Chat Completions
- Base URL
https://www.realrelay.ai/v1- Official docs
- www.codebuddy.ai
- Checked against the tool’s docs
- 2026-10
Overview
CodeBuddy Code is Tencent's coding agent for the terminal. It reads your project, edits files and runs commands. You add RealRelay.ai models to it as custom models in a file called models.json. Custom models use the OpenAI Chat Completions format, so requests go to /v1/chat/completions.
An API key from the API keys page of the console.
The full endpoint URL, ending in
/v1/chat/completions. Unlike most tools, CodeBuddy Code does not add the path for you.A model ID exactly as
GET /v1/modelslists it, for examplez-ai/glm-5.2. Pick one that supports tool calling.
This setup follows CodeBuddy's documentation but has not yet been run end to end against RealRelay.ai. CodeBuddy Code asks you to sign in to a CodeBuddy account the first time it starts, and its documentation does not say whether custom models work without that sign-in. This page covers the terminal agent only, not the CodeBuddy IDE plugin or WorkBuddy.
Install
Install it with npm, which needs Node.js 18.20 or later, or with Tencent's Homebrew tap, which does not need Node.js.
npm install -g @tencent-ai/codebuddy-codecodebuddy --versionbrew install Tencent-CodeBuddy/tap/codebuddy-codecodebuddy --versionIf codebuddy --version prints a version number, the install worked. If the command is not found, open a new terminal so it picks up the updated PATH.
The first time you run codebuddy, it shows a sign-in screen. Users outside China choose the International Site.
Configure
- 1
Save the key in an environment variable
This keeps the key out of the config file. Open a new terminal afterwards.
~/.zshrc · ~/.bashrc export REALRELAY_API_KEY="sk-***"Windows PowerShell [Environment]::SetEnvironmentVariable("REALRELAY_API_KEY", "sk-***", "User") - 2
Add the model to models.json
Create the file if it does not exist. On Windows it is
%USERPROFILE%\.codebuddy\models.json. CodeBuddy Code notices the change within about a second, so you do not need to restart it.~/.codebuddy/models.json 1{2 "models": [3 {4 "id": "z-ai/glm-5.2",5 "name": "z-ai/glm-5.2 (RealRelay.ai)",6 "vendor": "RealRelay.ai",7 "url": "https://www.realrelay.ai/v1/chat/completions",8 "apiKey": "${REALRELAY_API_KEY}",9 "maxInputTokens": 200000,10 "maxOutputTokens": 32000,11 "supportsToolCall": true,12 "supportsImages": false13 }14 ]15}
idis the model ID sent to RealRelay.ai.nameis only the label in the model list.urlmust be the full path. A URL that stops at/v1does not work here.apiKeyreads the key fromREALRELAY_API_KEYwhen CodeBuddy Code starts. If that variable is not set, the placeholder is sent as it is and the request fails.maxInputTokensandmaxOutputTokensare safe lower bounds in this example. Replace them with the limits on the model's catalog page.supportsToolCallmust betruefor the agent to edit files and run commands. SetsupportsImagestotrueonly for models that accept images.A
.codebuddy/models.jsoninside a project overrides the one in your home folder. Do not put a key in a file you commit.
Verify
- 1
Call the endpoint directly
Run this with your key. A JSON reply with a
choicesarray means the address, key and model work.Terminal 1curl -sS "https://www.realrelay.ai/v1/chat/completions" \2 -H "Authorization: Bearer sk-***" \3 -H "content-type: application/json" \4 -d '{"model": "z-ai/glm-5.2", "max_tokens": 16, "messages": [{"role": "user", "content": "Reply with OK"}]}' - 2
Start CodeBuddy Code with the model
Start it in a project with the model selected, then list the models it knows about.
CodeBuddy Code cd /path/to/your/projectcodebuddy --model z-ai/glm-5.2/model list - 3
Check the list and send a message
Your model should appear in the list with a
customtag. Send a short message; a reply confirms the whole path, and the request appears in the console's usage logs.
Models
Add one entry to the models list for each RealRelay.ai model you want, each with its own limits. Then switch in a session with /model followed by the ID, or start with codebuddy --model. Switching is refused while a task is running.
/model z-ai/glm-5.2To show only some models in the list, add an availableModels array with their IDs. When it is set, every model missing from it is hidden, including the built-in ones.
CodeBuddy Code also uses a lighter model for background work and a reasoning model for hard steps. A custom model without its own settings for these uses itself for both, so one entry is enough to start. Models that work well for coding agents are listed under Choosing a model.
Troubleshooting
The model does not appear in
/model list. The JSON is invalid, the file is not saved in~/.codebuddy/, or anavailableModelsarray leaves the ID out. A project-levelavailableModelsreplaces the one in your home folder completely.401.
REALRELAY_API_KEYwas not set in the terminal that started CodeBuddy Code. Open a new terminal and check it withecho $REALRELAY_API_KEY, then start again.404. The
urlstops at/v1. Add/chat/completions.Model not found. The
iddoes not matchGET /v1/modelsexactly. Keep the prefix before the slash.Replies are cut off.
maxOutputTokensis too low for the task. Raise it, up to the model's limit.Context errors on long tasks.
maxInputTokensis higher than the model's real window. Set it to the model's limit.Edits made in the file have no effect. The change was not saved to disk, or a project-level
models.jsondefines the sameidand wins.
