@bastani/atomic 0.9.19-alpha.5 → 0.9.19-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/broker/client.ts +19 -1
- package/dist/builtin/intercom/index.bundle.mjs +8 -1
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/README.md +3 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +7 -7
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +2 -1
- package/dist/builtin/web-access/CHANGELOG.md +13 -0
- package/dist/builtin/web-access/README.md +31 -24
- package/dist/builtin/web-access/index.bundle.mjs +16121 -80
- package/dist/builtin/web-access/package.json +2 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +1 -1
- package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
- package/dist/builtin/workflows/builtin/{chunk-vhmnzdj9.js → chunk-1jth021m.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-p8jjwfg6.js → chunk-2377r57g.js} +4 -2
- package/dist/builtin/workflows/builtin/{chunk-hbnwv56f.js → chunk-31j2gs7h.js} +2 -2
- package/dist/builtin/workflows/builtin/{chunk-n8zysf1t.js → chunk-ngkqkzej.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-1nbq96fh.js → chunk-nkrafh9s.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-1kx4aggw.js → chunk-wf741bv3.js} +2 -2
- package/dist/builtin/workflows/builtin/{chunk-t6x2d78s.js → chunk-z29qbehr.js} +1 -1
- package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +7 -7
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/tournament.js +2 -2
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +339 -31
- package/dist/builtin/workflows/src/index.js +67 -19
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +10 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +91 -12
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-coordinator.js +300 -0
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +14 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +15 -3
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +9 -0
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +12 -1
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/index.d.ts +9 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +67 -12
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
- package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
- package/dist/core/tools/non-minting-snapshot-store.js +64 -0
- package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
- package/dist/core/tools/powershell.d.ts +2 -2
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +2 -5
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read-document-extract.js.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/write.d.ts +30 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +97 -8
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/task-live-transcript.d.ts +1 -1
- package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-live-transcript.js +19 -11
- package/dist/modes/interactive/components/task-live-transcript.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +28 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +3 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
- package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +2 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +23 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +20 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/utils/markit.d.ts +2 -0
- package/dist/utils/markit.d.ts.map +1 -1
- package/dist/utils/markit.js +65 -5
- package/dist/utils/markit.js.map +1 -1
- package/docs/background-tasks.md +15 -11
- package/docs/build.md +51 -0
- package/docs/changelog.mdx +8 -8
- package/docs/compaction/reference.md +267 -0
- package/docs/compaction.md +36 -219
- package/docs/computer-use.md +35 -0
- package/docs/containerization.md +9 -5
- package/docs/custom-provider/api-reference.md +145 -0
- package/docs/custom-provider/oauth.md +131 -0
- package/docs/custom-provider/override.md +34 -0
- package/docs/custom-provider/registration.md +163 -0
- package/docs/custom-provider/streaming.md +214 -0
- package/docs/custom-provider.md +43 -607
- package/docs/development.md +87 -0
- package/docs/docs.json +199 -76
- package/docs/environment-variables.md +1 -1
- package/docs/extensions/api-reference.md +1001 -0
- package/docs/extensions/authoring.md +676 -0
- package/docs/extensions/events.md +793 -0
- package/docs/extensions/examples.md +94 -0
- package/docs/extensions/ui.md +470 -0
- package/docs/extensions.md +270 -2768
- package/docs/getting-started/authentication.md +55 -0
- package/docs/getting-started/first-session.md +172 -0
- package/docs/getting-started/installation.md +154 -0
- package/docs/getting-started/project-instructions.md +43 -0
- package/docs/guides/configuration.md +65 -0
- package/docs/guides/intercom.md +24 -0
- package/docs/guides/non-interactive.md +33 -0
- package/docs/guides/subagents.md +24 -0
- package/docs/guides/workflows.md +27 -0
- package/docs/guides.md +41 -0
- package/docs/index.md +13 -45
- package/docs/intercom/operations.md +178 -0
- package/docs/intercom/reference.md +146 -0
- package/docs/intercom.md +54 -259
- package/docs/json.md +17 -0
- package/docs/llama-cpp.md +5 -0
- package/docs/models/artificial-analysis-index.md +89 -0
- package/docs/models/evals.md +2 -2
- package/docs/models/model-selection.md +3 -3
- package/docs/models/pareto-efficiency.md +2 -2
- package/docs/models/reference.md +601 -0
- package/docs/models.md +45 -550
- package/docs/packages/authoring.md +88 -0
- package/docs/packages/reference.md +43 -0
- package/docs/packages.md +28 -107
- package/docs/programmatic.md +29 -0
- package/docs/prompt-templates.md +11 -0
- package/docs/providers/reference.md +23 -0
- package/docs/providers.md +10 -15
- package/docs/quickstart.md +44 -238
- package/docs/reference/cli.md +252 -0
- package/docs/reference.md +52 -0
- package/docs/rpc/examples.md +64 -0
- package/docs/rpc/extension-ui.md +198 -0
- package/docs/rpc/protocol.md +1341 -0
- package/docs/rpc.md +109 -1346
- package/docs/sdk/reference.md +1090 -0
- package/docs/sdk.md +56 -1002
- package/docs/session-format.md +2 -0
- package/docs/sessions.md +6 -10
- package/docs/settings.md +6 -45
- package/docs/skills/authoring.md +95 -0
- package/docs/skills/reference.md +60 -0
- package/docs/skills.md +20 -122
- package/docs/subagents/authoring.md +37 -0
- package/docs/subagents/reference.md +60 -0
- package/docs/subagents.md +42 -96
- package/docs/terminal-setup.md +1 -1
- package/docs/themes/reference.md +176 -0
- package/docs/themes.md +21 -135
- package/docs/tmux.md +5 -0
- package/docs/tools/edit.md +5 -0
- package/docs/tools.md +31 -0
- package/docs/tui/reference.md +343 -0
- package/docs/tui.md +23 -286
- package/docs/usage.md +26 -209
- package/docs/web-access.md +40 -0
- package/docs/windows.md +2 -1
- package/docs/workflows/api-reference.md +11 -4
- package/docs/workflows/authoring.md +4 -2
- package/docs/workflows/builtins.md +2 -2
- package/docs/workflows/operations.md +11 -7
- package/docs/workflows/reliable-design.md +21 -3
- package/docs/workflows/verification.md +8 -0
- package/examples/extensions/gondolin/index.ts +116 -148
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/ssh.ts +56 -34
- package/npm-shrinkwrap.json +33 -33
- package/package.json +4 -4
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Provider streaming API
|
|
3
|
+
description: "Implement a custom streaming API: events, content blocks, tool calls, stop reasons, and usage."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Provider streaming API
|
|
7
|
+
|
|
8
|
+
## Custom Streaming API
|
|
9
|
+
|
|
10
|
+
For providers with non-standard APIs, implement `streamSimple`. Study the existing API implementations before writing your own:
|
|
11
|
+
|
|
12
|
+
**Reference implementations:**
|
|
13
|
+
|
|
14
|
+
Atomic uses provider implementations from its installed `@bastani/pi-ai` dependency. The streaming implementations behind the `api` field live under `node_modules/@bastani/pi-ai/dist/api/`, including:
|
|
15
|
+
- `anthropic-messages.d.ts` / `anthropic-messages.js` - Anthropic Messages API
|
|
16
|
+
- `mistral-conversations.d.ts` / `mistral-conversations.js` - Mistral Conversations/Chat streaming
|
|
17
|
+
- `openai-completions.d.ts` / `openai-completions.js` - OpenAI Chat Completions
|
|
18
|
+
- `openai-responses.d.ts` / `openai-responses.js` - OpenAI Responses API
|
|
19
|
+
- `google-generative-ai.d.ts` / `google-generative-ai.js` - Google Generative AI
|
|
20
|
+
- `bedrock-converse-stream.d.ts` / `bedrock-converse-stream.js` - Amazon Bedrock Converse API
|
|
21
|
+
Per-vendor provider configurations (base URLs, auth, model catalogs) live under `dist/providers/`, for example `anthropic.d.ts` / `anthropic.js` and `mistral.d.ts` / `mistral.js`.
|
|
22
|
+
|
|
23
|
+
### Stream Pattern
|
|
24
|
+
|
|
25
|
+
All providers follow the same pattern:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import {
|
|
29
|
+
type AssistantMessage,
|
|
30
|
+
type AssistantMessageEventStream,
|
|
31
|
+
type Context,
|
|
32
|
+
type Model,
|
|
33
|
+
type SimpleStreamOptions,
|
|
34
|
+
calculateCost,
|
|
35
|
+
createAssistantMessageEventStream,
|
|
36
|
+
} from "@bastani/pi-ai";
|
|
37
|
+
|
|
38
|
+
function streamMyProvider(
|
|
39
|
+
model: Model<any>,
|
|
40
|
+
context: Context,
|
|
41
|
+
options?: SimpleStreamOptions
|
|
42
|
+
): AssistantMessageEventStream {
|
|
43
|
+
const stream = createAssistantMessageEventStream();
|
|
44
|
+
|
|
45
|
+
(async () => {
|
|
46
|
+
// Initialize output message
|
|
47
|
+
const output: AssistantMessage = {
|
|
48
|
+
role: "assistant",
|
|
49
|
+
content: [],
|
|
50
|
+
api: model.api,
|
|
51
|
+
provider: model.provider,
|
|
52
|
+
model: model.id,
|
|
53
|
+
usage: {
|
|
54
|
+
input: 0,
|
|
55
|
+
output: 0,
|
|
56
|
+
cacheRead: 0,
|
|
57
|
+
cacheWrite: 0,
|
|
58
|
+
totalTokens: 0,
|
|
59
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
60
|
+
},
|
|
61
|
+
stopReason: "pending",
|
|
62
|
+
timestamp: Date.now(),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
// Push start event
|
|
67
|
+
stream.push({ type: "start", partial: output });
|
|
68
|
+
|
|
69
|
+
// Make API request and process response...
|
|
70
|
+
// Push content events as they arrive, and set output.stopReason from the
|
|
71
|
+
// terminal event. A reason your provider sends that you do not map must
|
|
72
|
+
// become an error, not a silent "stop".
|
|
73
|
+
if (output.stopReason === "pending") {
|
|
74
|
+
throw new Error("Provider stream ended without a stop reason");
|
|
75
|
+
}
|
|
76
|
+
if (output.stopReason === "error" || output.stopReason === "aborted") {
|
|
77
|
+
throw new Error(output.errorMessage || "An unknown error occurred");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Push done event
|
|
81
|
+
stream.push({
|
|
82
|
+
type: "done",
|
|
83
|
+
reason: output.stopReason,
|
|
84
|
+
message: output
|
|
85
|
+
});
|
|
86
|
+
stream.end();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
89
|
+
output.errorMessage = error instanceof Error ? error.message : String(error);
|
|
90
|
+
stream.push({ type: "error", reason: output.stopReason, error: output });
|
|
91
|
+
stream.end();
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
|
|
95
|
+
return stream;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Event Types
|
|
100
|
+
|
|
101
|
+
Push events via `stream.push()` in this order:
|
|
102
|
+
|
|
103
|
+
1. `{ type: "start", partial: output }` - Stream started
|
|
104
|
+
|
|
105
|
+
2. Content events (repeatable, track `contentIndex` for each block):
|
|
106
|
+
- `{ type: "text_start", contentIndex, partial }` - Text block started
|
|
107
|
+
- `{ type: "text_delta", contentIndex, delta, partial }` - Text chunk
|
|
108
|
+
- `{ type: "text_end", contentIndex, content, partial }` - Text block ended
|
|
109
|
+
- `{ type: "thinking_start", contentIndex, partial }` - Thinking started
|
|
110
|
+
- `{ type: "thinking_delta", contentIndex, delta, partial }` - Thinking chunk
|
|
111
|
+
- `{ type: "thinking_end", contentIndex, content, partial }` - Thinking ended
|
|
112
|
+
- `{ type: "toolcall_start", contentIndex, partial }` - Tool call started
|
|
113
|
+
- `{ type: "toolcall_delta", contentIndex, delta, partial }` - Tool call JSON chunk
|
|
114
|
+
- `{ type: "toolcall_end", contentIndex, toolCall, partial }` - Tool call ended
|
|
115
|
+
|
|
116
|
+
3. `{ type: "done", reason, message }` or `{ type: "error", reason, error }` - Stream ended
|
|
117
|
+
|
|
118
|
+
The `partial` field in each event contains the current `AssistantMessage` state. Update `output.content` as you receive data, then include `output` as the `partial`.
|
|
119
|
+
|
|
120
|
+
### Stop Reasons
|
|
121
|
+
|
|
122
|
+
`StopReason` is `"pending" | "stop" | "length" | "toolUse" | "error" | "aborted"`.
|
|
123
|
+
|
|
124
|
+
Start the partial message at `"pending"`. It is the reason every in-flight message carries, and it says the terminal event has not arrived yet — it is not a default standing in for `"stop"`. Set the real reason when the provider says the turn ended, then push `done` with it.
|
|
125
|
+
|
|
126
|
+
Two checks belong immediately before `done`:
|
|
127
|
+
|
|
128
|
+
- a stream that reached the end while still `"pending"` never received a terminal event, so raise rather than report a stop that did not happen;
|
|
129
|
+
- `"error"` and `"aborted"` are failures, so raise them with `output.errorMessage` and let the `catch` push an `error` event.
|
|
130
|
+
|
|
131
|
+
`done` accepts only `"stop"`, `"length"`, and `"toolUse"`, which is exactly what those two checks leave, so the `as "stop" | "length" | "toolUse"` cast older implementations used is no longer needed.
|
|
132
|
+
|
|
133
|
+
Map each raw reason your provider can send onto one of the five terminal values, and **raise on one you do not recognise** rather than falling back to `"stop"`. This is what the built-in providers do: an unmapped reason becomes a provider error naming the raw value, so a new truncation or safety signal is visible instead of arriving as a turn that looks like it finished normally. The optional `rawStopReason` field on `AssistantMessage` is where the provider's own string belongs when you want to keep it.
|
|
134
|
+
|
|
135
|
+
### Content Blocks
|
|
136
|
+
|
|
137
|
+
Add content blocks to `output.content` as they arrive:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Text block
|
|
141
|
+
output.content.push({ type: "text", text: "" });
|
|
142
|
+
stream.push({ type: "text_start", contentIndex: output.content.length - 1, partial: output });
|
|
143
|
+
|
|
144
|
+
// As text arrives
|
|
145
|
+
const block = output.content[contentIndex];
|
|
146
|
+
if (block.type === "text") {
|
|
147
|
+
block.text += delta;
|
|
148
|
+
stream.push({ type: "text_delta", contentIndex, delta, partial: output });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// When block completes
|
|
152
|
+
stream.push({ type: "text_end", contentIndex, content: block.text, partial: output });
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Tool Calls
|
|
156
|
+
|
|
157
|
+
Tool calls require accumulating JSON and parsing:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
// Start tool call
|
|
161
|
+
output.content.push({
|
|
162
|
+
type: "toolCall",
|
|
163
|
+
id: toolCallId,
|
|
164
|
+
name: toolName,
|
|
165
|
+
arguments: {}
|
|
166
|
+
});
|
|
167
|
+
stream.push({ type: "toolcall_start", contentIndex: output.content.length - 1, partial: output });
|
|
168
|
+
|
|
169
|
+
// Accumulate JSON
|
|
170
|
+
let partialJson = "";
|
|
171
|
+
partialJson += jsonDelta;
|
|
172
|
+
try {
|
|
173
|
+
block.arguments = JSON.parse(partialJson);
|
|
174
|
+
} catch {}
|
|
175
|
+
stream.push({ type: "toolcall_delta", contentIndex, delta: jsonDelta, partial: output });
|
|
176
|
+
|
|
177
|
+
// Complete
|
|
178
|
+
stream.push({
|
|
179
|
+
type: "toolcall_end",
|
|
180
|
+
contentIndex,
|
|
181
|
+
toolCall: { type: "toolCall", id, name, arguments: block.arguments },
|
|
182
|
+
partial: output
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Usage and Cost
|
|
187
|
+
|
|
188
|
+
Update usage from API response and calculate cost:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
output.usage.input = response.usage.input_tokens;
|
|
192
|
+
output.usage.output = response.usage.output_tokens;
|
|
193
|
+
output.usage.cacheRead = response.usage.cache_read_tokens ?? 0;
|
|
194
|
+
output.usage.cacheWrite = response.usage.cache_write_tokens ?? 0;
|
|
195
|
+
output.usage.totalTokens = output.usage.input + output.usage.output +
|
|
196
|
+
output.usage.cacheRead + output.usage.cacheWrite;
|
|
197
|
+
calculateCost(model, output.usage);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`calculateCost()` selects one rate set for the whole request. Aggregate input is `usage.input + usage.cacheRead + usage.cacheWrite`; a tier applies only when that sum is strictly greater than `inputTokensAbove`, and the matching tier with the highest threshold wins. Every tier must provide complete `input`, `output`, `cacheRead`, and `cacheWrite` rates. Extension-registered models preserve these tiers, and matching `models.json` `modelOverrides` use the same replacement rules described in [Custom Models](/models/reference#request-wide-cost-tiers).
|
|
201
|
+
|
|
202
|
+
### Registration
|
|
203
|
+
|
|
204
|
+
Register your stream function:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
pi.registerProvider("my-provider", {
|
|
208
|
+
baseUrl: "https://api.example.com",
|
|
209
|
+
apiKey: "$MY_API_KEY",
|
|
210
|
+
api: "my-custom-api",
|
|
211
|
+
models: [...],
|
|
212
|
+
streamSimple: streamMyProvider
|
|
213
|
+
});
|
|
214
|
+
```
|