# Grok Build

Source: https://docs.aicentos.com/en/clients/grok-build

Language: en

> Use aicentos in Grok Build — define a custom model provider through config.toml

Grok Build is xAI's terminal coding agent. It calls the official xAI endpoint by default, but it supports declaring arbitrary OpenAI-compatible `[model.*]` endpoints in `~/.grok/config.toml`. Point the endpoint at aicentos and the same key can call the grok family as well as models from other vendors.

## Prerequisites

* Install Grok Build (official script):

  ```bash
  curl -fsSL https://x.ai/cli/install.sh | bash
  ```

* Create a dedicated key in the aicentos console (naming it `grok-build` is a good idea).

## Configuration to fill in

| Field           | Value                                                                                |
| --------------- | ------------------------------------------------------------------------------------ |
| base\_url       | `https://aicentos.com/v1`                                                            |
| api\_backend    | `chat_completions` (default)                                                         |
| env\_key        | `AICENTOS_API_KEY`                                                                   |
| model           | A model ID from the Model Gallery in the console, e.g. `grok-4.7`, `claude-opus-4-8` |
| context\_window | Match the chosen model, e.g. `200000`                                                |

## Setup steps

* Write the key into your shell environment (add it to `~/.zshrc` or `~/.bashrc`, then `source` the file to apply it):

  ```bash
  export AICENTOS_API_KEY="your_api_key_here"
  ```

* Edit `~/.grok/config.toml` and add a custom model:

  ```toml
  [models]
  default = "aicentos-grok"

  [model.aicentos-grok]
  base_url          = "https://aicentos.com/v1"
  env_key           = "AICENTOS_API_KEY"
  api_backend       = "chat_completions"
  context_window    = 200000
  max_completion_tokens = 8192
  description       = "aicentos gateway - grok-4.7"
  ```

  The `<name>` in `[model.<name>]` is the model ID. To add more models, for example `grok-4.7` and `claude-opus-4-8`, write a separate `[model.grok-4.7]` and `[model.claude-opus-4-8]` block for each.

* Start Grok Build and switch with the model picker or a command:

  ```bash
  grok
  /model aicentos-grok
  ```

## Test

First list the models to see whether yours is recognized:

```bash
grok models
```

Then send a lightweight prompt (e.g. `grok -p "Introduce the current directory in one sentence" -m aicentos-grok`) and confirm it returns normally.

## Notes

* Grok Build has **no `--base-url` command-line flag**; a custom endpoint can only be specified through the configuration file or environment variables.
* `api_backend` defaults to `chat_completions`; if you explicitly write `responses` or `messages`, make sure the gateway supports the corresponding endpoint, otherwise requests fail.
* Credentials are resolved in this order: the `api_key` in the model configuration → the environment variable named by `env_key` → the logged-in session token → the global `XAI_API_KEY`. Using `env_key` with your own variable name keeps things separate from the official xAI account.
* If a newly added model omits `context_window`, Grok Build assumes 200,000 by default; setting it explicitly for the chosen model is recommended.
* Once a custom endpoint is configured, the xAI subscription is no longer needed, but the selected model is still billed on the aicentos side — check the balance on the [wallet page](https://aicentos.com/wallet) first.