File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,43 @@ print(retrieved_response)
81
81
# retrieved_response = await litellm.aget_responses(response_id=response_id)
82
82
```
83
83
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
+
84
121
#### DELETE a Response
85
122
``` python showLineNumbers title="Delete Response by ID"
86
123
import litellm
You can’t perform that action at this time.
0 commit comments