File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,38 @@ Terminating an invocation also destroys any browsers associated with it.
99</Info >
1010
1111## Via API
12- Stopping an invocation via the API is not available yet, but it's coming very soon.
12+ You can stop an invocation by setting its status to ` failed ` . This will cancel the invocation and mark it as terminated.
13+
14+ <CodeGroup >
15+
16+ ``` typescript Typescript/Javascript
17+ import Kernel from ' @onkernel/sdk' ;
18+
19+ const client = new Kernel ({
20+ apiKey: ' My API Key' ,
21+ });
22+
23+ const invocation = await client .invocations .update (' invocation_id' , {
24+ status: ' failed' ,
25+ output: JSON .stringify ({ error: ' Invocation cancelled by user' })
26+ });
27+ ```
28+
29+ ``` python Python
30+ from kernel import Kernel
31+
32+ client = Kernel(
33+ api_key = " My API Key" ,
34+ )
35+
36+ invocation = client.invocations.update(
37+ id = " invocation_id" ,
38+ status = ' failed' ,
39+ output = ' {"error":"Invocation cancelled by user"}'
40+ )
41+ ```
42+
43+ </CodeGroup >
1344
1445## Via CLI
1546Use ` ctrl-c ` in the terminal tab where you launched the invocation.
You can’t perform that action at this time.
0 commit comments