> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reilabs.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Rei Chat quickstart

> Authenticate, choose the correct Rei Chat base URL, and make your first API call.

The Rei Chat platform exposes two complementary HTTP APIs: the **Agent API** for managing your agents and their configuration, and the **Inference API** for running chat and response generation against an agent. This guide explains the scope of each, which credential to use, and how to make your first request.

## APIs at a glance

| API               | Base URL                         | Scope                                                        | Auth                                              |
| ----------------- | -------------------------------- | ------------------------------------------------------------ | ------------------------------------------------- |
| **Agent API**     | `https://api.reilabs.org/v1`     | Create, configure, and manage agents (units) and their tools | Account API Key *and* Unit API Key (per endpoint) |
| **Inference API** | `https://rei-api.reilabs.org/v1` | Run chat completions and generate responses from an agent    | Unit API Key                                      |

<Note>
  All paths are versioned under `/v1`. Always send your credential in the `Authorization` header as a bearer token: `Authorization: Bearer <SECRET_KEY>`.
</Note>

***

## Agent API

**Base URL:** `https://api.reilabs.org/v1`

**Scope & usage:** Use the Agent API to manage the lifecycle and configuration of your agents: the control-plane operations you typically run from a backend or during setup. It is split into two sub-categories based on which credential authorizes the call.

### Account & Unit Management

Operations that create or change agents on your account. These are authorized with your **Account API Key**, because they act across your account rather than on behalf of a single agent.

| Method   | Endpoint                | Description               |
| -------- | ----------------------- | ------------------------- |
| `POST`   | `/accounts/units`       | Create a new agent (unit) |
| `PUT`    | `/accounts/units`       | Update an existing agent  |
| `DELETE` | `/accounts/units`       | Delete an agent           |
| `POST`   | `/accounts/units/clone` | Clone an existing agent   |

### Agent Operations

Operations that read or update a single agent and its tools. These are authorized with that agent's **Unit API Key**.

| Method | Endpoint        | Description                  |
| ------ | --------------- | ---------------------------- |
| `GET`  | `/agents`       | Retrieve the agent's details |
| `GET`  | `/agents/tools` | List the agent's tools       |
| `PUT`  | `/agents/tools` | Update the agent's tools     |

***

## Inference API

**Base URL:** `https://rei-api.reilabs.org/v1`

**Scope & usage:** Use the Inference API at runtime to interact with a configured agent, sending messages and receiving generated output. All Inference API calls are authorized with the **Unit API Key** of the agent you are calling.

### Chat & Responses

| Method | Endpoint           | Description                             |
| ------ | ------------------ | --------------------------------------- |
| `POST` | `/chat-completion` | Run a chat completion against the agent |
| `POST` | `/response`        | Generate a response from the agent      |

***

## Authentication

Rei Chat uses two types of bearer credentials. Pick the one required by the endpoint you are calling (see the tables above).

| Credential          | Used for                               | Endpoints                                                                         |
| ------------------- | -------------------------------------- | --------------------------------------------------------------------------------- |
| **Account API Key** | Managing resources across your account | `POST/PUT/DELETE /accounts/units`, `POST /accounts/units/clone`                   |
| **Unit API Key**    | Acting as a specific agent             | `GET /agents`, `GET/PUT /agents/tools`, `POST /chat-completion`, `POST /response` |

### Account API Key

To manage resources.

<details>
  <summary><strong>❓ How to get a User API Key</strong></summary>

  #### **Steps**

  1. Navigate to [Rei Chat Portal](https://app.reilabs.org/)

  2. Create an agent as stated in the Rei Chat Portal.

  3. Click on three dots next to the `Create`.

       <img src="https://mintcdn.com/reilabs/GB3egViUEgZq7g34/docs/intro-user-secret-view.png?fit=max&auto=format&n=GB3egViUEgZq7g34&q=85&s=044653721a0c31653d6c8a9b9872f6e8" alt="Top right bar of Rei Chat Portal" width="726" height="592" data-path="docs/intro-user-secret-view.png" />

  4. Click `View API`.

       <img src="https://mintcdn.com/reilabs/GB3egViUEgZq7g34/docs/intro-user-secret-view-2.png?fit=max&auto=format&n=GB3egViUEgZq7g34&q=85&s=890b6a0b292fb0206ef98fc3c1074a59" alt="User API Key pop-out dialog" width="462" height="238" data-path="docs/intro-user-secret-view-2.png" />

  5. Locate your `Account API Key` from the pop-out dialog.

       <img src="https://mintcdn.com/reilabs/GB3egViUEgZq7g34/docs/intro-user-secret-view-3.png?fit=max&auto=format&n=GB3egViUEgZq7g34&q=85&s=44316b58ed5f609cbb34becb7607a019" alt="User API Key pop-out dialog" width="698" height="562" data-path="docs/intro-user-secret-view-3.png" />

  6. Turn the key to `Active`

  7. Copy.

  * Treat this key as highly sensitive. It grants full API access.
  * ❗ Never expose it in client-side code or version control (e.g., Git).

  8. Key rotation

  * You may regenerate the Account API Key if is needed.
  * Only the latest generated Account API Key is valid.
</details>

<details>
  <summary><strong>🔧 How to use User API Key</strong></summary>

  **Example:**

  ```http theme={null}
  POST /v1/accounts/units HTTP/1.1
  Host: api.reilabs.org
  Authorization: Bearer YOUR_ACCOUNT_API_KEY
  ```
</details>

### Unit API Key

To act on behalf of a specific agent.

<details>
  <summary><strong>❓ How to get a Rei Agent API Key</strong></summary>

  #### **Steps**

  1. Navigate to [Rei Chat Portal](https://app.reilabs.org/)

  2. Create an agent as stated in the Rei Chat Portal.

  3. Find the agent from the side bar at the left.

  4. Click `...`

  5. Click `Agent Details`

  6. Locate your Agent `Secret Key` from the pop-out dialog.
     <img src="https://mintcdn.com/reilabs/GB3egViUEgZq7g34/docs/intro-rei-secret-view.png?fit=max&auto=format&n=GB3egViUEgZq7g34&q=85&s=19c2a5bcbca27eea32f16031aef784b6" alt="Unit API Key pop-out dialog" width="1316" height="258" data-path="docs/intro-rei-secret-view.png" />.

  7. Copy.

  * Treat this key as highly sensitive. It grants full API access.
  * ❗ Never expose it in client-side code or version control (e.g., Git).

  8. Key rotation

  * You may regenerate the Secret Key if is needed.
  * Only the latest generated Secret Key is valid.
</details>

<details>
  <summary><strong>🔧 How to use Agent API Key</strong></summary>

  **Example:**

  ```http theme={null}
  POST /v1/chat-completion HTTP/1.1
  Host: rei-api.reilabs.org
  Authorization: Bearer YOUR_UNIT_API_KEY
  ```
</details>

***

## Make your first request

Once you have an Unit API Key, call the Inference API to run a chat completion:

```bash theme={null}
curl -X POST https://rei-api.reilabs.org/v1/chat-completion \
  -H "Authorization: Bearer YOUR_UNIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "Hello, who are you?" }
    ]
  }'
```

To manage agents instead, call the Agent API with your Account API Key:

```bash theme={null}
curl -X POST https://api.reilabs.org/v1/accounts/units \
  -H "Authorization: Bearer YOUR_ACCOUNT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentModel": "google/gemini-2.5-flash",
    "tag": "my-first-agent",
    "behaviourPrompt": "You are a helpful assistant."
  }'
```

See the **Agent API** and **Inference API** sections in the sidebar for the full request and response schema of every endpoint.
