Stop an answer

.md

Stop the answer being written in a conversation. It keeps what it wrote so far.

Scopesai:write
POST/v1/me/ai/conversations/{id}/cancel

Asks the answer being written to stop. The worker looks for the request about once a second, so the answer stops within a second or two rather than at once, and keeps the text it had written. An answer that had not started yet ends without a word and is left out of the conversation.

The answer then sends stream_end with reason cancelled and a turn_state with status cancelled over the websocket. Wait for those before asking again.

cancelled is false when nothing was being written, or a stop was already asked for. That is not an error: the answer is not running either way.

Stopping is outside the limit of twenty a minute, as on the website.

Request

curl -X POST https://api.proppertrading.com/v1/me/ai/conversations/01a16152-7e42-70cd-91a4-b6b80ee47daa/cancel \
  -H "Authorization: Bearer ptat_9f2c1a44_3b8e7d2f5c9a1b4e6d8f0a2c4e6b8d1f" \
  -H "Idempotency-Key: 9a3e7c15-2d4b-4e86-b0f1-6c8d2a5e7b94"

Response

{
    "data": {
        "object": "ai_cancellation",
        "conversation_id": "01a16152-7e42-70cd-91a4-b6b80ee47daa",
        "cancelled": true
    },
    "meta": {
        "request_id": "req_01m5gn6fepe9v7vq4zf5er4xxf"
    }
}

Errors

StatusCodeMeaning
400missing_idempotency_keyEvery POST needs one
400workspace_requiredOur own staff, without a firm in Propper-Workspace
403ai_unavailableThe firm has the assistant switched off for this chat
403forbiddenStaff whose role does not include use_ai_chat
403insufficient_scopeThis device does not hold ai:write
404resource_not_foundNo conversation of yours with that id in this chat and this firm