# OpenCodeReview

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

Language: en

> Use aicentos in OpenCodeReview (OCR) — wire up code review through a custom provider

OpenCodeReview (command name `ocr`) is Alibaba's open-source AI code review CLI: it reads the Git diff and calls a large model for review comments. It ships with an OpenAI-compatible provider and also supports custom OpenAI-compatible gateways, so requests can be routed to aicentos.

## Prerequisites

Create a dedicated key in the aicentos console (naming it `ocr-ci` makes usage easier to track). OCR only supports the OpenAI and Anthropic protocols; this guide uses OpenAI's Chat Completions path. Code review depends on the model's **function calling** capability, so pick a model that supports tool calling.

## Configuration to fill in

| Field    | Value                                                                             |
| -------- | --------------------------------------------------------------------------------- |
| provider | `openai` (built-in, override its URL) or a custom provider                        |
| protocol | `openai` (Chat Completions)                                                       |
| URL      | `https://aicentos.com/v1`                                                         |
| API Key  | The key created in the console                                                    |
| Model    | A model name from the Model Gallery in the console; must support function calling |

## Setup steps

* Install the CLI (Node.js required, or Homebrew on macOS):

  ```bash
  npm install -g open-code-review
  ```

* Write the configuration with the non-interactive commands; it ends up in `~/.opencodereview/config.json`:

  ```bash
  ocr config set provider                   openai
  ocr config set model                      claude-sonnet-5
  ocr config set providers.openai.url       https://aicentos.com/v1
  ocr config set providers.openai.api_key   your_api_key_here
  ```

* If you prefer a graphical walkthrough, run `ocr config provider` and `ocr config model` instead: pick the provider, enter the key and choose the model in the TUI, and a connectivity check runs automatically at the end.

## Test

Verify the endpoint on its own first:

```bash
ocr llm test
```

Once it passes, run a real review in any Git repository:

```bash
ocr review
```

## Notes

* The URL only goes up to `/v1`; do not extend it to the full `/chat/completions`.
* The configuration resolver needs all three of **URL, key and model**; merely `export`ing environment variables is not enough — anything missing must still be written into config.json, otherwise you get a 401.
* Environment variables can also override the configuration temporarily and take the highest precedence: `OCR_LLM_URL` / `OCR_LLM_TOKEN` / `OCR_LLM_MODEL`.
* For the built-in provider the field is `providers.<name>.url`; for custom providers it is `custom_providers.<name>.url`. Do not mix up the two maps.
* An insufficient account balance shows up as 401 / 403; check the balance on the [wallet page](https://aicentos.com/wallet) first.
* Official repository: `https://github.com/alibaba/open-code-review`