Skip to content

Commit 67a3532

Browse files
authored
Add docs for Cancelling invocation (#51)
1 parent 206aaab commit 67a3532

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

apps/stop.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff 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
1546
Use `ctrl-c` in the terminal tab where you launched the invocation.

0 commit comments

Comments
 (0)