@b3os/cli 0.2.1 → 0.2.2
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/README.md +87 -8
- package/assets/b3os-run.py +137 -0
- package/assets/skill/b3os/SKILL.md +111 -0
- package/dist/commands/_agents.d.ts +14 -0
- package/dist/commands/_agents.js +33 -0
- package/dist/commands/_agents.js.map +1 -0
- package/dist/commands/_common.js +6 -2
- package/dist/commands/_common.js.map +1 -1
- package/dist/commands/_context.d.ts +49 -0
- package/dist/commands/_context.js +260 -0
- package/dist/commands/_context.js.map +1 -0
- package/dist/commands/_next.d.ts +39 -0
- package/dist/commands/_next.js +77 -0
- package/dist/commands/_next.js.map +1 -0
- package/dist/commands/agent.d.ts +42 -0
- package/dist/commands/agent.js +218 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/app.d.ts +2 -5
- package/dist/commands/app.js +229 -69
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/auth.d.ts +70 -2
- package/dist/commands/auth.js +308 -33
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/docs.d.ts +54 -0
- package/dist/commands/docs.js +202 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/doctor.d.ts +23 -0
- package/dist/commands/doctor.js +313 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +38 -1
- package/dist/commands/init.js +259 -60
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/listen.d.ts +30 -0
- package/dist/commands/listen.js +194 -0
- package/dist/commands/listen.js.map +1 -0
- package/dist/commands/manifest.d.ts +13 -1
- package/dist/commands/manifest.js +59 -7
- package/dist/commands/manifest.js.map +1 -1
- package/dist/commands/mcp.d.ts +25 -2
- package/dist/commands/mcp.js +120 -11
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/sandbox.d.ts +35 -6
- package/dist/commands/sandbox.js +208 -9
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/setup.d.ts +39 -0
- package/dist/commands/setup.js +203 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/tool.d.ts +109 -1
- package/dist/commands/tool.js +635 -47
- package/dist/commands/tool.js.map +1 -1
- package/dist/config.d.ts +30 -6
- package/dist/config.js +39 -8
- package/dist/config.js.map +1 -1
- package/dist/ctx.d.ts +5 -45
- package/dist/ctx.js +25 -160
- package/dist/ctx.js.map +1 -1
- package/dist/docs/index.json +1 -0
- package/dist/docs/pages/actions/call.md +300 -0
- package/dist/docs/pages/actions/catalog/airtable.md +737 -0
- package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
- package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
- package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
- package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
- package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
- package/dist/docs/pages/actions/catalog/discord.md +784 -0
- package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
- package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
- package/dist/docs/pages/actions/catalog/github.md +1853 -0
- package/dist/docs/pages/actions/catalog/gmail.md +575 -0
- package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
- package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
- package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
- package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
- package/dist/docs/pages/actions/catalog/http.md +824 -0
- package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
- package/dist/docs/pages/actions/catalog/jira.md +920 -0
- package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
- package/dist/docs/pages/actions/catalog/linear.md +1030 -0
- package/dist/docs/pages/actions/catalog/markets.md +21 -0
- package/dist/docs/pages/actions/catalog/morpho.md +247 -0
- package/dist/docs/pages/actions/catalog/notion.md +1077 -0
- package/dist/docs/pages/actions/catalog/nws.md +485 -0
- package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
- package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
- package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
- package/dist/docs/pages/actions/catalog/resend.md +307 -0
- package/dist/docs/pages/actions/catalog/s3.md +513 -0
- package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
- package/dist/docs/pages/actions/catalog/slack.md +2629 -0
- package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
- package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
- package/dist/docs/pages/actions/catalog.md +46 -0
- package/dist/docs/pages/actions/limits.md +50 -0
- package/dist/docs/pages/actions/model-tools.md +225 -0
- package/dist/docs/pages/actions/packs.md +148 -0
- package/dist/docs/pages/actions/settings.md +69 -0
- package/dist/docs/pages/actions/tools.md +244 -0
- package/dist/docs/pages/actions/triggers.md +149 -0
- package/dist/docs/pages/actions.md +88 -0
- package/dist/docs/pages/compat/anthropic.md +168 -0
- package/dist/docs/pages/compat/e2b.md +194 -0
- package/dist/docs/pages/compat/firecrawl.md +138 -0
- package/dist/docs/pages/compat/openai.md +168 -0
- package/dist/docs/pages/concepts/auth.md +151 -0
- package/dist/docs/pages/concepts/beta.md +55 -0
- package/dist/docs/pages/concepts/glossary.md +71 -0
- package/dist/docs/pages/concepts/ids.md +98 -0
- package/dist/docs/pages/concepts/jobs.md +229 -0
- package/dist/docs/pages/concepts/latency.md +138 -0
- package/dist/docs/pages/concepts/limits.md +191 -0
- package/dist/docs/pages/concepts/stack.md +59 -0
- package/dist/docs/pages/concepts/timing.md +86 -0
- package/dist/docs/pages/concepts/usage.md +110 -0
- package/dist/docs/pages/design/b3os-yaml.md +370 -0
- package/dist/docs/pages/design/deploy-from-github.md +122 -0
- package/dist/docs/pages/design/observability.md +134 -0
- package/dist/docs/pages/errors.md +1824 -0
- package/dist/docs/pages/infer/chat.md +570 -0
- package/dist/docs/pages/infer/limits.md +55 -0
- package/dist/docs/pages/infer/messages.md +185 -0
- package/dist/docs/pages/infer/responses.md +173 -0
- package/dist/docs/pages/infer/settings.md +154 -0
- package/dist/docs/pages/infer/speech.md +323 -0
- package/dist/docs/pages/infer.md +154 -0
- package/dist/docs/pages/introduction.md +162 -0
- package/dist/docs/pages/platform/addresses.md +174 -0
- package/dist/docs/pages/platform/call-log.md +99 -0
- package/dist/docs/pages/platform/custom-domains.md +104 -0
- package/dist/docs/pages/platform/keys.md +79 -0
- package/dist/docs/pages/platform/limits.md +57 -0
- package/dist/docs/pages/platform/members.md +101 -0
- package/dist/docs/pages/platform/requests.md +116 -0
- package/dist/docs/pages/platform/settings.md +129 -0
- package/dist/docs/pages/platform/webhooks.md +68 -0
- package/dist/docs/pages/platform.md +67 -0
- package/dist/docs/pages/quickstart/mcp.md +94 -0
- package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
- package/dist/docs/pages/quickstart/scrape.md +134 -0
- package/dist/docs/pages/quickstart.md +45 -0
- package/dist/docs/pages/render/inspections.md +162 -0
- package/dist/docs/pages/render/limits.md +72 -0
- package/dist/docs/pages/render/screenshots.md +179 -0
- package/dist/docs/pages/render/settings.md +431 -0
- package/dist/docs/pages/render/styles.md +342 -0
- package/dist/docs/pages/render/videos.md +272 -0
- package/dist/docs/pages/render.md +118 -0
- package/dist/docs/pages/routines/callables.md +174 -0
- package/dist/docs/pages/routines/definitions.md +361 -0
- package/dist/docs/pages/routines/limits.md +117 -0
- package/dist/docs/pages/routines/runs.md +328 -0
- package/dist/docs/pages/routines/settings.md +104 -0
- package/dist/docs/pages/routines/triggers.md +339 -0
- package/dist/docs/pages/routines.md +216 -0
- package/dist/docs/pages/sandboxes/agents.md +217 -0
- package/dist/docs/pages/sandboxes/commands.md +272 -0
- package/dist/docs/pages/sandboxes/images.md +166 -0
- package/dist/docs/pages/sandboxes/limits.md +143 -0
- package/dist/docs/pages/sandboxes/ports.md +260 -0
- package/dist/docs/pages/sandboxes/settings.md +358 -0
- package/dist/docs/pages/sandboxes/snapshots.md +423 -0
- package/dist/docs/pages/sandboxes/swarms.md +146 -0
- package/dist/docs/pages/sandboxes/volumes.md +131 -0
- package/dist/docs/pages/sandboxes.md +231 -0
- package/dist/docs/pages/sdks/cli.md +121 -0
- package/dist/docs/pages/sdks/mcp.md +169 -0
- package/dist/docs/pages/sdks/python.md +146 -0
- package/dist/docs/pages/sdks/typescript.md +202 -0
- package/dist/docs/pages/sdks.md +282 -0
- package/dist/docs/pages/settings.md +33 -0
- package/dist/docs/pages/vault/limits.md +46 -0
- package/dist/docs/pages/vault.md +133 -0
- package/dist/docs/pages/vision/agent-browser.md +115 -0
- package/dist/docs/pages/vision/crawl.md +333 -0
- package/dist/docs/pages/vision/extract.md +152 -0
- package/dist/docs/pages/vision/fetcher.md +15 -0
- package/dist/docs/pages/vision/limits.md +79 -0
- package/dist/docs/pages/vision/profiles.md +111 -0
- package/dist/docs/pages/vision/proxy.md +131 -0
- package/dist/docs/pages/vision/scrape.md +356 -0
- package/dist/docs/pages/vision/sessions.md +311 -0
- package/dist/docs/pages/vision/settings.md +656 -0
- package/dist/docs/pages/vision.md +175 -0
- package/dist/errors.d.ts +129 -0
- package/dist/errors.js +326 -0
- package/dist/errors.js.map +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.js +26 -13
- package/dist/main.js.map +1 -1
- package/dist/manifest/domains.d.ts +50 -0
- package/dist/manifest/domains.js +159 -0
- package/dist/manifest/domains.js.map +1 -0
- package/dist/manifest/link.d.ts +20 -0
- package/dist/manifest/link.js +24 -0
- package/dist/manifest/link.js.map +1 -0
- package/dist/manifest/record.d.ts +1 -1
- package/dist/tool/archive.d.ts +33 -0
- package/dist/tool/archive.js +174 -0
- package/dist/tool/archive.js.map +1 -0
- package/dist/tool/calls.d.ts +46 -0
- package/dist/tool/calls.js +274 -0
- package/dist/tool/calls.js.map +1 -0
- package/dist/tool/checks.d.ts +21 -0
- package/dist/tool/checks.js +145 -0
- package/dist/tool/checks.js.map +1 -0
- package/dist/tool/elf.d.ts +19 -0
- package/dist/tool/elf.js +107 -0
- package/dist/tool/elf.js.map +1 -0
- package/dist/tool/predict.d.ts +8 -0
- package/dist/tool/predict.js +38 -0
- package/dist/tool/predict.js.map +1 -0
- package/dist/tool/ustar.d.ts +5 -0
- package/dist/tool/ustar.js +220 -0
- package/dist/tool/ustar.js.map +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
# Chat completions
|
|
2
|
+
|
|
3
|
+
> Call the node's model with the OpenAI Chat Completions API, including tool calls, JSON Schema output, streaming, images and reasoning.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/infer/chat.md
|
|
6
|
+
|
|
7
|
+
`POST /v1/infer/chat/completions` is the OpenAI Chat Completions API. Set `B3OS_MODEL` to a chat model's ID from `GET /v1/infer/models` first ([how](https://docs.beta.b3os.org/compat/openai)).
|
|
8
|
+
|
|
9
|
+
## A completion
|
|
10
|
+
|
|
11
|
+
**curl**
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -s https://beta-api.b3os.org/v1/infer/chat/completions \
|
|
15
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
16
|
+
-H "Content-Type: application/json" \
|
|
17
|
+
-d "{\"model\": \"$B3OS_MODEL\", \"messages\": [{\"role\": \"user\", \"content\": \"Name one river in Oregon.\"}]}"
|
|
18
|
+
```
|
|
19
|
+
**TypeScript**
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import OpenAI from "openai";
|
|
23
|
+
|
|
24
|
+
const client = new OpenAI({ apiKey: process.env.B3OS_API_KEY, baseURL: "https://beta-api.b3os.org/v1/infer" });
|
|
25
|
+
const completion = await client.chat.completions.create({
|
|
26
|
+
model: process.env.B3OS_MODEL!,
|
|
27
|
+
messages: [{ role: "user", content: "Name one river in Oregon." }],
|
|
28
|
+
});
|
|
29
|
+
console.log(completion.choices[0].message.content, completion.usage);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The B3OS SDK has the same call as `b3os.infer.createChatCompletion(...)`.
|
|
33
|
+
**Python**
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import os
|
|
37
|
+
from openai import OpenAI
|
|
38
|
+
|
|
39
|
+
client = OpenAI(api_key=os.environ["B3OS_API_KEY"], base_url="https://beta-api.b3os.org/v1/infer")
|
|
40
|
+
completion = client.chat.completions.create(
|
|
41
|
+
model=os.environ["B3OS_MODEL"],
|
|
42
|
+
messages=[{"role": "user", "content": "Name one river in Oregon."}],
|
|
43
|
+
)
|
|
44
|
+
print(completion.choices[0].message.content, completion.usage)
|
|
45
|
+
```
|
|
46
|
+
**MCP**
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
Use the B3OS model to draft three subject lines for this release note: …
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `infer_chat` tool sends a chat completion to the node's model, with the same fields as the API body. It is in the `infer` toolset: start the local server with `--toolsets infer`, or connect to the remote one at `https://beta-api.b3os.org/mcp?toolsets=infer`.
|
|
53
|
+
|
|
54
|
+
Production's answer to that request, with the node's timing in `b3os.timing` and `Server-Timing` (the `edge_*` entries are the edge's; `model` is the time in the model's runtime):
|
|
55
|
+
|
|
56
|
+
**Response 200**
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"b3os": {
|
|
61
|
+
"node": "n1",
|
|
62
|
+
"route": "local",
|
|
63
|
+
"timing": {
|
|
64
|
+
"model_ms": 430.631,
|
|
65
|
+
"total_ms": 430.824
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"choices": [
|
|
69
|
+
{
|
|
70
|
+
"finish_reason": "stop",
|
|
71
|
+
"index": 0,
|
|
72
|
+
"logprobs": null,
|
|
73
|
+
"message": {
|
|
74
|
+
"content": "The **Willamette River** is the most prominent river in Oregon. It is the state's largest river by discharge volume and length, flowing approximately 187 miles through the central part of the state before emptying into the Columbia River in the Portland area. Other notable rivers in Oregon include the Columbia River (which forms part of the state's border) and the Deschutes River.",
|
|
75
|
+
"refusal": null,
|
|
76
|
+
"role": "assistant"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
"created": 1793508869,
|
|
81
|
+
"id": "chatcmpl-req_01m6aqb1dws3wdfjmzh4419y7g",
|
|
82
|
+
"model": "b3os/qwen3.5-9b",
|
|
83
|
+
"object": "chat.completion",
|
|
84
|
+
"system_fingerprint": "vllm-0.31.0-f0b1f1d6",
|
|
85
|
+
"usage": {
|
|
86
|
+
"completion_tokens": 81,
|
|
87
|
+
"completion_tokens_details": {
|
|
88
|
+
"reasoning_tokens": 0
|
|
89
|
+
},
|
|
90
|
+
"prompt_tokens": 18,
|
|
91
|
+
"total_tokens": 99
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Request**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
100
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
101
|
+
-H 'content-type: application/json' \
|
|
102
|
+
-d '{"model":"b3os/qwen3.5-9b","messages":[{"role":"user","content":"Name one river in Oregon."}]}'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Server-Timing**
|
|
106
|
+
|
|
107
|
+
```http
|
|
108
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=442.000, infer_route;desc="local", prep;dur=0.175, model;dur=430.631, total;dur=430.883
|
|
109
|
+
x-request-id: req_01m6aqb1dws3wdfjmzh4419y7g
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
<sub>Captured 2026-11-01 from commit `7d802c58` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-completion`.</sub>
|
|
113
|
+
|
|
114
|
+
## Tool calls
|
|
115
|
+
|
|
116
|
+
Pass `tools` (up to 128) and the model answers with `tool_calls` when it wants one; send the result back as a `tool` message:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"model": "b3os/your-chat-model",
|
|
121
|
+
"messages": [
|
|
122
|
+
{ "role": "system", "content": "You are a concise assistant." },
|
|
123
|
+
{ "role": "user", "content": "What is the weather in Eugene?" }
|
|
124
|
+
],
|
|
125
|
+
"tools": [{
|
|
126
|
+
"type": "function",
|
|
127
|
+
"function": {
|
|
128
|
+
"name": "get_weather",
|
|
129
|
+
"description": "Current weather for a city.",
|
|
130
|
+
"parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] }
|
|
131
|
+
}
|
|
132
|
+
}]
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The answer asks for the tool: `finish_reason` is `tool_calls` and `arguments` is a JSON string, as OpenAI returns it (this request adds `"temperature": 0`):
|
|
137
|
+
|
|
138
|
+
**Response 200**
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"b3os": {
|
|
143
|
+
"node": "n1",
|
|
144
|
+
"route": "local",
|
|
145
|
+
"timing": {
|
|
146
|
+
"model_ms": 262.192,
|
|
147
|
+
"total_ms": 262.399
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"choices": [
|
|
151
|
+
{
|
|
152
|
+
"finish_reason": "tool_calls",
|
|
153
|
+
"index": 0,
|
|
154
|
+
"logprobs": null,
|
|
155
|
+
"message": {
|
|
156
|
+
"content": null,
|
|
157
|
+
"refusal": null,
|
|
158
|
+
"role": "assistant",
|
|
159
|
+
"tool_calls": [
|
|
160
|
+
{
|
|
161
|
+
"function": {
|
|
162
|
+
"arguments": "{\"city\": \"Eugene\"}",
|
|
163
|
+
"name": "get_weather"
|
|
164
|
+
},
|
|
165
|
+
"id": "chatcmpl-tool-9cf52221215c05e0",
|
|
166
|
+
"type": "function"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"created": 1793508871,
|
|
173
|
+
"id": "chatcmpl-req_01m6aqb35zarksagdyzp9f1j08",
|
|
174
|
+
"model": "b3os/qwen3.5-9b",
|
|
175
|
+
"object": "chat.completion",
|
|
176
|
+
"system_fingerprint": "vllm-0.31.0-f0b1f1d6",
|
|
177
|
+
"usage": {
|
|
178
|
+
"completion_tokens": 28,
|
|
179
|
+
"completion_tokens_details": {
|
|
180
|
+
"reasoning_tokens": 0
|
|
181
|
+
},
|
|
182
|
+
"prompt_tokens": 283,
|
|
183
|
+
"total_tokens": 311
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Request**
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
192
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
193
|
+
-H 'content-type: application/json' \
|
|
194
|
+
-d '{"model":"b3os/qwen3.5-9b","temperature":0,"messages":[{"role":"system","content":"You are a concise assistant."},{"role":"user","content":"What is the weather in Eugene?"}],"tools":[{"type":"function","function":{"name":"get_weather","description":"Current weather for a city.","parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}]}'
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Server-Timing**
|
|
198
|
+
|
|
199
|
+
```http
|
|
200
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=653.000, infer_route;desc="local", prep;dur=0.190, model;dur=262.192, total;dur=262.455
|
|
201
|
+
x-request-id: req_01m6aqb35zarksagdyzp9f1j08
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
<sub>Captured 2026-11-01 from commit `7d802c58` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-tool-call`.</sub>
|
|
205
|
+
|
|
206
|
+
`tool_choice` takes `none`, `auto`, `required` or a named function, and `parallel_tool_calls` is accepted. The [sandbox agent quickstart](https://docs.beta.b3os.org/quickstart/sandbox-agent) runs a full tool loop against the node.
|
|
207
|
+
|
|
208
|
+
## JSON Schema output
|
|
209
|
+
|
|
210
|
+
`response_format` with `type: "json_schema"` constrains the answer to your schema, on models whose `b3os.json_schema` is true. A schema (here, or in a tool's `parameters`) larger than 64 KiB or nested deeper than 32 levels is refused with `unsupported_parameter`:
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"model": "b3os/your-chat-model",
|
|
215
|
+
"response_format": {
|
|
216
|
+
"type": "json_schema",
|
|
217
|
+
"json_schema": {
|
|
218
|
+
"name": "city",
|
|
219
|
+
"schema": { "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"] }
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"messages": [{ "role": "user", "content": "Name a city in Oregon as JSON." }]
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
`message.content` is a JSON string that matches the schema:
|
|
227
|
+
|
|
228
|
+
**Response 200**
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"b3os": {
|
|
233
|
+
"node": "n1",
|
|
234
|
+
"route": "local",
|
|
235
|
+
"timing": {
|
|
236
|
+
"model_ms": 54.477,
|
|
237
|
+
"total_ms": 54.671
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"choices": [
|
|
241
|
+
{
|
|
242
|
+
"finish_reason": "stop",
|
|
243
|
+
"index": 0,
|
|
244
|
+
"logprobs": null,
|
|
245
|
+
"message": {
|
|
246
|
+
"content": "{\"name\": \"Portland\"}",
|
|
247
|
+
"refusal": null,
|
|
248
|
+
"role": "assistant"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"created": 1793508870,
|
|
253
|
+
"id": "chatcmpl-req_01m6aqb2682rsvsgwwh41phtfs",
|
|
254
|
+
"model": "b3os/qwen3.5-9b",
|
|
255
|
+
"object": "chat.completion",
|
|
256
|
+
"system_fingerprint": "vllm-0.31.0-f0b1f1d6",
|
|
257
|
+
"usage": {
|
|
258
|
+
"completion_tokens": 7,
|
|
259
|
+
"completion_tokens_details": {
|
|
260
|
+
"reasoning_tokens": 0
|
|
261
|
+
},
|
|
262
|
+
"prompt_tokens": 20,
|
|
263
|
+
"total_tokens": 27
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Request**
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
272
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
273
|
+
-H 'content-type: application/json' \
|
|
274
|
+
-d '{"model":"b3os/qwen3.5-9b","temperature":0,"response_format":{"type":"json_schema","json_schema":{"name":"city","schema":{"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}}},"messages":[{"role":"user","content":"Name a city in Oregon as JSON."}]}'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Server-Timing**
|
|
278
|
+
|
|
279
|
+
```http
|
|
280
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=67.000, infer_route;desc="local", prep;dur=0.181, model;dur=54.477, total;dur=54.728
|
|
281
|
+
x-request-id: req_01m6aqb2682rsvsgwwh41phtfs
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
<sub>Captured 2026-11-01 from commit `7d802c58` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-json-schema`.</sub>
|
|
285
|
+
|
|
286
|
+
The model writes the fields in the order your schema lists them, as OpenAI documents for structured outputs: the node passes the schema, and every tool's `parameters`, through with your key order. Put the fields the model should work out first ahead of the ones that depend on them, a `working` or `reasoning` field before `answer`. The same holds for Responses' `text.format.schema` and Messages' `output_config.format.schema` and `input_schema`.
|
|
287
|
+
|
|
288
|
+
## Streaming
|
|
289
|
+
|
|
290
|
+
With `"stream": true` the response is server-sent `chat.completion.chunk` objects ending with `data: [DONE]`, exactly as OpenAI sends them. `"stream_options": {"include_usage": true}` adds a final chunk with the token counts, and on the node also `b3os.timing.ttft_ms`, the time to the first token inside the node. A stream may run up to 10 minutes.
|
|
291
|
+
|
|
292
|
+
**Events (16)**
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
event: message
|
|
296
|
+
data: {"choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
297
|
+
|
|
298
|
+
event: message
|
|
299
|
+
data: {"choices":[{"delta":{"content":"The"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
300
|
+
|
|
301
|
+
event: message
|
|
302
|
+
data: {"choices":[{"delta":{"content":" Columbia"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
303
|
+
|
|
304
|
+
event: message
|
|
305
|
+
data: {"choices":[{"delta":{"content":" River"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
306
|
+
|
|
307
|
+
event: message
|
|
308
|
+
data: {"choices":[{"delta":{"content":" is"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
309
|
+
|
|
310
|
+
event: message
|
|
311
|
+
data: {"choices":[{"delta":{"content":" a"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
312
|
+
|
|
313
|
+
event: message
|
|
314
|
+
data: {"choices":[{"delta":{"content":" major"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
315
|
+
|
|
316
|
+
event: message
|
|
317
|
+
data: {"choices":[{"delta":{"content":" river"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
318
|
+
|
|
319
|
+
event: message
|
|
320
|
+
data: {"choices":[{"delta":{"content":" that"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
321
|
+
|
|
322
|
+
event: message
|
|
323
|
+
data: {"choices":[{"delta":{"content":" flows"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
324
|
+
|
|
325
|
+
event: message
|
|
326
|
+
data: {"choices":[{"delta":{"content":" through"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
327
|
+
|
|
328
|
+
event: message
|
|
329
|
+
data: {"choices":[{"delta":{"content":" Oregon"},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
330
|
+
|
|
331
|
+
event: message
|
|
332
|
+
data: {"choices":[{"delta":{"content":"."},"finish_reason":null,"index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
333
|
+
|
|
334
|
+
event: message
|
|
335
|
+
data: {"choices":[{"delta":{},"finish_reason":"stop","index":0,"logprobs":null}],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":null}
|
|
336
|
+
|
|
337
|
+
event: message
|
|
338
|
+
data: {"b3os":{"node":"n1","route":"local","timing":{"total_ms":128.286,"ttft_ms":127.989}},"choices":[],"created":1793508871,"id":"chatcmpl-req_01m6aqb2v0e9yryb5964yc4zed","model":"b3os/qwen3.5-9b","object":"chat.completion.chunk","usage":{"completion_tokens":13,"completion_tokens_details":{"reasoning_tokens":0},"prompt_tokens":23,"total_tokens":36}}
|
|
339
|
+
|
|
340
|
+
event: message
|
|
341
|
+
data: "[DONE]"
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**Request**
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
348
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
349
|
+
-H 'accept: text/event-stream' \
|
|
350
|
+
-H 'content-type: application/json' \
|
|
351
|
+
-d '{"model":"b3os/qwen3.5-9b","temperature":0,"max_tokens":32,"stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Name one river in Oregon, in one short sentence."}]}'
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Server-Timing**
|
|
355
|
+
|
|
356
|
+
```http
|
|
357
|
+
server-timing: edge_auth;dur=0.000, edge_upstream;dur=139.000, infer_route;desc="local", prep;dur=0.232, upstream;dur=7.322, ttft;dur=127.989
|
|
358
|
+
x-request-id: req_01m6aqb2v0e9yryb5964yc4zed
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
<sub>Captured 2026-11-01 from commit `7d802c58` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-stream-usage`.</sub>
|
|
362
|
+
|
|
363
|
+
`usage.prompt_tokens_details.cached_tokens` says how many prompt tokens the runtime's prefix cache served, from your organization's earlier requests; the cache works in whole blocks of 1,056 tokens on the beta's chat model, so a prompt shorter than that never reads from it. Cached tokens are part of `prompt_tokens`: they are metered like the rest and count in full against the [tokens-per-minute limit](https://docs.beta.b3os.org/infer/limits).
|
|
364
|
+
|
|
365
|
+
## Images
|
|
366
|
+
|
|
367
|
+
On models whose `b3os.image_input` is true, user messages can carry images, as in the OpenAI API: `https://` URLs, which the node fetches through its egress guard (the model's runtime never fetches anything), or `data:` URIs. Each image is resized to about a megapixel, up to 8 per request on the beta's chat model. A URL on a private, loopback or metadata address fails with `403 egress_denied`. Images must be PNG, JPEG, WebP or GIF, and the file's first bytes decide, not the `Content-Type` the host sends: anything else is `400 invalid_request` naming the image.
|
|
368
|
+
|
|
369
|
+
An image goes in a user message's `content` list, after or between text parts:
|
|
370
|
+
|
|
371
|
+
**curl**
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
curl -s https://beta-api.b3os.org/v1/infer/chat/completions \
|
|
375
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
376
|
+
-H "Content-Type: application/json" \
|
|
377
|
+
-d "{\"model\": \"$B3OS_MODEL\", \"temperature\": 0, \"messages\": [{\"role\": \"user\", \"content\": [
|
|
378
|
+
{\"type\": \"text\", \"text\": \"What does this image say? Answer in one sentence.\"},
|
|
379
|
+
{\"type\": \"image_url\", \"image_url\": {\"url\": \"https://beta.b3os.org/og.png\"}}]}]}"
|
|
380
|
+
```
|
|
381
|
+
**TypeScript**
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
import OpenAI from "openai";
|
|
385
|
+
|
|
386
|
+
const client = new OpenAI({ apiKey: process.env.B3OS_API_KEY, baseURL: "https://beta-api.b3os.org/v1/infer" });
|
|
387
|
+
const completion = await client.chat.completions.create({
|
|
388
|
+
model: process.env.B3OS_MODEL!,
|
|
389
|
+
temperature: 0,
|
|
390
|
+
messages: [
|
|
391
|
+
{
|
|
392
|
+
role: "user",
|
|
393
|
+
content: [
|
|
394
|
+
{ type: "text", text: "What does this image say? Answer in one sentence." },
|
|
395
|
+
{ type: "image_url", image_url: { url: "https://beta.b3os.org/og.png" } },
|
|
396
|
+
],
|
|
397
|
+
},
|
|
398
|
+
],
|
|
399
|
+
});
|
|
400
|
+
console.log(completion.choices[0].message.content, completion.usage?.prompt_tokens);
|
|
401
|
+
```
|
|
402
|
+
**Python**
|
|
403
|
+
|
|
404
|
+
```python
|
|
405
|
+
import base64
|
|
406
|
+
import os
|
|
407
|
+
from openai import OpenAI
|
|
408
|
+
|
|
409
|
+
client = OpenAI(api_key=os.environ["B3OS_API_KEY"], base_url="https://beta-api.b3os.org/v1/infer")
|
|
410
|
+
image = {"url": "https://beta.b3os.org/og.png"}
|
|
411
|
+
# A local file goes as a data: URI instead:
|
|
412
|
+
# image = {"url": "data:image/png;base64," + base64.b64encode(open("shot.png", "rb").read()).decode()}
|
|
413
|
+
completion = client.chat.completions.create(
|
|
414
|
+
model=os.environ["B3OS_MODEL"],
|
|
415
|
+
temperature=0,
|
|
416
|
+
messages=[{"role": "user", "content": [
|
|
417
|
+
{"type": "text", "text": "What does this image say? Answer in one sentence."},
|
|
418
|
+
{"type": "image_url", "image_url": image},
|
|
419
|
+
]}],
|
|
420
|
+
)
|
|
421
|
+
print(completion.choices[0].message.content, completion.usage.prompt_tokens)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Production's answer, reading the site's own launch card. The image counts as prompt tokens (`multimodal_tokens.image` in `usage.prompt_tokens_details`), metered like text:
|
|
425
|
+
|
|
426
|
+
**Response 200**
|
|
427
|
+
|
|
428
|
+
```json
|
|
429
|
+
{
|
|
430
|
+
"b3os": {
|
|
431
|
+
"node": "n1",
|
|
432
|
+
"route": "local",
|
|
433
|
+
"timing": {
|
|
434
|
+
"model_ms": 762.013,
|
|
435
|
+
"total_ms": 881.001
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
"choices": [
|
|
439
|
+
{
|
|
440
|
+
"finish_reason": "stop",
|
|
441
|
+
"index": 0,
|
|
442
|
+
"logprobs": null,
|
|
443
|
+
"message": {
|
|
444
|
+
"content": "This image promotes a beta platform called B3OS that provides agent tools—such as browsers, sandboxes, rendering, and routines—directly on the machine serving the AI model, running on B3IQ compute infrastructure.",
|
|
445
|
+
"refusal": null,
|
|
446
|
+
"role": "assistant"
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
"created": 1793800470,
|
|
451
|
+
"id": "chatcmpl-req_01m6kddz11ex9ef866ftmdgpe3",
|
|
452
|
+
"model": "b3os/qwen3.5-9b",
|
|
453
|
+
"object": "chat.completion",
|
|
454
|
+
"system_fingerprint": "vllm-0.31.0-f0b1f1d6",
|
|
455
|
+
"usage": {
|
|
456
|
+
"completion_tokens": 46,
|
|
457
|
+
"completion_tokens_details": {
|
|
458
|
+
"reasoning_tokens": 0
|
|
459
|
+
},
|
|
460
|
+
"prompt_tokens": 785,
|
|
461
|
+
"prompt_tokens_details": {
|
|
462
|
+
"cached_tokens": 0,
|
|
463
|
+
"created_cache_tokens": 0,
|
|
464
|
+
"multimodal_tokens": {
|
|
465
|
+
"image": 760
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"total_tokens": 831
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
**Request**
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
477
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
478
|
+
-H 'content-type: application/json' \
|
|
479
|
+
-d '{"model":"b3os/qwen3.5-9b","temperature":0,"messages":[{"role":"user","content":[{"type":"text","text":"What does this image say? Answer in one sentence."},{"type":"image_url","image_url":{"url":"https://beta.b3os.org/og.png"}}]}]}'
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Server-Timing**
|
|
483
|
+
|
|
484
|
+
```http
|
|
485
|
+
server-timing: edge_auth;dur=27.000, edge_upstream;dur=951.000, infer_route;desc="local", prep;dur=118.969, model;dur=762.013, total;dur=881.061
|
|
486
|
+
x-request-id: req_01m6kddz11ex9ef866ftmdgpe3
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
<sub>Captured 2026-11-04 from commit `845c4cc5` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-image`.</sub>
|
|
490
|
+
|
|
491
|
+
## Reasoning
|
|
492
|
+
|
|
493
|
+
The beta's chat model has a reasoning phase that is off by default. Ask for one with `reasoning_effort`, and the node holds it to a budget:
|
|
494
|
+
|
|
495
|
+
| `reasoning_effort` | Reasoning tokens, at most |
|
|
496
|
+
|---|---|
|
|
497
|
+
| `none`, `minimal` | 0 (no reasoning phase) |
|
|
498
|
+
| `low` | 256 |
|
|
499
|
+
| `medium` | 1,024 |
|
|
500
|
+
| `high` | 4,096 |
|
|
501
|
+
| `xhigh` | 8,192 |
|
|
502
|
+
|
|
503
|
+
At the budget the node closes the reasoning and the answer starts in the same request, so a hard question gets an answer instead of an empty message cut off at `max_tokens`. On 50 word problems (dev, 2026-11-03), thinking with no ceiling left 10 answers empty at the default 4,096-token cap; `high` answered all 50 within 4,094 reasoning tokens, and `low` answered all 50 in under twice the time of an answer with reasoning off. These are dev numbers from one run on a development copy of the node; the requests and answers are in the repository at `bench/infer/results/20261103T0000Z-dev-reasoning-effort`. The reasoning arrives in the message's `reasoning_content`, apart from the answer; it counts as output tokens, and `reasoning_tokens` in `usage.completion_tokens_details` says how many. Without `max_tokens` the default output cap grows by the budget, so the answer keeps its room. With a `max_tokens` below the budget the reasoning can use all of it, and the answer is then empty with `finish_reason: "length"`. Responses' `reasoning.effort` uses the same table, and so does Messages' adaptive `thinking` with `output_config.effort`.
|
|
504
|
+
|
|
505
|
+
`"chat_template_kwargs": {"enable_thinking": true}` still turns reasoning on with no ceiling; sending it with a `reasoning_effort` that says the opposite is `400 invalid_request`. The node also takes the runtime's sampling extensions `top_k`, `min_p`, `repetition_penalty` and `logit_bias`, and accepts and ignores `metadata`, `store` and `service_tier`; any other parameter is `400 unsupported_parameter` ([the full list](https://docs.beta.b3os.org/compat/openai#differences-from-openai)).
|
|
506
|
+
|
|
507
|
+
## Beyond the node's models
|
|
508
|
+
|
|
509
|
+
A model ID the node does not serve fails with [`model_not_available`](https://docs.beta.b3os.org/errors#model_not_available). The API has an opt-in `"route": "gateway"` that sends such a request to the B3IQ gateway, but the beta node has no gateway route configured yet, so the request fails with `model_not_available` there too. On a node with the route, `b3os.route` in the response and `infer_route` in `Server-Timing` say which way each request went.
|
|
510
|
+
|
|
511
|
+
## Prompt logging
|
|
512
|
+
|
|
513
|
+
When the project keeps model calls ([prompt logging](https://docs.beta.b3os.org/platform/call-log), off by default), this call's request and answer are kept on the node for 7 days with keys removed. `b3os.capture` in the answer (the last chunk of a stream) says what applied: `{"value": "off", "from": "node", "clamped": false}`, and so does the `X-B3OS-Options` header. Send `X-B3OS-Capture-Content: off` to keep nothing of one call; no header turns it on.
|
|
514
|
+
|
|
515
|
+
## When it fails
|
|
516
|
+
|
|
517
|
+
Errors use OpenAI's shape, with the B3OS code in `error.code`. Here the model is another provider's, which the node does not serve and never maps to its own:
|
|
518
|
+
|
|
519
|
+
**Response 404**
|
|
520
|
+
|
|
521
|
+
```json
|
|
522
|
+
{
|
|
523
|
+
"error": {
|
|
524
|
+
"code": "model_not_available",
|
|
525
|
+
"message": "gpt-4o is not served on this node; GET /v1/infer/models lists the models that are",
|
|
526
|
+
"param": "model",
|
|
527
|
+
"type": "invalid_request_error"
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
**Request**
|
|
533
|
+
|
|
534
|
+
```bash
|
|
535
|
+
curl -s -X POST 'https://beta-api.b3os.org/v1/infer/chat/completions' \
|
|
536
|
+
-H "Authorization: Bearer $B3OS_API_KEY" \
|
|
537
|
+
-H 'content-type: application/json' \
|
|
538
|
+
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Name one river in Oregon."}]}'
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
**Server-Timing**
|
|
542
|
+
|
|
543
|
+
```http
|
|
544
|
+
server-timing: edge_auth;dur=15.000, edge_upstream;dur=13.000, total;dur=0.227
|
|
545
|
+
x-request-id: req_01m6aqejdy2cbb1yd24qmxqf5m
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
<sub>Captured 2026-11-01 from commit `ec54a894` on the host the node runs on, one call, label `live-recorded` (recorded from production). Case `infer/chat-unknown-model`.</sub>
|
|
549
|
+
|
|
550
|
+
| Code | Status | Meaning |
|
|
551
|
+
|---|---|---|
|
|
552
|
+
| [`model_not_available`](https://docs.beta.b3os.org/errors#model_not_available) | 404 | The node does not serve this model (and has no gateway route for it) |
|
|
553
|
+
| [`context_length_exceeded`](https://docs.beta.b3os.org/errors#context_length_exceeded) | 400 | The prompt and `max_tokens` do not fit the model's context |
|
|
554
|
+
| [`invalid_request`](https://docs.beta.b3os.org/errors#invalid_request) | 400 | A value is out of range or of the wrong type (`n` other than 1, `temperature` above 2); `param` names it |
|
|
555
|
+
| [`unsupported_parameter`](https://docs.beta.b3os.org/errors#unsupported_parameter) | 400 | The model's runtime does not support a parameter you sent; `param` names it |
|
|
556
|
+
| [`infer_backend_unavailable`](https://docs.beta.b3os.org/errors#infer_backend_unavailable) | 503 | The model is restarting or failing; retry after `Retry-After` |
|
|
557
|
+
| [`rate_limited`](https://docs.beta.b3os.org/errors#rate_limited) | 429 | Over your tokens or requests per minute for the model |
|
|
558
|
+
|
|
559
|
+
Per-model token and request limits, request sizes and stream lengths are on [Infer limits](https://docs.beta.b3os.org/infer/limits).
|
|
560
|
+
|
|
561
|
+
```json
|
|
562
|
+
{
|
|
563
|
+
"model": "b3os/qwen3.5-9b",
|
|
564
|
+
"messages": [{ "role": "user", "content": "Name one river in Oregon." }]
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
[Try it in the playground](https://beta.b3os.org/app/playground?op=inferCreateChatCompletion&body=eyJtb2RlbCI6ImIzb3MvcXdlbjMuNS05YiIsIm1lc3NhZ2VzIjpbeyJyb2xlIjoidXNlciIsImNvbnRlbnQiOiJOYW1lIG9uZSByaXZlciBpbiBPcmVnb24uIn1dfQ)
|
|
569
|
+
|
|
570
|
+
<sub>Opens the dashboard playground with this request filled in (`POST /v1/infer/chat/completions`). The link carries no key.</sub>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Infer limits and FAQ
|
|
2
|
+
|
|
3
|
+
> Per-model token and request limits, request sizes and stream lengths for inference in the beta, and answers to common questions about the node's models.
|
|
4
|
+
|
|
5
|
+
Source: https://docs.beta.b3os.org/infer/limits.md
|
|
6
|
+
|
|
7
|
+
## Limits
|
|
8
|
+
|
|
9
|
+
| Limit | Value |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Tokens and requests per minute | Per model: `b3os.limits.tpm` and `b3os.limits.rpm` in `GET /v1/infer/models` |
|
|
12
|
+
| Largest request | Per model: `b3os.max_request_bytes`; the chat endpoint accepts at most 10 MiB |
|
|
13
|
+
| Chat stream length | 10 minutes |
|
|
14
|
+
| Choices per request (`n`) | 1 |
|
|
15
|
+
| Images per chat request | 8 on the beta's chat model, each resized to about a megapixel |
|
|
16
|
+
| Remote images fetched for you | 128 MiB per minute per organization |
|
|
17
|
+
| Model requests in flight (chat, Responses, Messages, embeddings) | 64 per organization; more get `429` [`concurrency_limited`](https://docs.beta.b3os.org/errors#concurrency_limited) |
|
|
18
|
+
| JSON Schema for structured output | Up to 64 KiB and 32 levels deep |
|
|
19
|
+
| Speech input | 4,096 characters per request; request body 64 KiB |
|
|
20
|
+
| Speech audio | 5 minutes per request; longer is `413` [`payload_too_large`](https://docs.beta.b3os.org/errors#payload_too_large). The `<break>` tags of one input add up to at most 60 seconds of silence and split it into at most 100 spoken parts; more is `400` [`invalid_request`](https://docs.beta.b3os.org/errors#invalid_request) |
|
|
21
|
+
| Speech answers in flight | 32 per organization, streamed or not, until the last byte is read; more get `429` [`concurrency_limited`](https://docs.beta.b3os.org/errors#concurrency_limited) |
|
|
22
|
+
| Unread speech answer | Ends, with its connection cut, when the caller reads nothing of it for longer than the node's idle limit |
|
|
23
|
+
|
|
24
|
+
Going over a model's rate returns `429` [`rate_limited`](https://docs.beta.b3os.org/errors#rate_limited) with `Retry-After`; a prompt longer than the model's context returns `400` [`context_length_exceeded`](https://docs.beta.b3os.org/errors#context_length_exceeded).
|
|
25
|
+
|
|
26
|
+
## Fixed in the beta
|
|
27
|
+
|
|
28
|
+
No request field changes these in the beta.
|
|
29
|
+
|
|
30
|
+
- [**Cached tokens and the token limit**](https://docs.beta.b3os.org/infer/settings#cached-tokens-and-the-token-limit): Counted in full. Prompt tokens the runtime serves from its prefix cache count in full toward your tokens-per-minute limit (`tpm`), the same as any other prompt token. They are billed as `infer.input_tokens` like the rest.
|
|
31
|
+
- [**Precision**](https://docs.beta.b3os.org/infer/settings#precision): FP8. The chat model runs in an FP8 quantization. A different precision would be a different model ID; the model list shows each model's `quantization`.
|
|
32
|
+
|
|
33
|
+
## FAQ
|
|
34
|
+
|
|
35
|
+
**Which model does the node serve?**
|
|
36
|
+
|
|
37
|
+
`GET /v1/infer/models` says, with each model's context length, quantization and features. The beta runs `b3os/qwen3.5-9b`, a 9B model in an FP8 quantization B3OS made (its task quality is not measured yet; published scores are the vendor's, on BF16) with a 32,768-token context, tool calling, JSON Schema output and image input, and the `kokoro-82m` speech model. Write code against the IDs in that list rather than fixed names.
|
|
38
|
+
**Does inference cost anything in the beta?**
|
|
39
|
+
|
|
40
|
+
No. Tokens are metered so you can see your usage, and each model's tokens-per-minute limit applies.
|
|
41
|
+
**I need a larger model. What are my options?**
|
|
42
|
+
|
|
43
|
+
Call any provider you like from your agent; B3OS tools work with any model. The API also has an opt-in `"route": "gateway"` for models served through the B3IQ gateway, but the beta node has no gateway route configured yet, so a model the node does not serve fails with `model_not_available` either way. B3OS never sends a request elsewhere on its own.
|
|
44
|
+
**Can I use the Anthropic SDK?**
|
|
45
|
+
|
|
46
|
+
Yes. Set the base URL to `https://beta-api.b3os.org/v1/infer` (the SDK adds `/v1/messages`) and pass your B3OS key as the auth token (`ANTHROPIC_AUTH_TOKEN`). Text, images, custom tools, `thinking`, JSON Schema output and streaming work; tools that Anthropic runs on its side do not. See [compatibility](https://docs.beta.b3os.org/compat/openai#anthropic-messages).
|
|
47
|
+
**How do I turn on the model's reasoning?**
|
|
48
|
+
|
|
49
|
+
It is off by default. Send `reasoning_effort` on chat completions, `reasoning.effort` on Responses, or `thinking` on Messages: `low`, `medium`, `high` and `xhigh` let the model reason for at most 256, 1,024, 4,096 and 8,192 tokens, then the node closes the reasoning and the answer follows in the same request. The reasoning text comes back separately from the answer and counts as output tokens. See [Reasoning](https://docs.beta.b3os.org/infer/chat#reasoning).
|
|
50
|
+
**Why do I get infer_backend_unavailable?**
|
|
51
|
+
|
|
52
|
+
The model process is restarting or failing. The response carries `Retry-After`; try again after it.
|
|
53
|
+
**Why does code in my sandbox get forbidden from infer?**
|
|
54
|
+
|
|
55
|
+
The sandbox's grant lacks the scope. Create it with `api.scopes` including `infer:run` (and `infer:read` to list models).
|