# CoPilot

Work with the Bitrix24 AI assistant in chats: open the CoPilot draft chat, switch the assistant's model and role, ask it to regenerate an answer, and rate the answer.

**Scope:** `im` | **Base URL:** `https://vibecode.bitrix24.com/v1` | **Authorization:** `X-Api-Key`

## Operations

- [CoPilot draft chat](./copilot/draft.md) — `POST /v1/chats/copilot/draft`
- [Change the CoPilot model](./copilot/engine.md) — `PUT /v1/chats/:dialogId/copilot/engine`
- [Change the CoPilot role](./copilot/role.md) — `PUT /v1/chats/:dialogId/copilot/role`
- [Regenerate a CoPilot answer](./copilot/regenerate.md) — `POST /v1/chats/messages/:messageId/regenerate`
- [Rate an answer](./copilot/vote.md) — `POST /v1/chats/messages/:messageId/vote`

## Known specifics

**Every operation in this section is a write.** A read-only key gets `403 WRITE_BLOCKED_READONLY_KEY` before any call to Bitrix24: switching the model or the role changes the chat, regenerating an answer starts a new generation, the draft chat is created on the first call, and any call that takes a chat or a message may make the key owner a chat member when the chat allows auto-join.

**A CoPilot chat is a chat type of its own.** Switching the model and the role works only in a CoPilot chat; in a regular chat Bitrix24 returns `WRONG_MESSAGE_TYPE`. The current model and role of a CoPilot chat arrive in the `data.copilot` block of the [Load a chat](/docs/chats/messages/load) response.

**AI is not available on every Bitrix24 account.** When CoPilot is turned off on the account or not included in its plan, Bitrix24 rejects the request with a code in `error.b24Code` — for example, `DRAFT_CHAT_NOT_AVAILABLE` or `AI_NOT_AVAILABLE`.

## See also

- [Chats and messages](/docs/chats)
- [Load a chat](/docs/chats/messages/load)
- [Transcribe an audio file](/docs/chats/files/transcribe)
