sference-cli 0.3.2__tar.gz → 0.5.0__tar.gz
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.
- {sference_cli-0.3.2 → sference_cli-0.5.0}/PKG-INFO +84 -48
- {sference_cli-0.3.2 → sference_cli-0.5.0}/README.md +83 -47
- {sference_cli-0.3.2 → sference_cli-0.5.0}/pyproject.toml +1 -1
- sference_cli-0.5.0/sference_cli/_discovery.py +124 -0
- sference_cli-0.5.0/sference_cli/cursor_config.py +485 -0
- {sference_cli-0.3.2 → sference_cli-0.5.0}/sference_cli/device_auth.py +46 -4
- {sference_cli-0.3.2 → sference_cli-0.5.0}/sference_cli/launch.py +626 -153
- {sference_cli-0.3.2 → sference_cli-0.5.0}/sference_cli/main.py +434 -409
- sference_cli-0.5.0/sference_cli/settings.py +40 -0
- sference_cli-0.3.2/sference_cli/_proxy_addon.py +0 -242
- sference_cli-0.3.2/sference_cli/_proxy_routing.py +0 -234
- sference_cli-0.3.2/sference_cli/proxy.py +0 -291
- {sference_cli-0.3.2 → sference_cli-0.5.0}/.gitignore +0 -0
- {sference_cli-0.3.2 → sference_cli-0.5.0}/LICENSE +0 -0
- {sference_cli-0.3.2 → sference_cli-0.5.0}/sference_cli/__init__.py +0 -0
- {sference_cli-0.3.2 → sference_cli-0.5.0}/sference_cli/stream_cache.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sference-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: sference command-line interface
|
|
5
5
|
Project-URL: Homepage, https://sference.com
|
|
6
6
|
Project-URL: Repository, https://github.com/s-ference/sference
|
|
@@ -27,7 +27,9 @@ Description-Content-Type: text/markdown
|
|
|
27
27
|
|
|
28
28
|
# sference CLI
|
|
29
29
|
|
|
30
|
-
Command-line interface for the sference
|
|
30
|
+
Command-line interface for the sference API (`sference`): batches, streams, responses, decisions, and launchers that point coding agents (Claude Code, Codex, opencode, Pi, Cursor) at sference. It uses the Python SDK (`sference-sdk`) and is published on PyPI as `sference-cli`.
|
|
31
|
+
|
|
32
|
+
**Default model:** `deepseek-ai/DeepSeek-V4.1-Flash-1017` (DeepSeek V4.1 Flash). Every command that takes `--model` falls back to `SFERENCE_MODEL`, then to this default. Run `sference models` for the live catalog.
|
|
31
33
|
|
|
32
34
|
## Installation
|
|
33
35
|
|
|
@@ -65,11 +67,13 @@ sference --help
|
|
|
65
67
|
|
|
66
68
|
## Authentication
|
|
67
69
|
|
|
68
|
-
1. **Interactive (browser):** `sference auth login`
|
|
69
|
-
2. **Non-interactive / CI:** `sference auth login --api-key 'sk_...'`
|
|
70
|
-
3. **Environment variable:** `SFERENCE_API_KEY`
|
|
70
|
+
1. **Interactive (browser):** `sference auth login` signs in with the OAuth 2.0 device flow (RFC 8628). The CLI opens the console approval page and shows a short code; confirm it matches, approve the device, and the CLI finishes on its own. No API key is involved. Pass `--no-browser` on a remote or headless machine to print the URL and code instead.
|
|
71
|
+
2. **Non-interactive / CI:** `sference auth login --api-key 'sk_...'` saves an API key from **Console → API keys** without opening a browser.
|
|
72
|
+
3. **Environment variable:** `SFERENCE_API_KEY` is used when this device is **not** signed in with the device flow. A device login wins over the variable (the CLI says so once); if the device grant is revoked, the CLI falls back to `SFERENCE_API_KEY`.
|
|
73
|
+
|
|
74
|
+
Credentials are stored in `~/.sference/credentials.json` (owner-only permissions). A device login stores a 24 h access token and a 30 d rotating refresh token; the CLI refreshes the access token automatically when you run a command, and `sference launch claude` refreshes it at launch so a session starts on a fresh 24 h token. Launched tools (Claude Code, Codex, opencode, Pi) run on the token issued at launch. Signed-in devices are listed, and can be revoked, under **Profile → Signed-in devices** in the console.
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
For local development, `--base-url` (or `SFERENCE_BASE_URL`) points the device flow at another API and `--console-url` (or `SFERENCE_CONSOLE_URL`) overrides the approval page the browser opens.
|
|
73
77
|
|
|
74
78
|
Verify the current credential:
|
|
75
79
|
|
|
@@ -78,20 +82,35 @@ sference auth me
|
|
|
78
82
|
sference auth me --json
|
|
79
83
|
```
|
|
80
84
|
|
|
81
|
-
## Quick examples
|
|
85
|
+
## Quick examples
|
|
86
|
+
|
|
87
|
+
`--model` is optional everywhere below; it defaults to `deepseek-ai/DeepSeek-V4.1-Flash-1017`.
|
|
88
|
+
|
|
89
|
+
**Models**
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sference models # table: id, context, capabilities, alias/retirement notes
|
|
93
|
+
sference models --json # raw GET /v1/models
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Responses**
|
|
82
97
|
|
|
83
|
-
|
|
98
|
+
```bash
|
|
99
|
+
sference responses create --content "Summarize RFC 8628 in one line"
|
|
100
|
+
sference responses create --content "Long task" --background # returns immediately
|
|
101
|
+
sference responses result --id <response_id>
|
|
102
|
+
```
|
|
84
103
|
|
|
85
104
|
**Batches**
|
|
86
105
|
|
|
87
106
|
```bash
|
|
88
|
-
sference batch submit --input-file ./workload.jsonl --
|
|
107
|
+
sference batch submit --input-file ./workload.jsonl --window 24h
|
|
89
108
|
sference batch status --batch-id <batch_id>
|
|
90
109
|
sference batch wait --batch-id <batch_id>
|
|
91
110
|
sference batch results --batch-id <batch_id>
|
|
92
111
|
sference batch download-results --batch-id <batch_id> --out ./out.jsonl
|
|
93
112
|
# Submit, wait, print JSONL results on stdout (stderr: progress; resumable cache)
|
|
94
|
-
sference batch stream --input-file ./workload.jsonl --
|
|
113
|
+
sference batch stream --input-file ./workload.jsonl --window 24h
|
|
95
114
|
```
|
|
96
115
|
|
|
97
116
|
**Streams**
|
|
@@ -99,7 +118,7 @@ sference batch stream --input-file ./workload.jsonl --model Qwen/Qwen3.6-35B-A3B
|
|
|
99
118
|
```bash
|
|
100
119
|
sference stream create --name "my-stream" --window 24h
|
|
101
120
|
sference stream list
|
|
102
|
-
sference stream submit --stream-id <stream_id> --input-file ./lines.jsonl
|
|
121
|
+
sference stream submit --stream-id <stream_id> --input-file ./lines.jsonl
|
|
103
122
|
sference stream status --stream-id <stream_id>
|
|
104
123
|
sference responses tail --stream-id <stream_id>
|
|
105
124
|
```
|
|
@@ -108,8 +127,10 @@ sference responses tail --stream-id <stream_id>
|
|
|
108
127
|
|
|
109
128
|
| Variable | Purpose |
|
|
110
129
|
|----------|---------|
|
|
111
|
-
| `SFERENCE_API_KEY` | API key (or
|
|
112
|
-
| `
|
|
130
|
+
| `SFERENCE_API_KEY` | API key (or access token); used when the device is not signed in via `sference auth login` |
|
|
131
|
+
| `SFERENCE_BASE_URL` | API base URL for every command (default `https://api.sference.com`; same as `--base-url`) |
|
|
132
|
+
| `SFERENCE_CONSOLE_URL` | Console URL the device-flow approval page opens on (default: server-provided) |
|
|
133
|
+
| `SFERENCE_MODEL` | Default model for every command and launcher (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
113
134
|
| `SFERENCE_STREAM_CACHE` | Optional path to the stream resumable-cache file (default `~/.sference/stream_cache.json`) |
|
|
114
135
|
| `SFERENCE_STREAM_CHECKPOINTS` | Optional path for **`responses tail`** event checkpoints (default `~/.sference/stream_checkpoints.json`) |
|
|
115
136
|
|
|
@@ -119,31 +140,27 @@ sference responses tail --stream-id <stream_id>
|
|
|
119
140
|
|
|
120
141
|
| Command | Description |
|
|
121
142
|
|---------|-------------|
|
|
122
|
-
| `sference auth login` |
|
|
143
|
+
| `sference auth login` | Sign in with the browser device flow (`--no-browser` prints the URL and code; `--api-key` saves an API key for CI) |
|
|
123
144
|
| `sference auth me` | Show current user (`--json` for machine-readable output) |
|
|
124
145
|
|
|
125
146
|
### Launch
|
|
126
147
|
|
|
127
|
-
#### `sference launch claude`
|
|
148
|
+
#### `sference launch claude`
|
|
128
149
|
|
|
129
|
-
|
|
150
|
+
`sference launch claude` points Claude Code at Sference's native `/v1/messages` endpoint via `ANTHROPIC_BASE_URL` and enables gateway model discovery: the live catalog is primed into Claude Code's picker cache before launch, so `/model` lists every Sference model the account can serve. No proxy, no mitmproxy.
|
|
130
151
|
|
|
131
152
|
| Command | Description |
|
|
132
|
-
|
|
133
|
-
| `sference launch claude` |
|
|
134
|
-
| `sference launch claude --dry-run` | Print the
|
|
135
|
-
| `sference launch claude --model zai-org/GLM-5.
|
|
136
|
-
| `sference launch claude --models a,b` |
|
|
137
|
-
| `sference launch claude --
|
|
138
|
-
| `sference launch claude --
|
|
139
|
-
| `sference launch claude --no-anthropic` | Disable the proxy; route everything directly to Sference via `ANTHROPIC_BASE_URL` (the previous behavior — no hybrid routing, no `/model` picker) |
|
|
140
|
-
| `sference launch claude --no-anthropic --enable-tool-search` | Direct mode: set `ENABLE_TOOL_SEARCH=true` on a custom host |
|
|
141
|
-
|
|
142
|
-
Proxy mode requires `mitmproxy` (`mitmdump` on `PATH`) and the [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code). The installer (`install.sh` / `install.ps1`) installs mitmproxy alongside the CLI; to add it to an existing install: `uv tool install mitmproxy`. If mitmproxy is missing, proxy mode errors with a `--no-anthropic` suggestion.
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| `sference launch claude` | Launch Claude Code against Sference; catalog primed into `/model` |
|
|
155
|
+
| `sference launch claude --dry-run` | Print the env config + command without launching |
|
|
156
|
+
| `sference launch claude --model zai-org/GLM-5.3` | Pin a different model (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
157
|
+
| `sference launch claude --models a,b` | Override the primed picker set (default: live `GET /v1/models`) |
|
|
158
|
+
| `sference launch claude --enable-tool-search` | Set `ENABLE_TOOL_SEARCH=true` |
|
|
159
|
+
| `sference launch claude -- -p "hi"` | Forward Claude Code flags/args after `--` |
|
|
143
160
|
|
|
144
|
-
|
|
161
|
+
Requires only the [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code). Every Claude Code model alias (opus/sonnet/haiku/fable, sub-agents) is pinned to the chosen model so no request goes out with a `claude-*` id. The default model accepts Claude Code's thinking-disabled request shape; the GLM-5.3 family does not (it always reasons), so pick it only for clients that send thinking. Device-flow credentials are refreshed at launch so long sessions start on a fresh 24 h token. `--no-anthropic` and `--proxy-port` are still accepted (hidden) as no-ops for older scripts.
|
|
145
162
|
|
|
146
|
-
|
|
163
|
+
All launchers fill their model picker from the live `GET /v1/models` catalog (text-generation models only); aliases past their `retires_on` date are left out, since the API asks callers to migrate to the `alias_of` target.
|
|
147
164
|
|
|
148
165
|
#### `sference launch pi`
|
|
149
166
|
|
|
@@ -151,10 +168,10 @@ Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `moons
|
|
|
151
168
|
|---------|-------------|
|
|
152
169
|
| `sference launch pi` | Launch Pi with Sference API routing (writes `~/.pi/agent/models.json`) |
|
|
153
170
|
| `sference launch pi --dry-run` | Print provider config and command without launching Pi |
|
|
154
|
-
| `sference launch pi --model
|
|
171
|
+
| `sference launch pi --model zai-org/GLM-5.3` | Override catalog model |
|
|
155
172
|
| `sference launch pi -- /path/to/project` | Forward Pi args after `sference launch pi` |
|
|
156
173
|
|
|
157
|
-
Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provider block to `~/.pi/agent/models.json` using pi's `openai-responses` API (the Sference `/v1/responses` endpoint) with `baseUrl`, `apiKey`, and the full list of Sference-provided models (fetched live from `GET /v1/models`), then execs `pi --provider sference --model <id> --models sference/**`. The `--models sference/**` flag scopes pi's `/model` picker (and Ctrl+P cycling) to Sference models only, so other configured providers are hidden by default (`**` is required because Sference model ids contain a slash and `*` would match nothing). All catalog models appear in the picker; `--model` selects the active one. Reasoning is driven by pi's native `reasoning.effort` (no per-model thinking-format config needed). If the catalog fetch fails (offline), only the chosen model is registered. Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `
|
|
174
|
+
Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provider block to `~/.pi/agent/models.json` using pi's `openai-responses` API (the Sference `/v1/responses` endpoint) with `baseUrl`, `apiKey`, and the full list of Sference-provided models (fetched live from `GET /v1/models`), then execs `pi --provider sference --model <id> --models sference/**`. The `--models sference/**` flag scopes pi's `/model` picker (and Ctrl+P cycling) to Sference models only, so other configured providers are hidden by default (`**` is required because Sference model ids contain a slash and `*` would match nothing). All catalog models appear in the picker; `--model` selects the active one. Reasoning is driven by pi's native `reasoning.effort` (no per-model thinking-format config needed). If the catalog fetch fails (offline), only the chosen model is registered. Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `deepseek-ai/DeepSeek-V4.1-Flash-1017` (override with `--model` or `SFERENCE_MODEL`).
|
|
158
175
|
|
|
159
176
|
#### `sference launch codex`
|
|
160
177
|
|
|
@@ -162,7 +179,7 @@ Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provid
|
|
|
162
179
|
|---------|-------------|
|
|
163
180
|
| `sference launch codex` | Launch the [Codex CLI](https://developers.openai.com/codex/cli) against Sference's `/v1/responses` |
|
|
164
181
|
| `sference launch codex --dry-run` | Print provider config and command without launching Codex |
|
|
165
|
-
| `sference launch codex --model
|
|
182
|
+
| `sference launch codex --model zai-org/GLM-5.3` | Override catalog model (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
166
183
|
| `sference launch codex -- exec "fix the bug"` | Forward Codex args (here: non-interactive `codex exec`) |
|
|
167
184
|
| `sference launch codex -- -c model_reasoning_effort=high` | Override the reasoning effort (default `medium`) |
|
|
168
185
|
|
|
@@ -170,15 +187,34 @@ Requires `codex` on `PATH`. The `sference` model provider is passed as `codex -c
|
|
|
170
187
|
|
|
171
188
|
**Sub-agents and MCP servers** work: the Sference provider applies to the whole session, so agents Codex spawns run on Sference too. The launcher also writes `~/.sference/codex/models.json`, a Codex model catalog listing only the Sference models, and passes it as `model_catalog_json`. Without it Codex offers `spawn_agent` its own OpenAI models, and a sub-agent started on one of them fails. Each entry is built at launch from the catalog bundled with your Codex (`codex debug models --bundled`), so it always matches your Codex version; if that command is unavailable the launcher warns and starts without the catalog. An `agents.default_subagent_model` in your Codex config still pins sub-agents to an OpenAI model, which Sference cannot serve (the launcher warns about it).
|
|
172
189
|
|
|
190
|
+
#### `sference launch cursor`
|
|
191
|
+
|
|
192
|
+
| Command | Description |
|
|
193
|
+
|---------|-------------|
|
|
194
|
+
| `sference launch cursor` | Turn Sference routing on for Cursor |
|
|
195
|
+
| `sference launch cursor --dry-run` | Print what would change without writing anything |
|
|
196
|
+
| `sference launch cursor --model zai-org/GLM-5.3` | Override the default model for new chats (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
197
|
+
| `sference launch cursor --sference-only` | Disable all Cursor-provided models, leaving only Sference models |
|
|
198
|
+
| `sference launch cursor --api-key sk_...` | Store this API key in Cursor (default: your credential, or a newly created one) |
|
|
199
|
+
| `sference launch cursor status` | Show whether Cursor chats on Sference right now |
|
|
200
|
+
| `sference launch cursor off` | Restore Cursor's settings from before `launch cursor` |
|
|
201
|
+
| `sference launch cursor off --revoke-key` | Also revoke the API key that was created for Cursor |
|
|
202
|
+
|
|
203
|
+
Configures [Cursor](https://cursor.com) to run its chat on Sference through Cursor's own-API-key (BYOK) mode: the launcher writes the Sference base URL (`/v1`), your key, and the live model catalog into Cursor's settings database, and sets the default model for new chats (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`). Cursor's own models stay available side by side unless `--sference-only` is passed. Requires a **signed-in paid Cursor plan** (Pro/Business/Enterprise) — BYOK is not available on the free plan.
|
|
204
|
+
|
|
205
|
+
Key handling: with an `sk_...` credential (or `--api-key`) that key is stored directly; with a device login the launcher creates a dedicated API key (tagged `sference-cli-cursor`, visible in Console → API Keys) so the 24 h device token never lands in another app. If Cursor already has an OpenAI key saved, the launcher refuses unless `--replace-existing-key` is passed (the old key cannot be restored; on macOS you will be asked to confirm the Keychain change).
|
|
206
|
+
|
|
207
|
+
Safety: quit Cursor first — it rewrites its settings from memory on exit and would discard the change (the launcher refuses while Cursor is running; `--force` overrides, and you must then fully restart Cursor). Everything is written in one transaction, the prior settings are backed up to `~/.sference/cursor/backup.json`, and `off` restores them. **Scope:** this covers Cursor chat and the model picker — Tab completions, chat titles, Agent Review (Bugbot), and cloud agents keep running on Cursor's own models, same as any BYOK setup.
|
|
208
|
+
|
|
173
209
|
### Batch
|
|
174
210
|
|
|
175
211
|
| Command | Description |
|
|
176
212
|
|---------|-------------|
|
|
177
213
|
| `sference batch list` | List batches (table; `--json` for raw payload) |
|
|
178
|
-
| `sference batch submit` | Submit a JSONL file (`--input-file
|
|
214
|
+
| `sference batch submit` | Submit a JSONL file (`--input-file`; `--model` applies to content-only lines and defaults to `SFERENCE_MODEL` / DeepSeek V4.1 Flash; `--window` `24h`) |
|
|
179
215
|
| `sference batch stream` | Submit, wait, print **JSONL results on stdout** (see below) |
|
|
180
216
|
| `sference batch status` | Get one batch (`--batch-id`, `--json`) |
|
|
181
|
-
| `sference batch wait` | Poll until terminal state (`--batch-id`, `--poll-interval`, `--timeout
|
|
217
|
+
| `sference batch wait` | Poll until terminal state (`--batch-id`, `--poll-interval`, `--timeout` (default 30 s), `--json`) |
|
|
182
218
|
| `sference batch results` | JSON results payload (`--batch-id`, `--json`) |
|
|
183
219
|
| `sference batch cancel` | Cancel a batch (`--batch-id`, `--json`) |
|
|
184
220
|
| `sference batch download-results` | Download results JSONL to a file (`--batch-id`, `--out`, `--format jsonl`) |
|
|
@@ -187,9 +223,9 @@ Requires `codex` on `PATH`. The `sference` model provider is passed as `codex -c
|
|
|
187
223
|
|
|
188
224
|
| Command | Description |
|
|
189
225
|
|---------|-------------|
|
|
190
|
-
| `sference responses create` | Create one response (`--model`, `--
|
|
191
|
-
| `sference responses result` | Poll until terminal state (`--id`, `--poll-
|
|
192
|
-
| `sference responses tail` | Print completion events as JSONL via `GET /v1/responses/events` (optional `--stream-id` to scope to a stream; omit for non-stream completions). Flags: `--consumer`, `--from-latest`, `--no-checkpoint`, `--poll-
|
|
226
|
+
| `sference responses create` | Create one response (`--content`; optional `--model`, `--instructions`, `--max-output-tokens`, `--enable-thinking/--disable-thinking`; `--background` submits async and returns immediately). The sync default blocks; if the server-side wait times out, the request is **cancelled** and the command fails — use `--background` + `sference responses result` for long requests |
|
|
227
|
+
| `sference responses result` | Poll until terminal state (`--id`, `--poll-interval` seconds) |
|
|
228
|
+
| `sference responses tail` | Print completion events as JSONL via `GET /v1/responses/events` (optional `--stream-id` to scope to a stream; omit for non-stream completions). Flags: `--consumer`, `--from-latest`, `--no-checkpoint`, `--poll-interval` |
|
|
193
229
|
|
|
194
230
|
### Decisions (`/v1/decisions`)
|
|
195
231
|
|
|
@@ -213,20 +249,20 @@ Long-lived **streams** are separate from **batches**: you create a stream, submi
|
|
|
213
249
|
| `sference stream create` | Create a stream (`--name`, `--window` `24h`, `--json`) |
|
|
214
250
|
| `sference stream list` | List streams (`--json`) |
|
|
215
251
|
| `sference stream status` | Full detail + counters (`--stream-id`, `--json`) |
|
|
216
|
-
| `sference stream submit` |
|
|
252
|
+
| `sference stream submit` | Queue one **background** response per JSONL line via `POST /v1/responses` (`metadata.stream_id` and `completion_window: "24h"` set automatically; `--stream-id`, `--input-file`, optional `--model` for lines without one). The whole file is validated before anything is sent |
|
|
217
253
|
| `sference stream cancel` | Stop accepting new items and stop enqueueing pending work; does not auto-cancel in-flight requests (`--stream-id`, `--json`) |
|
|
218
254
|
| `sference stream archive` | Finalize the stream (optional after cancel); no new items (`--stream-id`, `--json`) |
|
|
219
255
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
```json
|
|
223
|
-
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"Qwen/Qwen3.6-35B-A3B","messages":[{"role":"user","content":"hi"}]}}
|
|
224
|
-
```
|
|
256
|
+
Accepted JSONL lines for `stream submit`:
|
|
225
257
|
|
|
226
258
|
```json
|
|
227
259
|
{"content":"hi"}
|
|
260
|
+
{"input":[{"role":"user","content":"hi"}],"instructions":"Be brief.","max_output_tokens":256}
|
|
261
|
+
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"zai-org/GLM-5.3","messages":[{"role":"user","content":"hi"}],"max_tokens":256}}
|
|
228
262
|
```
|
|
229
263
|
|
|
264
|
+
Chat-shaped bodies are mapped onto the Responses API (`messages` → `input`, `max_tokens` → `max_output_tokens`); `custom_id` lands in `metadata.custom_id`. Forwarded fields: `model`, `input`, `instructions`, `max_output_tokens`, `temperature`, `top_p`, `include_reasoning`, `enable_thinking`, `metadata`; any other field is rejected rather than silently dropped.
|
|
265
|
+
|
|
230
266
|
---
|
|
231
267
|
|
|
232
268
|
## Streaming batches (`batch stream`)
|
|
@@ -244,10 +280,10 @@ Example:
|
|
|
244
280
|
sference batch stream --input-file workload.jsonl > results.jsonl
|
|
245
281
|
```
|
|
246
282
|
|
|
247
|
-
Content-only JSONL (model supplied globally):
|
|
283
|
+
Content-only JSONL (model supplied globally; omit `--model` for the default):
|
|
248
284
|
|
|
249
285
|
```bash
|
|
250
|
-
sference batch stream --input-file prompts.jsonl --model
|
|
286
|
+
sference batch stream --input-file prompts.jsonl --model zai-org/GLM-5.3 > results.jsonl
|
|
251
287
|
```
|
|
252
288
|
|
|
253
289
|
### Resumable cache
|
|
@@ -256,7 +292,7 @@ Batches can take a long time. If you **interrupt** the command (e.g. Ctrl+C) and
|
|
|
256
292
|
|
|
257
293
|
- Cache file: **`~/.sference/stream_cache.json`** (override with **`SFERENCE_STREAM_CACHE`**).
|
|
258
294
|
- Key: **SHA-256** of the raw input file bytes (same bytes ⇒ same key, regardless of path).
|
|
259
|
-
- Stored fields: `batch_id`, `created_at
|
|
295
|
+
- Stored fields: `batch_id`, `base_url`, `created_at` (an entry is only reused against the same API base URL).
|
|
260
296
|
- After results are written to stdout, the entry for that input is **removed** so the cache does not grow forever.
|
|
261
297
|
- If the cached batch no longer exists on the server (404), the cache entry is dropped and a **new** batch is submitted.
|
|
262
298
|
|
|
@@ -291,14 +327,14 @@ The SDK and CLI accept two line shapes (see also [`fixtures/example_batch.jsonl`
|
|
|
291
327
|
1. **OpenAI-compatible envelope:** each line has `custom_id`, `method`, `url`, and `body`. The API receives only `custom_id` + inner `body` (`method`/`url` are ignored). Inner `body` may use:
|
|
292
328
|
- **Chat completions:** `messages` (non-empty array), plus optional `temperature`, `max_tokens`, `tools`, …
|
|
293
329
|
- **Responses API:** `input` (string or message array), optional `instructions`, `max_output_tokens`, … — normalized to chat format at batch create.
|
|
294
|
-
2. **Content-only:** each line is `{"content": "..."}`.
|
|
330
|
+
2. **Content-only:** each line is `{"content": "..."}`. The model comes from `--model`, else `SFERENCE_MODEL`, else `deepseek-ai/DeepSeek-V4.1-Flash-1017`.
|
|
295
331
|
|
|
296
332
|
Invalid row bodies return **HTTP 400** at create with `requests[i]` and `custom_id` in the error message (nothing is enqueued). Do not set `background: true` inside batch row bodies.
|
|
297
333
|
|
|
298
334
|
Example Responses-shaped JSONL line:
|
|
299
335
|
|
|
300
336
|
```json
|
|
301
|
-
{"custom_id":"r2","method":"POST","url":"/v1/responses","body":{"model":"
|
|
337
|
+
{"custom_id":"r2","method":"POST","url":"/v1/responses","body":{"model":"deepseek-ai/DeepSeek-V4.1-Flash-1017","input":[{"role":"user","content":"hi"}],"max_output_tokens":256}}
|
|
302
338
|
```
|
|
303
339
|
|
|
304
340
|
---
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# sference CLI
|
|
2
2
|
|
|
3
|
-
Command-line interface for the sference
|
|
3
|
+
Command-line interface for the sference API (`sference`): batches, streams, responses, decisions, and launchers that point coding agents (Claude Code, Codex, opencode, Pi, Cursor) at sference. It uses the Python SDK (`sference-sdk`) and is published on PyPI as `sference-cli`.
|
|
4
|
+
|
|
5
|
+
**Default model:** `deepseek-ai/DeepSeek-V4.1-Flash-1017` (DeepSeek V4.1 Flash). Every command that takes `--model` falls back to `SFERENCE_MODEL`, then to this default. Run `sference models` for the live catalog.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
@@ -38,11 +40,13 @@ sference --help
|
|
|
38
40
|
|
|
39
41
|
## Authentication
|
|
40
42
|
|
|
41
|
-
1. **Interactive (browser):** `sference auth login`
|
|
42
|
-
2. **Non-interactive / CI:** `sference auth login --api-key 'sk_...'`
|
|
43
|
-
3. **Environment variable:** `SFERENCE_API_KEY`
|
|
43
|
+
1. **Interactive (browser):** `sference auth login` signs in with the OAuth 2.0 device flow (RFC 8628). The CLI opens the console approval page and shows a short code; confirm it matches, approve the device, and the CLI finishes on its own. No API key is involved. Pass `--no-browser` on a remote or headless machine to print the URL and code instead.
|
|
44
|
+
2. **Non-interactive / CI:** `sference auth login --api-key 'sk_...'` saves an API key from **Console → API keys** without opening a browser.
|
|
45
|
+
3. **Environment variable:** `SFERENCE_API_KEY` is used when this device is **not** signed in with the device flow. A device login wins over the variable (the CLI says so once); if the device grant is revoked, the CLI falls back to `SFERENCE_API_KEY`.
|
|
46
|
+
|
|
47
|
+
Credentials are stored in `~/.sference/credentials.json` (owner-only permissions). A device login stores a 24 h access token and a 30 d rotating refresh token; the CLI refreshes the access token automatically when you run a command, and `sference launch claude` refreshes it at launch so a session starts on a fresh 24 h token. Launched tools (Claude Code, Codex, opencode, Pi) run on the token issued at launch. Signed-in devices are listed, and can be revoked, under **Profile → Signed-in devices** in the console.
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
For local development, `--base-url` (or `SFERENCE_BASE_URL`) points the device flow at another API and `--console-url` (or `SFERENCE_CONSOLE_URL`) overrides the approval page the browser opens.
|
|
46
50
|
|
|
47
51
|
Verify the current credential:
|
|
48
52
|
|
|
@@ -51,20 +55,35 @@ sference auth me
|
|
|
51
55
|
sference auth me --json
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
## Quick examples
|
|
58
|
+
## Quick examples
|
|
59
|
+
|
|
60
|
+
`--model` is optional everywhere below; it defaults to `deepseek-ai/DeepSeek-V4.1-Flash-1017`.
|
|
61
|
+
|
|
62
|
+
**Models**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
sference models # table: id, context, capabilities, alias/retirement notes
|
|
66
|
+
sference models --json # raw GET /v1/models
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Responses**
|
|
55
70
|
|
|
56
|
-
|
|
71
|
+
```bash
|
|
72
|
+
sference responses create --content "Summarize RFC 8628 in one line"
|
|
73
|
+
sference responses create --content "Long task" --background # returns immediately
|
|
74
|
+
sference responses result --id <response_id>
|
|
75
|
+
```
|
|
57
76
|
|
|
58
77
|
**Batches**
|
|
59
78
|
|
|
60
79
|
```bash
|
|
61
|
-
sference batch submit --input-file ./workload.jsonl --
|
|
80
|
+
sference batch submit --input-file ./workload.jsonl --window 24h
|
|
62
81
|
sference batch status --batch-id <batch_id>
|
|
63
82
|
sference batch wait --batch-id <batch_id>
|
|
64
83
|
sference batch results --batch-id <batch_id>
|
|
65
84
|
sference batch download-results --batch-id <batch_id> --out ./out.jsonl
|
|
66
85
|
# Submit, wait, print JSONL results on stdout (stderr: progress; resumable cache)
|
|
67
|
-
sference batch stream --input-file ./workload.jsonl --
|
|
86
|
+
sference batch stream --input-file ./workload.jsonl --window 24h
|
|
68
87
|
```
|
|
69
88
|
|
|
70
89
|
**Streams**
|
|
@@ -72,7 +91,7 @@ sference batch stream --input-file ./workload.jsonl --model Qwen/Qwen3.6-35B-A3B
|
|
|
72
91
|
```bash
|
|
73
92
|
sference stream create --name "my-stream" --window 24h
|
|
74
93
|
sference stream list
|
|
75
|
-
sference stream submit --stream-id <stream_id> --input-file ./lines.jsonl
|
|
94
|
+
sference stream submit --stream-id <stream_id> --input-file ./lines.jsonl
|
|
76
95
|
sference stream status --stream-id <stream_id>
|
|
77
96
|
sference responses tail --stream-id <stream_id>
|
|
78
97
|
```
|
|
@@ -81,8 +100,10 @@ sference responses tail --stream-id <stream_id>
|
|
|
81
100
|
|
|
82
101
|
| Variable | Purpose |
|
|
83
102
|
|----------|---------|
|
|
84
|
-
| `SFERENCE_API_KEY` | API key (or
|
|
85
|
-
| `
|
|
103
|
+
| `SFERENCE_API_KEY` | API key (or access token); used when the device is not signed in via `sference auth login` |
|
|
104
|
+
| `SFERENCE_BASE_URL` | API base URL for every command (default `https://api.sference.com`; same as `--base-url`) |
|
|
105
|
+
| `SFERENCE_CONSOLE_URL` | Console URL the device-flow approval page opens on (default: server-provided) |
|
|
106
|
+
| `SFERENCE_MODEL` | Default model for every command and launcher (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
86
107
|
| `SFERENCE_STREAM_CACHE` | Optional path to the stream resumable-cache file (default `~/.sference/stream_cache.json`) |
|
|
87
108
|
| `SFERENCE_STREAM_CHECKPOINTS` | Optional path for **`responses tail`** event checkpoints (default `~/.sference/stream_checkpoints.json`) |
|
|
88
109
|
|
|
@@ -92,31 +113,27 @@ sference responses tail --stream-id <stream_id>
|
|
|
92
113
|
|
|
93
114
|
| Command | Description |
|
|
94
115
|
|---------|-------------|
|
|
95
|
-
| `sference auth login` |
|
|
116
|
+
| `sference auth login` | Sign in with the browser device flow (`--no-browser` prints the URL and code; `--api-key` saves an API key for CI) |
|
|
96
117
|
| `sference auth me` | Show current user (`--json` for machine-readable output) |
|
|
97
118
|
|
|
98
119
|
### Launch
|
|
99
120
|
|
|
100
|
-
#### `sference launch claude`
|
|
121
|
+
#### `sference launch claude`
|
|
101
122
|
|
|
102
|
-
|
|
123
|
+
`sference launch claude` points Claude Code at Sference's native `/v1/messages` endpoint via `ANTHROPIC_BASE_URL` and enables gateway model discovery: the live catalog is primed into Claude Code's picker cache before launch, so `/model` lists every Sference model the account can serve. No proxy, no mitmproxy.
|
|
103
124
|
|
|
104
125
|
| Command | Description |
|
|
105
|
-
|
|
106
|
-
| `sference launch claude` |
|
|
107
|
-
| `sference launch claude --dry-run` | Print the
|
|
108
|
-
| `sference launch claude --model zai-org/GLM-5.
|
|
109
|
-
| `sference launch claude --models a,b` |
|
|
110
|
-
| `sference launch claude --
|
|
111
|
-
| `sference launch claude --
|
|
112
|
-
| `sference launch claude --no-anthropic` | Disable the proxy; route everything directly to Sference via `ANTHROPIC_BASE_URL` (the previous behavior — no hybrid routing, no `/model` picker) |
|
|
113
|
-
| `sference launch claude --no-anthropic --enable-tool-search` | Direct mode: set `ENABLE_TOOL_SEARCH=true` on a custom host |
|
|
114
|
-
|
|
115
|
-
Proxy mode requires `mitmproxy` (`mitmdump` on `PATH`) and the [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code). The installer (`install.sh` / `install.ps1`) installs mitmproxy alongside the CLI; to add it to an existing install: `uv tool install mitmproxy`. If mitmproxy is missing, proxy mode errors with a `--no-anthropic` suggestion.
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `sference launch claude` | Launch Claude Code against Sference; catalog primed into `/model` |
|
|
128
|
+
| `sference launch claude --dry-run` | Print the env config + command without launching |
|
|
129
|
+
| `sference launch claude --model zai-org/GLM-5.3` | Pin a different model (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
130
|
+
| `sference launch claude --models a,b` | Override the primed picker set (default: live `GET /v1/models`) |
|
|
131
|
+
| `sference launch claude --enable-tool-search` | Set `ENABLE_TOOL_SEARCH=true` |
|
|
132
|
+
| `sference launch claude -- -p "hi"` | Forward Claude Code flags/args after `--` |
|
|
116
133
|
|
|
117
|
-
|
|
134
|
+
Requires only the [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code). Every Claude Code model alias (opus/sonnet/haiku/fable, sub-agents) is pinned to the chosen model so no request goes out with a `claude-*` id. The default model accepts Claude Code's thinking-disabled request shape; the GLM-5.3 family does not (it always reasons), so pick it only for clients that send thinking. Device-flow credentials are refreshed at launch so long sessions start on a fresh 24 h token. `--no-anthropic` and `--proxy-port` are still accepted (hidden) as no-ops for older scripts.
|
|
118
135
|
|
|
119
|
-
|
|
136
|
+
All launchers fill their model picker from the live `GET /v1/models` catalog (text-generation models only); aliases past their `retires_on` date are left out, since the API asks callers to migrate to the `alias_of` target.
|
|
120
137
|
|
|
121
138
|
#### `sference launch pi`
|
|
122
139
|
|
|
@@ -124,10 +141,10 @@ Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `moons
|
|
|
124
141
|
|---------|-------------|
|
|
125
142
|
| `sference launch pi` | Launch Pi with Sference API routing (writes `~/.pi/agent/models.json`) |
|
|
126
143
|
| `sference launch pi --dry-run` | Print provider config and command without launching Pi |
|
|
127
|
-
| `sference launch pi --model
|
|
144
|
+
| `sference launch pi --model zai-org/GLM-5.3` | Override catalog model |
|
|
128
145
|
| `sference launch pi -- /path/to/project` | Forward Pi args after `sference launch pi` |
|
|
129
146
|
|
|
130
|
-
Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provider block to `~/.pi/agent/models.json` using pi's `openai-responses` API (the Sference `/v1/responses` endpoint) with `baseUrl`, `apiKey`, and the full list of Sference-provided models (fetched live from `GET /v1/models`), then execs `pi --provider sference --model <id> --models sference/**`. The `--models sference/**` flag scopes pi's `/model` picker (and Ctrl+P cycling) to Sference models only, so other configured providers are hidden by default (`**` is required because Sference model ids contain a slash and `*` would match nothing). All catalog models appear in the picker; `--model` selects the active one. Reasoning is driven by pi's native `reasoning.effort` (no per-model thinking-format config needed). If the catalog fetch fails (offline), only the chosen model is registered. Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `
|
|
147
|
+
Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provider block to `~/.pi/agent/models.json` using pi's `openai-responses` API (the Sference `/v1/responses` endpoint) with `baseUrl`, `apiKey`, and the full list of Sference-provided models (fetched live from `GET /v1/models`), then execs `pi --provider sference --model <id> --models sference/**`. The `--models sference/**` flag scopes pi's `/model` picker (and Ctrl+P cycling) to Sference models only, so other configured providers are hidden by default (`**` is required because Sference model ids contain a slash and `*` would match nothing). All catalog models appear in the picker; `--model` selects the active one. Reasoning is driven by pi's native `reasoning.effort` (no per-model thinking-format config needed). If the catalog fetch fails (offline), only the chosen model is registered. Uses `~/.sference/credentials.json` or `SFERENCE_API_KEY`. Default model: `deepseek-ai/DeepSeek-V4.1-Flash-1017` (override with `--model` or `SFERENCE_MODEL`).
|
|
131
148
|
|
|
132
149
|
#### `sference launch codex`
|
|
133
150
|
|
|
@@ -135,7 +152,7 @@ Requires the [Pi CLI](https://pi.dev/docs) on `PATH`. Writes a `sference` provid
|
|
|
135
152
|
|---------|-------------|
|
|
136
153
|
| `sference launch codex` | Launch the [Codex CLI](https://developers.openai.com/codex/cli) against Sference's `/v1/responses` |
|
|
137
154
|
| `sference launch codex --dry-run` | Print provider config and command without launching Codex |
|
|
138
|
-
| `sference launch codex --model
|
|
155
|
+
| `sference launch codex --model zai-org/GLM-5.3` | Override catalog model (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
139
156
|
| `sference launch codex -- exec "fix the bug"` | Forward Codex args (here: non-interactive `codex exec`) |
|
|
140
157
|
| `sference launch codex -- -c model_reasoning_effort=high` | Override the reasoning effort (default `medium`) |
|
|
141
158
|
|
|
@@ -143,15 +160,34 @@ Requires `codex` on `PATH`. The `sference` model provider is passed as `codex -c
|
|
|
143
160
|
|
|
144
161
|
**Sub-agents and MCP servers** work: the Sference provider applies to the whole session, so agents Codex spawns run on Sference too. The launcher also writes `~/.sference/codex/models.json`, a Codex model catalog listing only the Sference models, and passes it as `model_catalog_json`. Without it Codex offers `spawn_agent` its own OpenAI models, and a sub-agent started on one of them fails. Each entry is built at launch from the catalog bundled with your Codex (`codex debug models --bundled`), so it always matches your Codex version; if that command is unavailable the launcher warns and starts without the catalog. An `agents.default_subagent_model` in your Codex config still pins sub-agents to an OpenAI model, which Sference cannot serve (the launcher warns about it).
|
|
145
162
|
|
|
163
|
+
#### `sference launch cursor`
|
|
164
|
+
|
|
165
|
+
| Command | Description |
|
|
166
|
+
|---------|-------------|
|
|
167
|
+
| `sference launch cursor` | Turn Sference routing on for Cursor |
|
|
168
|
+
| `sference launch cursor --dry-run` | Print what would change without writing anything |
|
|
169
|
+
| `sference launch cursor --model zai-org/GLM-5.3` | Override the default model for new chats (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`) |
|
|
170
|
+
| `sference launch cursor --sference-only` | Disable all Cursor-provided models, leaving only Sference models |
|
|
171
|
+
| `sference launch cursor --api-key sk_...` | Store this API key in Cursor (default: your credential, or a newly created one) |
|
|
172
|
+
| `sference launch cursor status` | Show whether Cursor chats on Sference right now |
|
|
173
|
+
| `sference launch cursor off` | Restore Cursor's settings from before `launch cursor` |
|
|
174
|
+
| `sference launch cursor off --revoke-key` | Also revoke the API key that was created for Cursor |
|
|
175
|
+
|
|
176
|
+
Configures [Cursor](https://cursor.com) to run its chat on Sference through Cursor's own-API-key (BYOK) mode: the launcher writes the Sference base URL (`/v1`), your key, and the live model catalog into Cursor's settings database, and sets the default model for new chats (default `deepseek-ai/DeepSeek-V4.1-Flash-1017`). Cursor's own models stay available side by side unless `--sference-only` is passed. Requires a **signed-in paid Cursor plan** (Pro/Business/Enterprise) — BYOK is not available on the free plan.
|
|
177
|
+
|
|
178
|
+
Key handling: with an `sk_...` credential (or `--api-key`) that key is stored directly; with a device login the launcher creates a dedicated API key (tagged `sference-cli-cursor`, visible in Console → API Keys) so the 24 h device token never lands in another app. If Cursor already has an OpenAI key saved, the launcher refuses unless `--replace-existing-key` is passed (the old key cannot be restored; on macOS you will be asked to confirm the Keychain change).
|
|
179
|
+
|
|
180
|
+
Safety: quit Cursor first — it rewrites its settings from memory on exit and would discard the change (the launcher refuses while Cursor is running; `--force` overrides, and you must then fully restart Cursor). Everything is written in one transaction, the prior settings are backed up to `~/.sference/cursor/backup.json`, and `off` restores them. **Scope:** this covers Cursor chat and the model picker — Tab completions, chat titles, Agent Review (Bugbot), and cloud agents keep running on Cursor's own models, same as any BYOK setup.
|
|
181
|
+
|
|
146
182
|
### Batch
|
|
147
183
|
|
|
148
184
|
| Command | Description |
|
|
149
185
|
|---------|-------------|
|
|
150
186
|
| `sference batch list` | List batches (table; `--json` for raw payload) |
|
|
151
|
-
| `sference batch submit` | Submit a JSONL file (`--input-file
|
|
187
|
+
| `sference batch submit` | Submit a JSONL file (`--input-file`; `--model` applies to content-only lines and defaults to `SFERENCE_MODEL` / DeepSeek V4.1 Flash; `--window` `24h`) |
|
|
152
188
|
| `sference batch stream` | Submit, wait, print **JSONL results on stdout** (see below) |
|
|
153
189
|
| `sference batch status` | Get one batch (`--batch-id`, `--json`) |
|
|
154
|
-
| `sference batch wait` | Poll until terminal state (`--batch-id`, `--poll-interval`, `--timeout
|
|
190
|
+
| `sference batch wait` | Poll until terminal state (`--batch-id`, `--poll-interval`, `--timeout` (default 30 s), `--json`) |
|
|
155
191
|
| `sference batch results` | JSON results payload (`--batch-id`, `--json`) |
|
|
156
192
|
| `sference batch cancel` | Cancel a batch (`--batch-id`, `--json`) |
|
|
157
193
|
| `sference batch download-results` | Download results JSONL to a file (`--batch-id`, `--out`, `--format jsonl`) |
|
|
@@ -160,9 +196,9 @@ Requires `codex` on `PATH`. The `sference` model provider is passed as `codex -c
|
|
|
160
196
|
|
|
161
197
|
| Command | Description |
|
|
162
198
|
|---------|-------------|
|
|
163
|
-
| `sference responses create` | Create one response (`--model`, `--
|
|
164
|
-
| `sference responses result` | Poll until terminal state (`--id`, `--poll-
|
|
165
|
-
| `sference responses tail` | Print completion events as JSONL via `GET /v1/responses/events` (optional `--stream-id` to scope to a stream; omit for non-stream completions). Flags: `--consumer`, `--from-latest`, `--no-checkpoint`, `--poll-
|
|
199
|
+
| `sference responses create` | Create one response (`--content`; optional `--model`, `--instructions`, `--max-output-tokens`, `--enable-thinking/--disable-thinking`; `--background` submits async and returns immediately). The sync default blocks; if the server-side wait times out, the request is **cancelled** and the command fails — use `--background` + `sference responses result` for long requests |
|
|
200
|
+
| `sference responses result` | Poll until terminal state (`--id`, `--poll-interval` seconds) |
|
|
201
|
+
| `sference responses tail` | Print completion events as JSONL via `GET /v1/responses/events` (optional `--stream-id` to scope to a stream; omit for non-stream completions). Flags: `--consumer`, `--from-latest`, `--no-checkpoint`, `--poll-interval` |
|
|
166
202
|
|
|
167
203
|
### Decisions (`/v1/decisions`)
|
|
168
204
|
|
|
@@ -186,20 +222,20 @@ Long-lived **streams** are separate from **batches**: you create a stream, submi
|
|
|
186
222
|
| `sference stream create` | Create a stream (`--name`, `--window` `24h`, `--json`) |
|
|
187
223
|
| `sference stream list` | List streams (`--json`) |
|
|
188
224
|
| `sference stream status` | Full detail + counters (`--stream-id`, `--json`) |
|
|
189
|
-
| `sference stream submit` |
|
|
225
|
+
| `sference stream submit` | Queue one **background** response per JSONL line via `POST /v1/responses` (`metadata.stream_id` and `completion_window: "24h"` set automatically; `--stream-id`, `--input-file`, optional `--model` for lines without one). The whole file is validated before anything is sent |
|
|
190
226
|
| `sference stream cancel` | Stop accepting new items and stop enqueueing pending work; does not auto-cancel in-flight requests (`--stream-id`, `--json`) |
|
|
191
227
|
| `sference stream archive` | Finalize the stream (optional after cancel); no new items (`--stream-id`, `--json`) |
|
|
192
228
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```json
|
|
196
|
-
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"Qwen/Qwen3.6-35B-A3B","messages":[{"role":"user","content":"hi"}]}}
|
|
197
|
-
```
|
|
229
|
+
Accepted JSONL lines for `stream submit`:
|
|
198
230
|
|
|
199
231
|
```json
|
|
200
232
|
{"content":"hi"}
|
|
233
|
+
{"input":[{"role":"user","content":"hi"}],"instructions":"Be brief.","max_output_tokens":256}
|
|
234
|
+
{"custom_id":"req-1","method":"POST","url":"/v1/chat/completions","body":{"model":"zai-org/GLM-5.3","messages":[{"role":"user","content":"hi"}],"max_tokens":256}}
|
|
201
235
|
```
|
|
202
236
|
|
|
237
|
+
Chat-shaped bodies are mapped onto the Responses API (`messages` → `input`, `max_tokens` → `max_output_tokens`); `custom_id` lands in `metadata.custom_id`. Forwarded fields: `model`, `input`, `instructions`, `max_output_tokens`, `temperature`, `top_p`, `include_reasoning`, `enable_thinking`, `metadata`; any other field is rejected rather than silently dropped.
|
|
238
|
+
|
|
203
239
|
---
|
|
204
240
|
|
|
205
241
|
## Streaming batches (`batch stream`)
|
|
@@ -217,10 +253,10 @@ Example:
|
|
|
217
253
|
sference batch stream --input-file workload.jsonl > results.jsonl
|
|
218
254
|
```
|
|
219
255
|
|
|
220
|
-
Content-only JSONL (model supplied globally):
|
|
256
|
+
Content-only JSONL (model supplied globally; omit `--model` for the default):
|
|
221
257
|
|
|
222
258
|
```bash
|
|
223
|
-
sference batch stream --input-file prompts.jsonl --model
|
|
259
|
+
sference batch stream --input-file prompts.jsonl --model zai-org/GLM-5.3 > results.jsonl
|
|
224
260
|
```
|
|
225
261
|
|
|
226
262
|
### Resumable cache
|
|
@@ -229,7 +265,7 @@ Batches can take a long time. If you **interrupt** the command (e.g. Ctrl+C) and
|
|
|
229
265
|
|
|
230
266
|
- Cache file: **`~/.sference/stream_cache.json`** (override with **`SFERENCE_STREAM_CACHE`**).
|
|
231
267
|
- Key: **SHA-256** of the raw input file bytes (same bytes ⇒ same key, regardless of path).
|
|
232
|
-
- Stored fields: `batch_id`, `created_at
|
|
268
|
+
- Stored fields: `batch_id`, `base_url`, `created_at` (an entry is only reused against the same API base URL).
|
|
233
269
|
- After results are written to stdout, the entry for that input is **removed** so the cache does not grow forever.
|
|
234
270
|
- If the cached batch no longer exists on the server (404), the cache entry is dropped and a **new** batch is submitted.
|
|
235
271
|
|
|
@@ -264,14 +300,14 @@ The SDK and CLI accept two line shapes (see also [`fixtures/example_batch.jsonl`
|
|
|
264
300
|
1. **OpenAI-compatible envelope:** each line has `custom_id`, `method`, `url`, and `body`. The API receives only `custom_id` + inner `body` (`method`/`url` are ignored). Inner `body` may use:
|
|
265
301
|
- **Chat completions:** `messages` (non-empty array), plus optional `temperature`, `max_tokens`, `tools`, …
|
|
266
302
|
- **Responses API:** `input` (string or message array), optional `instructions`, `max_output_tokens`, … — normalized to chat format at batch create.
|
|
267
|
-
2. **Content-only:** each line is `{"content": "..."}`.
|
|
303
|
+
2. **Content-only:** each line is `{"content": "..."}`. The model comes from `--model`, else `SFERENCE_MODEL`, else `deepseek-ai/DeepSeek-V4.1-Flash-1017`.
|
|
268
304
|
|
|
269
305
|
Invalid row bodies return **HTTP 400** at create with `requests[i]` and `custom_id` in the error message (nothing is enqueued). Do not set `background: true` inside batch row bodies.
|
|
270
306
|
|
|
271
307
|
Example Responses-shaped JSONL line:
|
|
272
308
|
|
|
273
309
|
```json
|
|
274
|
-
{"custom_id":"r2","method":"POST","url":"/v1/responses","body":{"model":"
|
|
310
|
+
{"custom_id":"r2","method":"POST","url":"/v1/responses","body":{"model":"deepseek-ai/DeepSeek-V4.1-Flash-1017","input":[{"role":"user","content":"hi"}],"max_output_tokens":256}}
|
|
275
311
|
```
|
|
276
312
|
|
|
277
313
|
---
|