For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Contact usJoin the Discord
ManualAPI GuideAPI Reference
  • Overview
    • API Reference
    • Client libraries
  • API Reference
      • POSTInitiate Async Chat Stream
      • GETObserve Async Chat Stream Events
      • GETGet Async Chat Stream Status
      • POSTCancel Async Chat Stream
      • DELDelete Async Chat Stream
LogoLogo
Contact usJoin the Discord
API ReferenceAsync Messages

Cancel Async Chat Stream

POST
https://host.com/v1/messages/async/:message_id/cancel
POST
/v1/messages/async/:message_id/cancel
$curl -X POST https://host.com/v1/messages/async/message_id/cancel \
> -H "Content-Type: application/json" \
> -d '{}'
1{
2 "message": "Stream cancelled successfully",
3 "message_id": "msg_async_12345"
4}
Cancel an active asynchronous chat stream. This endpoint gracefully cancels an ongoing chat completion stream by: 1. Setting the cancellation token to stop the event generation loop 2. Cancelling the underlying asyncio task 3. Updating the stream status to 'cancelled' Notes: - Cancellation is irreversible - stream cannot be resumed - Any active SSE connections will receive a final event and close - Stream status will be updated to reflect cancellation - Use DELETE endpoint to remove cancelled streams from storage
Was this page helpful?
Previous

Delete Async Chat Stream

Next
Built with

Cancel an active asynchronous chat stream.

This endpoint gracefully cancels an ongoing chat completion stream by:

  1. Setting the cancellation token to stop the event generation loop
  2. Cancelling the underlying asyncio task
  3. Updating the stream status to ‘cancelled’

Notes:

  • Cancellation is irreversible - stream cannot be resumed
  • Any active SSE connections will receive a final event and close
  • Stream status will be updated to reflect cancellation
  • Use DELETE endpoint to remove cancelled streams from storage

Path parameters

message_idstringRequired
Message ID of the asynchronous chat stream to cancel.

Request

This endpoint expects an object.

Response

This endpoint returns an object.
messagestring
Confirmation message for successful stream cancellation
message_idstring
Unique identifier of the cancelled stream

Errors

401
Unauthorized
404
Not Found
422
Unprocessable Entity