# Codebuff

Source: https://docs.aicentos.com/en/clients/codebuff

Language: en

> Connect aicentos's OpenAI-compatible endpoint in the Codebuff command-line agent

Codebuff is an AI coding agent that runs in the terminal and schedules multiple sub-agents per task to read code, draft plans and modify files. By default it connects to the official hosted service; if your version supports overriding the OpenAI-compatible endpoint, environment variables can point the requests at aicentos.

## First check whether your version supports a custom endpoint

Codebuff officially pushes the hosted mode: sign in to use the official quota, or use the official API through `CODEBUFF_API_KEY`. Not every version offers a custom Base URL, so confirm first:

* Run `codebuff --help` and look for options like `--base-url` or `--provider`.
* Check whether your version reads `OPENAI_BASE_URL` (some versions use `CODEBUFF_BASE_URL`) to override the endpoint.
* If neither is supported, the current version only talks to the official service and cannot connect to aicentos directly.

## Prerequisites

If your version does support a custom endpoint, first create a dedicated key for Codebuff on the console's "API Keys" page (naming it `codebuff-cli` is a good idea).

* Console: [https://aicentos.com](https://aicentos.com)
* Create a key: [https://aicentos.com/keys](https://aicentos.com/keys)
* Top up when the balance runs out: [https://aicentos.com/wallet](https://aicentos.com/wallet)

Also make sure Node.js is installed locally and Codebuff is installed globally:

```bash
npm install -g codebuff
```

## Configuration to fill in

| Field    | Value                                              |
| -------- | -------------------------------------------------- |
| Base URL | `https://aicentos.com/v1`                          |
| API Key  | The key created in the console                     |
| Model    | A model name from the Model Gallery in the console |

## Setup steps

* Write the endpoint and key into your shell configuration (`~/.zshrc` or `~/.bashrc`):

```bash
export OPENAI_API_KEY="sk-your-aicentos-key"
export OPENAI_BASE_URL="https://aicentos.com/v1"
```

* Reload the configuration: `source ~/.zshrc`.
* Go to your project directory and run `codebuff` directly.
* If the version supports the `--model` flag, specify the model explicitly at launch; otherwise switch models with the model selection command in the interactive interface.

Some versions keep the configuration in a JSON file under the user configuration directory (credential files default to `600` permissions; do not commit them to version control). If your version uses a configuration file instead of environment variables, fill in the same Base URL and key under the field names given by `codebuff --help` or the official documentation.

## Test

After launching, run a lightweight test with a simple prompt first — for example, have it read a file and summarize the contents — and only start real use once results come back normally.

## Notes

* Custom endpoints are an advanced use case, and field names may vary between versions; trust the `codebuff --help` output on your machine.
* `OPENAI_BASE_URL` only goes up to `https://aicentos.com/v1`; do not extend it to the full `/v1/chat/completions`.
* Codebuff sends code snippets and terminal output as context; confirm this complies with your team's data compliance requirements before use.
* When errors occur, check in order: whether the environment variables are active in the current terminal, whether the model name matches the console, and whether the account balance is sufficient ([https://aicentos.com/wallet](https://aicentos.com/wallet)).
* More details on the docs site: [https://docs.aicentos.com](https://docs.aicentos.com)