Skip to content

Commit 8af3ecf

Browse files
committed
docs: add cancel response API usage and curl example to response_api.md
1 parent fda7e22 commit 8af3ecf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/my-website/docs/response_api.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,43 @@ print(retrieved_response)
8181
# retrieved_response = await litellm.aget_responses(response_id=response_id)
8282
```
8383

84+
#### CANCEL a Response
85+
You can cancel an in-progress response (if supported by the provider):
86+
87+
```python showLineNumbers title="Cancel Response by ID"
88+
import litellm
89+
90+
# First, create a response
91+
response = litellm.responses(
92+
model="openai/o1-pro",
93+
input="Tell me a three sentence bedtime story about a unicorn.",
94+
max_output_tokens=100
95+
)
96+
97+
# Get the response ID
98+
response_id = response.id
99+
100+
# Cancel the response by ID
101+
cancel_response = litellm.cancel_responses(
102+
response_id=response_id
103+
)
104+
105+
print(cancel_response)
106+
107+
# For async usage
108+
# cancel_response = await litellm.acancel_responses(response_id=response_id)
109+
```
110+
111+
112+
**REST API:**
113+
```bash
114+
curl -X POST http://localhost:4000/v1/responses/response_id/cancel \
115+
-H "Authorization: Bearer sk-1234"
116+
```
117+
118+
This will attempt to cancel the in-progress response with the given ID.
119+
**Note:** Not all providers support response cancellation. If unsupported, an error will be raised.
120+
84121
#### DELETE a Response
85122
```python showLineNumbers title="Delete Response by ID"
86123
import litellm

0 commit comments

Comments
 (0)