[{"data":1,"prerenderedAt":7},["ShallowReactive",2],{"docs-chats\u002Fcopilot\u002Fengine":3,"docs-tabs-chats\u002Fcopilot\u002Fengine":6},{"content":4,"lastmod":5},"\n## Change the CoPilot model\n\n`PUT \u002Fv1\u002Fchats\u002F:dialogId\u002Fcopilot\u002Fengine`\n\nSwitches the artificial intelligence (AI) model that CoPilot uses to answer in a chat. Works only in a CoPilot chat. After the switch, a system message about the new model appears in the chat.\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|----------|-----|:-----:|---------|\n| `dialogId` (path) | string | yes | Dialog ID of a CoPilot chat — `chatN`. Get it from `data.chat.dialogId` of the [draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft) or from [recent dialogs](\u002Fdocs\u002Fchats\u002Fdiscovery\u002Frecent) called with `onlyCopilot=true` |\n\nQuery parameters are not accepted and are rejected with `400 INVALID_PARAMS`.\n\n## Request fields (body)\n\n| Field | Type | Required | Description |\n|------|-----|:-----:|---------|\n| `engineCode` | string | yes | Code of an AI model available in the Bitrix24 account. The chat's current model is `engine` in `data.copilot.chats` returned by [Load a chat](\u002Fdocs\u002Fchats\u002Fmessages\u002Fload) |\n\nOther body fields are rejected with `400 INVALID_PARAMS`.\n\n## Examples\n\n### curl — personal key\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine \\\n  -H \"X-Api-Key: YOUR_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"engineCode\": \"engine_code\"}'\n```\n\n### curl — OAuth application\n\n```bash\ncurl -X PUT https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine \\\n  -H \"X-Api-Key: YOUR_APP_KEY\" \\\n  -H \"Authorization: Bearer USER_SESSION_TOKEN\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"engineCode\": \"engine_code\"}'\n```\n\n### JavaScript — personal key\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_API_KEY',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ engineCode: 'engine_code' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Model switched:', data.result)\n```\n\n### JavaScript — OAuth application\n\n```javascript\nconst res = await fetch('https:\u002F\u002Fvibecode.bitrix24.com\u002Fv1\u002Fchats\u002Fchat2001\u002Fcopilot\u002Fengine', {\n  method: 'PUT',\n  headers: {\n    'X-Api-Key': 'YOUR_APP_KEY',\n    'Authorization': 'Bearer USER_SESSION_TOKEN',\n    'Content-Type': 'application\u002Fjson',\n  },\n  body: JSON.stringify({ engineCode: 'engine_code' }),\n})\n\nconst { success, data } = await res.json()\nconsole.log('Model switched:', data.result)\n```\n\n## Response fields\n\n| Field | Type | Description |\n|------|-----|---------|\n| `success` | boolean | Always `true` on success |\n| `data.result` | boolean | `true` — the model was switched |\n\n## Response example\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"result\": true\n  }\n}\n```\n\n## Error response example\n\n422 — the chat is not a CoPilot chat:\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"BITRIX_ERROR\",\n    \"message\": \"WRONG_MESSAGE_TYPE\",\n    \"b24Code\": \"WRONG_MESSAGE_TYPE\"\n  }\n}\n```\n\n## Errors\n\n| HTTP | Code | Description |\n|------|-----|---------|\n| 400 | `INVALID_PARAMS` | `engineCode` is missing or is not a non-empty string, or another body field or a query parameter was sent. Checked before any call to Bitrix24 |\n| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned \"not found\". The portal code is in `error.b24Code` |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `WRONG_MESSAGE_TYPE` in `error.b24Code` — the chat is not a CoPilot chat |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `IDENTICAL_ENGINE` in `error.b24Code` — the chat already uses this model |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `ENGINE_NOT_FOUND` in `error.b24Code` — no model with this code |\n| 422 | `BITRIX_ERROR` | Bitrix24 refused with `COPILOT_NOT_INSTALLED` in `error.b24Code` — CoPilot is not installed on the portal |\n| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user when using the `me` alias |\n| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |\n| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — the call changes the chat |\n| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |\n\nThe full list of general API errors — [Errors](\u002Fdocs\u002Ferrors).\n\n## Known specifics\n\n**Switching to the same model again is refused.** Before switching, compare `engine` from `data.copilot.chats` with the model you need.\n\n**The choice is remembered.** The model is saved as the one the user selected last.\n\n## See also\n\n- [CoPilot](\u002Fdocs\u002Fchats\u002Fcopilot)\n- [Change the CoPilot role](\u002Fdocs\u002Fchats\u002Fcopilot\u002Frole)\n- [CoPilot draft chat](\u002Fdocs\u002Fchats\u002Fcopilot\u002Fdraft)\n","2026-10-07",{},1794739533461]