Skip to content

Commit fcdf3c3

Browse files
Restructure How it works: Configure, Control, Scale, Observe, Manage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 0f2af3f commit fcdf3c3

53 files changed

Lines changed: 1230 additions & 951 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/deploy.mdx‎

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
title: "Deploying"
2+
title: "Deploy an App"
3+
sidebarTitle: "Deploy"
4+
description: "Deploy your app to KERNEL, set environment variables, and pass secrets"
35
---
46

57
Kernel's app deployment process is as simple as it is fast. There are no configuration files to manage or complex CI/CD pipelines.
@@ -94,6 +96,87 @@ const client = new Kernel({ apiKey: process.env.MY_KERNEL_API_KEY });
9496

9597
Now the API calls your app makes go out as your key. The deployment key stays in place for Kernel's own use — running the invocation and reporting its result — so your key only needs permissions for the calls you actually make.
9698

99+
## Secrets
100+
101+
Pass API keys and other secrets as [environment variables](#environment-variables) when you deploy, with `--env` or `--env-file`. Then read them in your app:
102+
103+
<CodeGroup>
104+
```typescript TypeScript
105+
import Anthropic from "@anthropic-ai/sdk";
106+
import OpenAI from "openai";
107+
108+
app.action('ai-action', async (ctx: KernelContext) => {
109+
// Access API keys from environment variables
110+
const anthropic = new Anthropic({
111+
apiKey: process.env.ANTHROPIC_API_KEY,
112+
});
113+
114+
const openai = new OpenAI({
115+
apiKey: process.env.OPENAI_API_KEY,
116+
});
117+
118+
// Use the clients...
119+
});
120+
```
121+
122+
```python Python
123+
import os
124+
from anthropic import Anthropic
125+
from openai import OpenAI
126+
127+
@app.action("ai-action")
128+
async def ai_action(ctx: KernelContext):
129+
# Access API keys from environment variables
130+
anthropic = Anthropic(
131+
api_key=os.environ.get("ANTHROPIC_API_KEY"),
132+
)
133+
134+
openai = OpenAI(
135+
api_key=os.environ.get("OPENAI_API_KEY"),
136+
)
137+
138+
# Use the clients...
139+
```
140+
</CodeGroup>
141+
142+
### Per-invocation secrets
143+
144+
For use cases where different API keys are needed per invocation (such as platforms using end-user keys), pass the secrets at runtime using the [payload parameter](/apps/invoke#payload-parameter).
145+
146+
Use encryption standards in your app to protect sensitive data.
147+
148+
<CodeGroup>
149+
```typescript TypeScript
150+
import OpenAI from "openai";
151+
152+
app.action('ai-action', async (ctx: KernelContext, payload) => {
153+
// Decrypt the API key passed at runtime
154+
const apiKey = decrypt(payload.encryptedApiKey);
155+
156+
const openai = new OpenAI({
157+
apiKey: apiKey,
158+
});
159+
160+
// Use the client with the user's API key...
161+
});
162+
```
163+
164+
```python Python
165+
from openai import OpenAI
166+
167+
@app.action("ai-action")
168+
async def ai_action(ctx: KernelContext, payload):
169+
# Decrypt the API key passed at runtime
170+
api_key = decrypt(payload["encryptedApiKey"])
171+
172+
openai = OpenAI(
173+
api_key=api_key,
174+
)
175+
176+
# Use the client with the user's API key...
177+
```
178+
</CodeGroup>
179+
97180
## Deployment notes
98181

99182
- **The dependency manifest (`package.json` for JS/TS, `pyproject.toml` for Python) must be present in the root directory of your project.**

‎apps/develop.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
title: "Developing"
2+
title: "Develop an App"
3+
sidebarTitle: "Develop"
4+
description: "Build an app with actions that run co-located with KERNEL browsers"
35
---
46

57
In addition to our browser API, Kernel provides a code execution platform for deploying and invoking code. Typically, Kernel's code execution platform is used for deploying and invoking browser automations or web agents.

‎apps/invoke.mdx‎

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
title: "Invoking"
2+
title: "Invoke an App"
3+
sidebarTitle: "Invoke"
4+
description: "Run an app action from the API or CLI, pass a payload, and stop a running invocation"
35
---
46

57
## Via API
@@ -154,4 +156,67 @@ See [here](/apps/develop#parameters) to learn how to access the payload in your
154156

155157
If your action specifies a [return value](/apps/develop#return-values), the invocation returns its value once it completes. (The Kernel CLI uses asynchronous invocations under the hood)
156158

159+
160+
## Stop an invocation
161+
162+
You can terminate an invocation that's running. This is useful for stopping automations or agents stuck in an infinite loop.
163+
164+
<Info>
165+
Terminating an invocation also destroys any browsers associated with it.
166+
</Info>
167+
168+
### Via API
169+
You can stop an invocation by setting its status to `failed`. This will cancel the invocation and mark it as terminated.
170+
171+
<CodeGroup>
172+
```typescript Typescript/Javascript
173+
import Kernel from '@onkernel/sdk';
174+
175+
const kernel = new Kernel();
176+
177+
const invocation = await kernel.invocations.update('invocation_id', {
178+
status: 'failed',
179+
output: JSON.stringify({ error: 'Invocation cancelled by user' }),
180+
});
181+
```
182+
183+
```python Python
184+
from kernel import Kernel
185+
186+
kernel = Kernel()
187+
invocation = kernel.invocations.update(
188+
id="invocation_id",
189+
status="failed",
190+
output='{"error":"Invocation cancelled by user"}',
191+
)
192+
```
193+
194+
```go Go
195+
package main
196+
197+
import (
198+
"context"
199+
200+
"github.com/kernel/kernel-go-sdk"
201+
)
202+
203+
func main() {
204+
ctx := context.Background()
205+
client := kernel.NewClient()
206+
207+
invocation, err := client.Invocations.Update(ctx, "invocation_id", kernel.InvocationUpdateParams{
208+
Status: kernel.InvocationUpdateParamsStatusFailed,
209+
Output: kernel.String(`{"error":"Invocation cancelled by user"}`),
210+
})
211+
if err != nil {
212+
panic(err)
213+
}
214+
_ = invocation
215+
}
216+
```
217+
</CodeGroup>
218+
219+
### Via CLI
220+
Use `ctrl-c` in the terminal tab where you launched the invocation.
221+
157222
App invocations accrue compute usage separately from any browsers they create. See the [pricing FAQ](/info/pricing#faq) for how app invocations are charged.

‎apps/logs.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
title: "Logs"
2+
title: "Invocation Logs"
3+
sidebarTitle: "Logs"
4+
description: "Stream an invocation's logs from the API or CLI"
35
---
46

57
## Via API

‎apps/secrets.mdx‎

Lines changed: 0 additions & 104 deletions
This file was deleted.

‎apps/status.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
2-
title: "Status"
2+
title: "Invocation Status"
3+
sidebarTitle: "Status"
4+
description: "Follow an invocation's status by streaming or polling"
35
---
46

57
Once you've [deployed](/apps/deploy) an app and invoked it, you can monitor its status using streaming for real-time updates or polling for periodic checks.

‎apps/stop.mdx‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)