@skyphusion/create-prism 1.0.4 → 1.3.0

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.
Files changed (45) hide show
  1. package/README.md +10 -8
  2. package/index.js +3 -2
  3. package/package.json +1 -1
  4. package/template/CONTRIBUTING.md +18 -3
  5. package/template/MIGRATIONS.md +52 -0
  6. package/template/README.md +79 -52
  7. package/template/docs/legal/INSTANCE-ACCEPTABLE-USE.md +5 -2
  8. package/template/docs/legal/INSTANCE-PRIVACY.md +128 -27
  9. package/template/migrations/0005_auth_attempts_retention.sql +23 -0
  10. package/template/package.json +6 -6
  11. package/template/public/app.js +21 -8
  12. package/template/public/index.html +23 -9
  13. package/template/public/styles.css +45 -7
  14. package/template/public/url-safety.js +6 -6
  15. package/template/schema.sql +6 -0
  16. package/template/src/ai-binding.ts +125 -3
  17. package/template/src/auth.ts +6 -0
  18. package/template/src/env.ts +38 -10
  19. package/template/src/gateway-credentials.ts +118 -22
  20. package/template/src/index.ts +2 -0
  21. package/template/src/providers/anthropic.ts +4 -4
  22. package/template/src/providers/openai-image.ts +10 -0
  23. package/template/src/providers/xai.ts +4 -4
  24. package/template/src/rate-limit.ts +26 -0
  25. package/template/src/routes/chat.ts +18 -9
  26. package/template/src/routes/prefs.ts +46 -5
  27. package/template/src/routes/rag.ts +135 -61
  28. package/template/src/routes/shared.ts +27 -11
  29. package/template/src/routes/workflow.ts +2 -5
  30. package/template/src/skyphusion-search.ts +108 -0
  31. package/template/src/user-prefs.ts +16 -3
  32. package/template/src/version.ts +1 -1
  33. package/template/tests/ai-binding-rest.test.ts +154 -0
  34. package/template/tests/csp.test.ts +11 -6
  35. package/template/tests/gateway-credentials.test.ts +101 -3
  36. package/template/tests/openai-image.test.ts +21 -1
  37. package/template/tests/rag-metadata-filter.test.ts +135 -0
  38. package/template/tests/skip-link.test.ts +164 -0
  39. package/template/tests/skyphusion-search.test.ts +144 -0
  40. package/template/tests/vectorize-backfill-metadata.test.ts +166 -0
  41. package/template/tests-integration/auth.test.ts +346 -2
  42. package/template/tests-integration/pdf-extract.test.ts +71 -0
  43. package/template/wrangler.example.toml +26 -11
  44. package/template/src/searxng.ts +0 -75
  45. package/template/tests/searxng.test.ts +0 -51
package/README.md CHANGED
@@ -64,10 +64,9 @@ template `wrangler.example.toml`.
64
64
 
65
65
  **Optional**
66
66
 
67
- - `SEARXNG_URL` (and the `SEARXNG_ACCESS_CLIENT_ID` / `SEARXNG_ACCESS_CLIENT_SECRET`
68
- halves when your SearXNG instance sits behind Cloudflare Access) enable the opt-in
69
- web-search source. Unset, web search silently skips SearXNG; keyless Wikipedia still
70
- runs.
67
+ - `SEARCH` service binding (`service = "skyphusion-search"`, `entrypoint = "SearchEntrypoint"`) enables the opt-in
68
+ web-search source. Delete the block if you have no such worker: the source then
69
+ reports `absent`, and keyless Wikipedia still runs.
71
70
 
72
71
  ## Auth: two modes, one identity seam (`AUTH_MODE`)
73
72
 
@@ -79,10 +78,13 @@ The scaffolded worker learns who a caller is one of two ways, chosen by the
79
78
  Inference bills the deployer, through the worker gateway secrets `GATEWAY_ID` and
80
79
  `CF_AIG_TOKEN`.
81
80
  - **`public` (the open, first-party-signup service).** First-party username/password
82
- accounts behind an opaque server-side session cookie. Every user brings their own AI
83
- Gateway credentials (mandatory BYOK), so **the worker holds no gateway secrets and
84
- visitor inference never bills the host**. Do not set `GATEWAY_ID` / `CF_AIG_TOKEN` on
85
- a public worker; they are ignored in this mode. No Cloudflare Access needed.
81
+ accounts behind an opaque server-side session cookie. Every user brings their own
82
+ Cloudflare account ID, AI Gateway slug, and API token (mandatory BYOK), so the worker
83
+ holds no gateway secrets and gateway-routed inference bills the visitor's account.
84
+ The exception is the few Workers AI paths AI Gateway cannot proxy (live voice,
85
+ Deepgram STT, six image models), which run on the host's `AI` binding and bill the
86
+ host. Do not set `GATEWAY_ID` / `CF_AIG_TOKEN` on a public worker; they are ignored in
87
+ this mode. No Cloudflare Access needed.
86
88
 
87
89
  Either way, one stable opaque account id scopes history and R2 ownership, so cross-user
88
90
  access is impossible even if an id is guessed.
package/index.js CHANGED
@@ -127,11 +127,12 @@ Next steps:
127
127
  npm run db:migrate:remote
128
128
  npx wrangler r2 bucket create skyphusion-llm
129
129
  npx wrangler vectorize create skyphusion-llm-vec --dimensions=768 --metric=cosine
130
+ npx wrangler vectorize create-metadata-index skyphusion-llm-vec --property-name=user_email --type=string
130
131
  5. Set the worker secrets (access mode, the default):
131
132
  npx wrangler secret put GATEWAY_ID (your AI Gateway slug)
132
133
  npx wrangler secret put CF_AIG_TOKEN (AI Gateway Run token, for paid models)
133
- Optional web search: SEARXNG_URL (and the two SEARXNG_ACCESS_* halves if
134
- the instance is Access-gated). See the README for the full secret list.
134
+ Optional web search: the SEARCH service binding to skyphusion-search
135
+ (entrypoint SearchEntrypoint; delete the block if you have no such worker). See the README.
135
136
  6. Verify, then deploy:
136
137
  npm run typecheck
137
138
  npm test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyphusion/create-prism",
3
- "version": "1.0.4",
3
+ "version": "1.3.0",
4
4
  "description": "Scaffold a new prism deployment: a multimodal AI playground on Cloudflare Workers.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "Conrad Rockenhaus",
@@ -79,6 +79,21 @@ By submitting a contribution, you agree that your work will be licensed under AG
79
79
  Sign off every commit with `git commit -s`. That appends a `Signed-off-by:` line certifying the
80
80
  [Developer Certificate of Origin](https://developercertificate.org/) (DCO): a lightweight,
81
81
  per-commit affirmation that you wrote the patch or otherwise have the right to submit it under the
82
- project's license. We use the DCO instead of a CLA. The name and email must be real and match the
83
- commit author; unsigned commits may be asked to amend with `git commit --amend -s` (or
84
- `git rebase --signoff` for a series) before merge.
82
+ project's license. We use the DCO instead of a CLA. Use a real name and email.
83
+
84
+ This is checked, not just asked for. The `dco` workflow (`.github/workflows/dco.yml`) runs on every
85
+ pull request and fails if any non-merge commit in the PR lacks a `Signed-off-by:` trailer whose
86
+ email matches the commit author email (case-insensitive). A PR that adds no non-merge commits
87
+ fails, because there is nothing to certify. Only pull requests opened by the `dependabot[bot]`
88
+ account are exempt; the exemption follows the account that opened the PR, not the commit author
89
+ email, so a bot-looking email on your own commits is still checked. It applies to everyone,
90
+ maintainers included; history already on `main` is not re-checked.
91
+
92
+ If the check fails, sign off the branch and force-push; the job summary prints the exact command:
93
+
94
+ ```bash
95
+ git rebase --signoff <fork-point> # or: git commit --amend -s --no-edit (single commit)
96
+ git push --force-with-lease
97
+ ```
98
+
99
+ To stop forgetting, use an alias such as `git config --global alias.cs 'commit -s'`.
@@ -8,6 +8,8 @@ redeploy.
8
8
 
9
9
  **Migration philosophy (read this first).** `schema.sql` is the canonical full schema for standing up a *fresh* database. It contains non-idempotent `ALTER TABLE` statements, so re-running it against a database that already has tables will raise `SQLITE_ERROR: duplicate column name` and, because `wrangler d1 execute --file` runs the whole file as one transaction, abort and roll back the entire run. **Never re-run `schema.sql` against an existing database.** To upgrade an existing deployment, apply only the delta for each version you're crossing, using the explicit commands below (or, for releases that ship one, the per-release `migrate-vX.Y.Z.sql` delta file). Apply each version's delta in order, then redeploy.
10
10
 
11
+ **v1.1.0 (account-scoped BYOK): BREAKING for existing BYOK users, no DDL.** `account_id` is a new key in the existing `user_prefs.prefs_json` blob. Every public-mode user saved before v1.1.0 (slug + token only) is refused with HTTP 412 `gateway_account_id_required` on every inference route until they add their 32-hex Cloudflare account ID under Account > AI Gateway, and their token must hold Workers AI Read as well as AI Gateway Run. A user who upgrades and does nothing loses inference. Tell your users before you tag. Access-mode installs using worker secrets are unaffected.
12
+
11
13
  v0.13.0 onward touched the D1 schema only at v0.20.0, v0.20.2, and v0.20.3; everything else in the v0.13.0 to v0.20.0 range is code-only. The pre-v0.13.0 migrations (v0.7.0 to v0.10.0) are below for anyone upgrading from very old deployments.
12
14
 
13
15
  For v0.7.0 (video generation):
@@ -24,6 +26,7 @@ For v0.8.0 (RAG Pass 1):
24
26
 
25
27
  ```
26
28
  npx wrangler vectorize create skyphusion-llm-vec --dimensions=768 --metric=cosine
29
+ npx wrangler vectorize create-metadata-index skyphusion-llm-vec --property-name=user_email --type=string
27
30
  # Create the documents and chunks tables explicitly. (Historically this step
28
31
  # was "--file=schema.sql"; that is no longer safe because today's schema.sql
29
32
  # also carries later non-idempotent ALTERs. Use the explicit DDL below.)
@@ -195,3 +198,52 @@ statement and continues. Fresh installs get all of the above from `schema.sql` a
195
198
  none of these deltas.
196
199
 
197
200
  All other releases are code/frontend-only with no D1 migration.
201
+
202
+ ## Vectorize metadata filter for RAG retrieval (fleet-chezmoi#1636)
203
+
204
+ **Why.** Retrieval used to query Vectorize globally and scope by user only in the D1 join. On a shared
205
+ index, a user with a small share of the vectors can get a top-K made entirely of other users' vectors,
206
+ which the join then drops, so they see no results even when their own documents match.
207
+ `VEC_METADATA_FILTER = "on"` filters the Vectorize query on `user_email` as well. The D1 join stays,
208
+ as the second layer of scope.
209
+
210
+ **It is off by default, and the order matters.** A Vectorize metadata index is not retroactive. Turn
211
+ the filter on before the backfill, and every vector written before the index existed is invisible to it:
212
+ retrieval returns nothing.
213
+
214
+ 1. Create the metadata index (once):
215
+
216
+ ```bash
217
+ npx wrangler vectorize create-metadata-index skyphusion-llm-vec --property-name=user_email --type=string
218
+ ```
219
+
220
+ Vectors upserted from now on are indexed automatically.
221
+
222
+ 2. If the index already holds vectors, re-upsert them. The script reads every id from D1
223
+ `chunks.vector_id`, fetches each vector, and writes it back with the same id, values and metadata.
224
+ Nothing is re-embedded. It refuses to run until step 1 is done, prints counts only (never an id or a
225
+ value), and is safe to re-run.
226
+
227
+ ```bash
228
+ CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=... \
229
+ node scripts/vectorize-backfill-metadata.mjs --index skyphusion-llm-vec --d1 <D1 database uuid> --dry-run
230
+ CLOUDFLARE_API_TOKEN=... CLOUDFLARE_ACCOUNT_ID=... \
231
+ node scripts/vectorize-backfill-metadata.mjs --index skyphusion-llm-vec --d1 <D1 database uuid>
232
+ ```
233
+
234
+ The token needs Vectorize Edit and D1 Read. Exit 0 means every D1 id was re-upserted. Exit 1 means
235
+ some ids had no vector (`gaps`) or no `user_email` metadata (`missing_metadata`); do not turn the
236
+ filter on until that is understood. Exit 2 means it refused or could not read, and nothing was written.
237
+
238
+ 3. Verify, then set `VEC_METADATA_FILTER = "on"` (a plain var) and deploy. Check that a user with
239
+ documents still gets results, and that the index `info` vector count matches the script's `upserted`
240
+ count. Allow a few seconds after the upsert for Vectorize to apply it.
241
+
242
+ A fresh deployment that creates the metadata index before its first upload needs only step 1, then the
243
+ var.
244
+
245
+ **Caveat:** a string metadata index matches on the first 64 bytes of the value. Public-mode identities
246
+ (`usr_` plus 24 hex characters) are well inside that. In access mode, two emails sharing their first 64
247
+ bytes would share an index entry. The D1 join still scopes their results correctly, so the worst case
248
+ for those users is the old global behaviour, not a disclosure.
249
+
@@ -4,7 +4,7 @@
4
4
  [![Typecheck](https://github.com/skyphusion-labs/prism/actions/workflows/typecheck.yml/badge.svg)](https://github.com/skyphusion-labs/prism/actions/workflows/typecheck.yml)
5
5
  [![Voice chat](https://img.shields.io/badge/%F0%9F%8E%99%EF%B8%8F_voice_chat-speak_%26_hear_chat_models-6d8cff)](#voice-chat)
6
6
 
7
- A multimodal AI playground deployed as a single Cloudflare Worker. **Live demo:** https://play.skyphusion.org (free signup, bring your own AI Gateway). Catalog breadth is live at `GET /api/models` (and `src/models.ts`): **93** models (44 chat + 21 image + 19 video + 3 TTS + 4 STT + 1 music + 1 live voice); the tables under [Features](#features) list every id. Native clients hit the commercial plane ([prism-control-plane](https://github.com/skyphusion-labs/prism-control-plane)); this Worker is the playground surface (RAG, projects, compact, web search). **Hands-free voice chat**, cross-model artifact reuse, RAG, projects, Discord ingestion, web search, SSE streaming, and multi-turn conversations (with optional **compact**). One web UI with first-party accounts, per-user history, R2 for all binary artifacts.
7
+ A multimodal AI playground deployed as a single Cloudflare Worker. **Live demo:** https://play.skyphusion.org (free signup, bring your own AI Gateway; a short list of demo capabilities is funded by the host, see [Who pays for what](#who-pays-for-what)). Catalog breadth is live at `GET /api/models` (and `src/models.ts`): **93** models (44 chat + 21 image + 19 video + 3 TTS + 4 STT + 1 music + 1 live voice); the tables under [Features](#features) list every id. Native clients hit the commercial plane ([prism-control-plane](https://github.com/skyphusion-labs/prism-control-plane)); this Worker is the playground surface (RAG, projects, compact, web search). **Hands-free voice chat**, cross-model artifact reuse, RAG, projects, Discord ingestion, web search, SSE streaming, and multi-turn conversations (with optional **compact**). One web UI with first-party accounts, per-user history, R2 for all binary artifacts.
8
8
 
9
9
  ```mermaid
10
10
  flowchart TB
@@ -70,8 +70,8 @@ A working template for the Cloudflare AI stack and a self-hosted multimodal play
70
70
 
71
71
  One Worker, no framework, no build step beyond TypeScript. The interesting parts are the patterns, not the model count:
72
72
 
73
- - **Unified `env.AI.run()` binding** drives every modality through one call surface: chat, vision input, image gen, TTS, STT, conversational STT + voice chat (Flux over a WebSocket), video gen, and music gen. Paid third-party models bill through **Cloudflare Unified Billing** on your AI Gateway.
74
- - **Per-provider dispatch helpers** for Anthropic Claude, xAI Grok, and Google Gemini, each transforming our internal `messages` shape into the provider's native format while authorizing keylessly via `cf-aig-authorization`. OpenAI chat and Workers AI ride the `env.AI.run` binding directly. **Sole deployer BYOK carve-out (v0.174.0):** optional `OPENAI_API_KEY` lets `openai/gpt-image-*` call `api.openai.com` for transparent PNG (the CF proxy 7003-rejects `background`/`output_format`). When unset, those models stay opaque on Unified Billing. Do not set this key on public multi-tenant deploys.
73
+ - **Unified `env.AI.run()` binding** drives every modality through one call surface: chat, vision input, image gen, TTS, STT, conversational STT + voice chat (Flux over a WebSocket), video gen, and music gen. Paid third-party models bill through **Cloudflare Unified Billing** on your AI Gateway. The binding can only reach the worker's own Cloudflare account, so in public mode (v1.1.0) the same `aiRun` seam swaps to the Cloudflare REST API (`/accounts/{account_id}/ai/run`) on each user's own account; see [Who pays for what](#who-pays-for-what).
74
+ - **Per-provider dispatch helpers** for Anthropic Claude, xAI Grok, and Google Gemini, each transforming our internal `messages` shape into the provider's native format while authorizing keylessly via `cf-aig-authorization`. OpenAI chat and Workers AI ride the `env.AI.run` binding directly. **Sole deployer BYOK carve-out (v0.174.0):** optional `OPENAI_API_KEY` lets `openai/gpt-image-*` call `api.openai.com` for transparent PNG (the CF proxy 7003-rejects `background`/`output_format`). When unset, those models stay opaque on Unified Billing. Public mode (`AUTH_MODE=public`) ignores the key even if set (v1.0.5, prism#193).
75
75
  - **SSE streaming** (v0.13.0+) for chat models across providers: Anthropic native SSE, Workers AI / OpenAI-compatible SSE (incl. Moonshot K3), xAI, OpenAI Chat Completions and Responses API (v0.173.0), and Gemini.
76
76
  - **AI Gateway** wraps every call for observability, caching, and rate-limiting.
77
77
  - **D1** holds chat metadata, multi-turn conversation history, and RAG chunk text. **R2** holds all binary artifacts. **Vectorize** holds RAG embeddings (768-dim BGE-base). The chat row references R2 keys; nothing binary touches D1.
@@ -231,7 +231,7 @@ One Worker, no framework, no build step beyond TypeScript. The interesting parts
231
231
 
232
232
  **Discord ingestion (v0.20.3+):** import a [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter) JSON export into a project. The worker parses the export, groups messages into conversation-aware chunks (by author, time gap, and channel), and embeds them into the project's retrieval scope, so you can ask questions across an archived Discord channel's history. Import is a file picker in the project's "manage documents" modal.
233
233
 
234
- **Web search (v0.17.0):** opt-in retrieval source that queries self-hosted SearXNG (general web; v0.166.0) and Wikipedia (reference and lore) in parallel. Snippets folded into the system prompt the same way RAG chunks are. Per-turn toggle. SearXNG requires `SEARXNG_URL`; Wikipedia needs no setup. See [Web search](#web-search) below.
234
+ **Web search (v0.17.0):** opt-in retrieval source that queries the `skyphusion-search` Worker (service binding `SEARCH`) and Wikipedia (reference and lore) in parallel. Snippets folded into the system prompt the same way RAG chunks are. Per-turn toggle. Without the `SEARCH` binding that source reports absent; Wikipedia needs no setup. See [Web search](#web-search) below.
235
235
 
236
236
  **Streaming (v0.13.0+):** `POST /api/chat/stream` returns SSE for any chat model flagged `streaming: true` in the catalog. Token deltas surface as `{ type: "delta", text: "..." }` events, terminal completion as `{ type: "done", ... }` with token counts and conversation IDs. Client disconnect aborts the upstream model call immediately.
237
237
 
@@ -241,7 +241,7 @@ One Worker, no framework, no build step beyond TypeScript. The interesting parts
241
241
 
242
242
  **UI (focus-mode redesign, v0.110.0+):** a single centered conversation column with a floating composer; the sidebar (searchable history, projects, documents) is a slide-in overlay; a searchable model picker (type to filter, v0.111.0); a ⚙ popover for the system prompt + retrieval toggles and an account menu in the top bar; a paperclip attach button and a voice-chat mic; conversation header **compact** / **expand** when a thread has enough turns (v0.175.7). Capability-aware mode switching (vision-only attachment types; image-mode re-skins to "negative prompt"; TTS / STT / video / music / voice hide irrelevant inputs), FLUX.2 reference-image attach UI (v0.16.0), per-turn web-search toggle (v0.17.0), per-user replay-able history with attachments and generated artifacts, Enter to send / Shift+Enter for newline. Mobile-optimized (safe-area insets, touch targets, no iOS zoom).
243
243
 
244
- **Auth (two modes via `AUTH_MODE`):** **public** (the hosted product) is first-party username/password signup with an opaque session cookie and mandatory per-user BYOK: each user brings their own AI Gateway, the worker holds no gateway secrets, and inference bills the user, never the host. **access** (the default, for private self-host) puts Cloudflare Access on the worker URL and scopes per-user history and R2 ownership via `Cf-Access-Authenticated-User-Email` (free up to 50 seats on Zero Trust). See [Running the public service](#running-the-public-service).
244
+ **Auth (two modes via `AUTH_MODE`):** **public** (the hosted product) is first-party username/password signup with an opaque session cookie and mandatory per-user BYOK: each user supplies their Cloudflare account ID, AI Gateway slug, and API token, and the worker ignores its own gateway and OpenAI secrets. A handful of Workers AI (`@cf/*`) paths that cannot ride a gateway still run on the host's `AI` binding and bill the host; see [Who pays for what](#who-pays-for-what). **access** (the default, for private self-host) puts Cloudflare Access on the worker URL and scopes per-user history and R2 ownership via `Cf-Access-Authenticated-User-Email` (free up to 50 seats on Zero Trust). See [Running the public service](#running-the-public-service).
245
245
 
246
246
  ## Stack
247
247
 
@@ -318,7 +318,7 @@ echo "CF_AIG_TOKEN=your-cloudflare-api-token" >> .dev.vars
318
318
 
319
319
  Then enable Unified Billing for each provider you plan to use: Dashboard > AI > AI Gateway > your gateway > Settings. Without credits, proxied models fail with `2021: Invalid User Credentials`.
320
320
 
321
- OpenAI chat never uses a deployer key. The **only** optional deployer secret is `OPENAI_API_KEY` (v0.174.0): when set, `openai/gpt-image-*` call `api.openai.com` for transparent PNG; when unset they stay opaque on Unified Billing. Leave it unset on public multi-tenant deploys so visitors cannot burn host credits.
321
+ OpenAI chat never uses a deployer key. The **only** optional deployer secret is `OPENAI_API_KEY` (v0.174.0): when set, `openai/gpt-image-*` call `api.openai.com` for transparent PNG; when unset they stay opaque on Unified Billing. Public mode (`AUTH_MODE=public`) ignores the key even if set (v1.0.5, prism#193), so it cannot bill the host for a visitor's image.
322
322
 
323
323
  > **Public service:** to run the open, first-party-signup instance instead (no worker gateway secrets; every user brings their own AI Gateway), see [Running the public service](#running-the-public-service), and skip steps 1, 1b, and 6.
324
324
 
@@ -357,8 +357,13 @@ For RAG over PDFs and spreadsheets:
357
357
 
358
358
  ```
359
359
  npx wrangler vectorize create skyphusion-llm-vec --dimensions=768 --metric=cosine
360
+ npx wrangler vectorize create-metadata-index skyphusion-llm-vec --property-name=user_email --type=string
360
361
  ```
361
362
 
363
+ The second command adds a `user_email` metadata index, which lets retrieval filter by user inside Vectorize
364
+ (`VEC_METADATA_FILTER = "on"`). Create it now, before any upload: an index added later does not cover
365
+ vectors already written, and those need the backfill in [MIGRATIONS.md](MIGRATIONS.md).
366
+
362
367
  The `VEC` binding is already in the template. If you don't intend to use RAG, the worker still functions; the binding just goes unused.
363
368
 
364
369
  ### 5. First deploy
@@ -390,22 +395,18 @@ For an open, self-serve **public service**, do not use Cloudflare Access at all:
390
395
 
391
396
  Do **not** use a **Bypass** policy on the main app URL. Bypass skips login, so the worker never receives a user email and everyone shares the `anonymous` bucket.
392
397
 
393
- ### 7. Optional: web search (SearXNG)
394
-
395
- For the v0.17.0 web-search feature (SearXNG source added v0.166.0), point the worker at a self-hosted SearXNG instance with the JSON API enabled:
396
-
397
- ```
398
- npx wrangler secret put SEARXNG_URL
399
- ```
398
+ ### 7. Optional: web search
400
399
 
401
- If the instance is behind Cloudflare Access, also set the service-token halves:
400
+ Web search calls the `skyphusion-search` Worker through a service binding. The committed template already declares it:
402
401
 
403
- ```
404
- npx wrangler secret put SEARXNG_ACCESS_CLIENT_ID
405
- npx wrangler secret put SEARXNG_ACCESS_CLIENT_SECRET
402
+ ```toml
403
+ [[services]]
404
+ binding = "SEARCH"
405
+ service = "skyphusion-search"
406
+ entrypoint = "SearchEntrypoint"
406
407
  ```
407
408
 
408
- Without `SEARXNG_URL`, the SearXNG source is silently skipped. Wikipedia always works with no config. See [Web search](#web-search) below.
409
+ Copy that block into your `wrangler.toml`. If you do not run a worker with that script name, delete the block instead: `wrangler deploy` fails when the service does not exist. With the binding absent, the response says that source is `absent` and Wikipedia still runs. Wikipedia needs no config. See [Web search](#web-search) below.
409
410
 
410
411
  ### 8. Local development
411
412
 
@@ -418,7 +419,8 @@ npm run dev
418
419
  ## Running the public service
419
420
 
420
421
  Run Prism as an open, self-serve service: anyone signs up with a username and password, and each user
421
- brings their own Cloudflare AI Gateway so their model usage bills their own account, never yours. This
422
+ brings their own Cloudflare account and AI Gateway for inference. A short list of Workers AI (`@cf/*`) paths
423
+ that cannot ride a gateway still run on your `AI` binding and bill you; see [Who pays for what](#who-pays-for-what). This
422
424
  is how play.skyphusion.org runs. It is a **mode of the same worker** (`AUTH_MODE=public`), not a second
423
425
  deployment.
424
426
 
@@ -429,7 +431,7 @@ deployment.
429
431
  | `AUTH_MODE` | `access` (default; may be unset) | `public` |
430
432
  | Sign-in | Cloudflare Access (email OTP / OAuth) | First-party username + password signup |
431
433
  | Worker gateway secrets | `GATEWAY_ID` + `CF_AIG_TOKEN` (yours; you pay inference) | **None** (omit both; ignored even if set) |
432
- | Who pays for inference | You (the deployer) | Each user, via their own AI Gateway |
434
+ | Who pays for inference | You (the deployer) | Each user, on their own Cloudflare account (v1.1.0), except the gateway-bypass Workers AI paths: you |
433
435
  | Cloudflare Access app | Required | **Not used** |
434
436
 
435
437
  Everything else (D1, R2, Vectorize, deploy) is the same as the [Quickstart](#quickstart): do steps 2 to
@@ -445,8 +447,9 @@ AUTH_MODE = "public"
445
447
  ```
446
448
 
447
449
  In public mode the worker runs its own username/password accounts and reads identity from an opaque
448
- session cookie. It never reads `GATEWAY_ID` / `CF_AIG_TOKEN`, so a stray gateway secret cannot make the
449
- host pay for a visitor's inference; gateway credentials come only from each user's own settings.
450
+ session cookie. It never reads `GATEWAY_ID` / `CF_AIG_TOKEN` / `OPENAI_API_KEY` (the last from v1.0.5), so a
451
+ stray deployer secret cannot make the host pay for a visitor's partner-model inference; gateway credentials
452
+ come only from each user's own settings.
450
453
 
451
454
  ### 2. Do not set worker gateway secrets, and do not put Access in front
452
455
 
@@ -457,7 +460,7 @@ npx wrangler secret put GATEWAY_ID
457
460
  npx wrangler secret put CF_AIG_TOKEN
458
461
  ```
459
462
 
460
- For local dev, leave those keys out of `.dev.vars` as well. The optional web-search config (`SEARXNG_URL`, plus `SEARXNG_ACCESS_CLIENT_ID` / `SEARXNG_ACCESS_CLIENT_SECRET` for a gated instance) still works if you want global features, but most public demos omit it so visitors rely on their own gateway for paid models.
463
+ For local dev, leave those keys out of `.dev.vars` as well. Web search is the `SEARCH` service binding, not a secret. Omit that block when you have no `skyphusion-search` worker; Wikipedia still runs. Most public demos omit gateway secrets so visitors rely on their own gateway for paid models.
461
464
 
462
465
  Do **not** create a Cloudflare Access application for a public-mode worker: the app has its own signup, and an Access gate in front would add a second login before it.
463
466
 
@@ -470,14 +473,39 @@ npm run deploy
470
473
  ### How users get set up (mandatory BYOK)
471
474
 
472
475
  1. Open the URL and **sign up** with a username and password (no email, no Access login).
473
- 2. Open **Account > AI Gateway**; create a Cloudflare AI Gateway in the [Cloudflare dashboard](https://developers.cloudflare.com/ai-gateway/) if needed, and enable Unified Billing for the providers you want.
474
- 3. Paste the gateway **slug** and a Cloudflare API token with **AI Gateway Run** permission.
475
- 4. Run models. Until a user configures their gateway, paid and proxied models fail closed with a clear "configure your AI Gateway" prompt (HTTP 412), so no call ever bills the host.
476
+ 2. Open **Account > AI Gateway**; create a Cloudflare AI Gateway in the [Cloudflare dashboard](https://developers.cloudflare.com/ai-gateway/) if needed, and load Unified Billing credits on that account.
477
+ 3. Paste the Cloudflare **account ID** (32 hex characters, from the dashboard), the gateway **slug**, and an API token scoped to that account with **Workers AI Read** (the REST API refuses a token that holds only AI Gateway permissions) and **AI Gateway Run** (the provider-native gateway endpoints). All three are required.
478
+ 4. Run models. Until a user configures all three, every model fails closed with HTTP 412 and a code naming what is missing (`gateway_not_configured`, `gateway_account_id_required`, `cf_aig_token_required`). The gate controls who may run inference; it does not change which account the gateway-bypass paths bill (see below).
479
+
480
+ **Why the account ID is required (v1.1.0).** Before v1.1.0 a user stored only a slug and a token, and every call resolved that slug on the worker's own `AI` binding. Cloudflare pins a binding's gateway to the worker's account ("Must be in the same account as your Worker"), and an AI Gateway URL is `.../v1/{account_id}/{gateway_id}/{provider}`, so the account was always the host's: a user's own gateway was unreachable, and those calls either failed or billed the host, never the user. Users saved under that shape keep their slug and token but are refused with `gateway_account_id_required` until they add the account ID; nothing falls back to the host.
476
481
 
477
482
  ### Who pays for what
478
483
 
479
484
  - **You (the host)** pay Cloudflare for Workers, D1, R2, and Vectorize: the storage and compute for the service itself.
480
- - **Each user** pays for their own model inference through Unified Billing on the AI Gateway they configured.
485
+ - **Each user** pays for every call that goes through the `aiRun` seam or a provider-native gateway endpoint, on their own Cloudflare account and gateway (v1.1.0): all partner models (Anthropic, xAI, Google, OpenAI, and the other Unified Billing providers, including image, video, and music), Workers AI chat, TTS, Whisper STT, FLUX.1 / Lucid Origin image gen, and the RAG embeddings (`@cf/baai/bge-base-en-v1.5`) behind document upload and retrieval.
486
+ - **You (the host)** pay for the Workers AI paths that call the worker's `AI` binding directly because AI Gateway cannot proxy them, which means the user's account cannot be reached either: the six stream-incompatible image models (FLUX.2 Klein 9B / Klein 4B / Dev, Leonardo Phoenix 1.0, Dreamshaper 8 LCM, SDXL), Deepgram file STT, and the live-voice Flux socket. Bound this with Workers AI limits on your account or remove those models from `src/models.ts` on your instance.
487
+ - **Control-plane users** (`pcp_` key) bill chat through prism-control-plane under its own metering, not through either account above. That plane stores no chat text. Media it generates, and reference images uploaded to it, are kept 30 days and then deleted ([its retention section](https://github.com/skyphusion-labs/prism-control-plane/blob/main/docs/CONTRACT.md)).
488
+
489
+ **How it works.** In `AUTH_MODE=public`, the host funds a named set of demo capabilities on purpose. Every other inference call bills the user's own Cloudflare account.
490
+
491
+ The 412 gate (`gateway_account_id_required`) decides who may run inference. It does not decide which account pays. The `AI` binding always runs on the worker's own account, and Cloudflare does not let a binding reach another account. The gateway-bypass paths use the binding, so they bill the host. The `aiRun` paths use the REST API with the user's token, so they bill the user.
492
+
493
+ This table was read from the code on `main` (v1.1.1). It shows what the code does, not what a deployed worker runs.
494
+
495
+ | Capability | Code path | Billed to |
496
+ |---|---|---|
497
+ | FLUX.2 Klein 9B, Klein 4B, Dev; Leonardo Phoenix 1.0; Dreamshaper 8 LCM; SDXL | `bypassGateway` in `src/routes/chat.ts` calls `env.AI.run` | **Host** |
498
+ | Deepgram Nova-3 file speech-to-text | `viaDeepgram` in `src/routes/chat.ts` calls `env.AI.run` | **Host** |
499
+ | Live voice (Deepgram Flux websocket) | `src/stt-session.ts` calls `env.AI.run` | **Host** |
500
+ | Workers AI chat, TTS, Whisper, FLUX.1 schnell, Lucid Origin | `aiRun`, which uses the REST API on the user's account | User |
501
+ | RAG embeddings (`@cf/baai/bge-base-en-v1.5`) | `aiRun` in `src/routes/rag.ts` | User |
502
+ | Partner models through `aiRun` (OpenAI, Anthropic, xAI, Google, video, music) | `aiRun`, including the long-run Workflow | User |
503
+ | Anthropic and xAI legacy provider-native path | `gatewayProviderUrl` builds the URL from the user's account ID | User |
504
+ | Control-plane chat (`pcp_` key) | prism-control-plane | Its own metering |
505
+
506
+ The Anthropic, xAI and `aiRun` partner-model rows were Unverified in PR #195. Reading `resolveGateway` closes them. In public mode it returns credentials only with an account ID, so those calls always carry the user's account.
507
+
508
+ **Review trigger.** If daily Workers AI neurons pass 5,000, a cap proposal gets written. Nothing enforces this number. It starts a decision and does not limit use. The free allocation is 10,000 neurons per day. Measured use was 8,635 neurons in the 30 days to 2026-10-08, so the cost today is zero. That window ran almost entirely before v1.1.0, when chat and embeddings also ran on the binding. v1.1.0 is deployed on play (`/health` reported `1.1.0` on 2026-10-08), so the host-funded set is now the three rows above. The 8,635 figure predates it and has not been re-measured against the new shape. `main` may be ahead of the deployed version.
481
509
 
482
510
  ### Abuse controls and policies
483
511
 
@@ -510,7 +538,7 @@ For D1 **schema** changes, see [Migrating an existing deployment](#migrating-an-
510
538
  |
511
539
  +---+---+
512
540
  | |
513
- SearXNG Wikipedia (web search)
541
+ SEARCH Wikipedia (web search)
514
542
  ```
515
543
 
516
544
  The worker is the only public surface. R2 is private; the worker streams objects through `GET /api/artifact/*` after verifying ownership via `customMetadata.user_email` on the R2 object.
@@ -592,7 +620,7 @@ Workers AI billing is per-token / per-image / per-minute depending on model. Fre
592
620
 
593
621
  D1 is roughly $0.75/GB-month for storage. R2 is roughly $0.015/GB-month with no egress fees inside Cloudflare. Free tiers on D1 and R2 cover small personal use indefinitely.
594
622
 
595
- Anthropic (Claude), xAI (Grok), OpenAI chat, Google Gemini, and proxied image / video / music models bill against your Cloudflare account via Unified Billing. Self-hosted SearXNG web search has no per-search API cost (you run the instance); Wikipedia is free. See per-provider sections below.
623
+ Anthropic (Claude), xAI (Grok), OpenAI chat, Google Gemini, and proxied image / video / music models bill against your Cloudflare account via Unified Billing. Web search through the `SEARCH` service binding stays on your Cloudflare account (no third-party search API). Wikipedia is free. See per-provider sections below.
596
624
 
597
625
  ## Anthropic models (Unified Billing)
598
626
 
@@ -785,7 +813,7 @@ This is a Cloudflare-proxied (third-party) model, so it requires Unified Billing
785
813
 
786
814
  ## Image generation
787
815
 
788
- **21** image models in `src/models.ts` (or `GET /api/models?type=image`): Google Nano Banana Pro / 2 / Lite, Imagen 4, GPT Image 1.5 / 2, Recraft V4 / V4.1 / V4.1 Pro, xAI Grok Imagine Image (+ Quality), ByteDance Seedream 5 Pro / Lite, FLUX 2 Klein 9B/4B, FLUX 2 Dev, FLUX-1 schnell, Lucid Origin, Phoenix 1.0, Dreamshaper 8 LCM, Stable Diffusion XL. The eight FLUX/Leonardo/Lykon/Stability models run through Workers AI (no Unified Billing required); the rest are proxied partner models on Unified Billing (need CF credits). GPT Image 1.5 / 2 are opaque on the proxy by default; **optional deployer BYOK (v0.174.0):** set `OPENAI_API_KEY` for transparent PNG via `api.openai.com` (leave unset on public multi-tenant play).
816
+ **21** image models in `src/models.ts` (or `GET /api/models?type=image`): Google Nano Banana Pro / 2 / Lite, Imagen 4, GPT Image 1.5 / 2, Recraft V4 / V4.1 / V4.1 Pro, xAI Grok Imagine Image (+ Quality), ByteDance Seedream 5 Pro / Lite, FLUX 2 Klein 9B/4B, FLUX 2 Dev, FLUX-1 schnell, Lucid Origin, Phoenix 1.0, Dreamshaper 8 LCM, Stable Diffusion XL. The eight FLUX/Leonardo/Lykon/Stability models run through Workers AI (no Unified Billing required); the rest are proxied partner models on Unified Billing (need CF credits). GPT Image 1.5 / 2 are opaque on the proxy by default; **optional deployer BYOK (v0.174.0):** set `OPENAI_API_KEY` for transparent PNG via `api.openai.com` (ignored in public mode, v1.0.5).
789
817
 
790
818
  ### Google Nano Banana Pro (Unified Billing, v0.21.2)
791
819
 
@@ -802,7 +830,7 @@ This is a Cloudflare-proxied (third-party) model, so it requires Unified Billing
802
830
 
803
831
  - **Recraft V4** (`recraft/recraftv4`, Unified Billing) is opaque and art-directed (strong composition and text rendering). The CF proxy exposes no alpha control, only an opaque `background_color`. It returns WebP; the worker stores it with the response content-type, so no format is hardcoded.
804
832
 
805
- - **GPT Image 1.5 / 2** (`openai/gpt-image-1.5`, `openai/gpt-image-2`) are opaque through the Unified Billing proxy by default (`{ prompt, quality, size }`; proxy 7003-rejects `background`/`output_format`). **Optional BYOK (v0.174.0):** when `OPENAI_API_KEY` is set, `runImage` calls `api.openai.com` via `src/providers/openai-image.ts` for transparent PNG. Leave the secret unset on public play.
833
+ - **GPT Image 1.5 / 2** (`openai/gpt-image-1.5`, `openai/gpt-image-2`) are opaque through the Unified Billing proxy by default (`{ prompt, quality, size }`; proxy 7003-rejects `background`/`output_format`). **Optional BYOK (v0.174.0):** when `OPENAI_API_KEY` is set, `runImage` calls `api.openai.com` via `src/providers/openai-image.ts` for transparent PNG. Public mode ignores the secret (v1.0.5, prism#193).
806
834
  - **xAI Grok Imagine** (`xai/grok-imagine-image`, `-quality`): request `response_format: "b64_json"` on Unified Billing (CF-managed ZDR credentials reject URL format). `extractProxiedImageAsset` accepts URL or inline base64.
807
835
  - **Recraft** (`recraft/recraftv4*`): bare `{ prompt }` only (v0.174.1/v0.174.2); legacy `style` enums and Pro `1024x1024` size are rejected upstream.
808
836
 
@@ -838,6 +866,8 @@ The retrieved chunks appear above the model's response with filename, chunk inde
838
866
  ```
839
867
  # Create the Vectorize index (768 dimensions for BGE-base, cosine similarity)
840
868
  npx wrangler vectorize create skyphusion-llm-vec --dimensions=768 --metric=cosine
869
+ # ...and its user_email metadata index, before any document is uploaded
870
+ npx wrangler vectorize create-metadata-index skyphusion-llm-vec --property-name=user_email --type=string
841
871
 
842
872
  # Apply the full schema to a FRESH database. schema.sql is the canonical
843
873
  # full schema for new deployments. Do NOT re-run it against a database that
@@ -907,48 +937,45 @@ DiscordChatExporter.Cli export -t <TOKEN> -c <CHANNEL_ID> -f Json \
907
937
 
908
938
  ## Web search
909
939
 
910
- An opt-in retrieval source (v0.17.0) that queries the web at request time and folds the snippets into the system prompt. Runs in parallel with RAG, so a single turn can pull from both your uploaded docs and the web. Designed for creative work, worldbuilding, and "what's current" questions where you want your model to do the synthesis rather than a search engine's pre-summary.
940
+ An opt-in retrieval source (v0.17.0) that retrieves at request time and folds the snippets into the system prompt. Runs in parallel with RAG, so a single turn can pull from your uploaded docs, the skyphusion-search corpus, and Wikipedia. The corpus half is Skyphusion public repos, not the open web. Wikipedia is the reference half.
911
941
 
912
942
  ### How it works
913
943
 
914
944
  When you check the "search the web" toggle next to the run button (chat models only), the worker fires two parallel queries on each turn:
915
945
 
916
- 1. **SearXNG** for general web results (v0.166.0). A self-hosted metasearch instance queried via its JSON API (`GET {SEARXNG_URL}/search?q=...&format=json`). Requires `SEARXNG_URL`; without it, this source is silently skipped. When the instance is gated by Cloudflare Access, the worker authenticates with a service token (`SEARXNG_ACCESS_CLIENT_ID` / `SEARXNG_ACCESS_CLIENT_SECRET`).
917
- 2. **Wikipedia** for reference and lore. No API key needed. Returns titles + HTML-stripped snippets via the public MediaWiki search endpoint.
946
+ 1. **skyphusion-search** for corpus hits. A service binding (`SEARCH`, entrypoint `SearchEntrypoint`) calls `search(question)` on the `skyphusion-search` Worker and reads `{ chunks }`. With the binding absent, the chat response reports `sources.web.status` `absent`. A thrown call reports `failed`. When the RPC throws `empty_question`, `question_too_long`, `rate_limited`, or `search_unavailable`, the error string is that code. An empty `chunks` array reports `ok` and count 0. Those three are different.
947
+ 2. **Wikipedia** for reference and lore. No API key needed. Returns titles + HTML-stripped snippets via the public MediaWiki search endpoint. Unchanged: it still answers when the web source fails or is absent.
918
948
 
919
- Both have an 8-second per-source timeout. If one fails or times out, the other still returns its hits. Results are persisted in the same `retrieved_context` column alongside any RAG chunks from the same turn, with a `source_type` discriminator so the UI can render web results (title + clickable URL + snippet) distinctly from doc chunks.
949
+ Both have an 8-second per-source timeout. If one fails or times out, the other still returns its hits. The chat JSON (and the stream `done` event) includes `sources.web` and `sources.wikipedia`, each `{ status, count, error? }`. `web_search_error` is set only when the web source failed. Results are persisted in the same `retrieved_context` column alongside any RAG chunks from the same turn, with a `source_type` discriminator so the UI can render web results (title + clickable URL + snippet) distinctly from doc chunks.
920
950
 
921
951
  Per-turn opt-in: the toggle is not sticky across turns. Each turn decides independently whether to search. Web search and RAG can be on simultaneously; the model sees both in the system prompt.
922
952
 
923
953
  ### Setup
924
954
 
925
- Run a SearXNG instance with the JSON output format enabled, then point the worker at it (Wikipedia needs no config):
926
-
927
- ```
928
- npx wrangler secret put SEARXNG_URL
929
- ```
930
-
931
- If the instance is behind Cloudflare Access (recommended for a private deployment), also set the service-token halves so the worker can authenticate:
955
+ Add the service binding to your `wrangler.toml` (already in `wrangler.example.toml`) and redeploy. Wikipedia needs no config.
932
956
 
933
- ```
934
- npx wrangler secret put SEARXNG_ACCESS_CLIENT_ID
935
- npx wrangler secret put SEARXNG_ACCESS_CLIENT_SECRET
957
+ ```toml
958
+ [[services]]
959
+ binding = "SEARCH"
960
+ service = "skyphusion-search"
961
+ entrypoint = "SearchEntrypoint"
936
962
  ```
937
963
 
938
- The worker sends them as `CF-Access-Client-Id` / `CF-Access-Client-Secret` only when both are set; leave them unset for an un-gated instance. Redeploy after setting secrets.
964
+ The binding calls the named entrypoint, not `POST /ask`. There is no Origin header and no Turnstile token. The search worker's script must export `SearchEntrypoint` (search-mcp). Delete the `[[services]]` block if that worker is not on your account.
939
965
 
940
966
  ### Caveats worth knowing
941
967
 
942
- - **Token budget.** Each turn with web search on adds roughly 2000-4000 tokens to the system prompt (up to 5 SearXNG snippets and 3 Wikipedia snippets). Long campaigns or document-heavy RAG turns may push against your model's context window.
943
- - **Self-hosting cost.** SearXNG is free and open-source; the only cost is running the instance. Search-every-turn would still burn context tokens, so the per-turn toggle is intentional.
968
+ - **Token budget.** Each turn with web search on adds roughly 2000-4000 tokens to the system prompt (up to 5 corpus snippets and 3 Wikipedia snippets). Long campaigns or document-heavy RAG turns may push against your model's context window.
969
+ - **Same-account call.** The binding does not leave your Cloudflare account and does not use a third-party search API. Search-every-turn would still burn context tokens, so the per-turn toggle is intentional.
970
+ - **The search worker can still refuse the call.** `search` throws `empty_question`, `question_too_long`, `rate_limited`, or `search_unavailable`. A refusal comes back as `sources.web.status` `failed` with that error code, and Wikipedia hits stay. An empty `chunks` array is `ok` with count 0.
944
971
  - **No fact-checking.** Web snippets are supplementary context, not authoritative. The system prompt tells the model so. Verify anything that matters before quoting it.
945
972
  - **Wikipedia User-Agent.** The worker identifies itself per Wikimedia's policy. If you fork to a different repo name, update the UA string in `searchWikipedia` so you're not lumped in with anonymous scrapers.
946
973
 
947
974
  ### When it shines
948
975
 
949
976
  - **Worldbuilding lore**: "Norse trickster mythology," "Edo period yokai," "Welsh place name etymology." Wikipedia alone covers most of this.
950
- - **Current events**: who holds an office, what just happened in the news.
951
- - **Mixed RAG + web**: your campaign uses a setting bible (uploaded as a doc) plus real-world historical detail. Toggle both; the model sees both context blocks.
977
+ - **This org's own docs**: how a Skyphusion repo is put together. That is what the corpus index holds. It is not a news search.
978
+ - **Mixed RAG + web**: your campaign uses a setting bible (uploaded as a doc) plus Wikipedia. Toggle both; the model sees both context blocks.
952
979
  - **Niche reference**: "17th-century apothecary daily routine," "Victorian funeral customs," anything where you want flavor without writing it yourself.
953
980
 
954
981
  ### When to leave it off
@@ -1041,9 +1068,9 @@ See [SECURITY.md](SECURITY.md) for vulnerability reporting.
1041
1068
 
1042
1069
  ## Acknowledgements
1043
1070
 
1044
- Built and maintained by [SkyPhusion](https://x.com/SkyPhusion).
1071
+ Built and maintained by [SkyPhusion](https://x.com/rockrockenhaus).
1045
1072
 
1046
- Built on Cloudflare Workers, Workers AI, AI Gateway, D1, R2, Vectorize, Workflows, and Cloudflare Access. Image generation models courtesy of Black Forest Labs and Leonardo.Ai. Text-to-speech via Deepgram. Speech-to-text via OpenAI Whisper. Web search via self-hosted SearXNG and Wikipedia.
1073
+ Built on Cloudflare Workers, Workers AI, AI Gateway, D1, R2, Vectorize, Workflows, and Cloudflare Access. Image generation models courtesy of Black Forest Labs and Leonardo.Ai. Text-to-speech via Deepgram. Speech-to-text via OpenAI Whisper. Web search via the skyphusion-search Worker and Wikipedia.
1047
1074
 
1048
1075
  ## Hosted instance policies (play.skyphusion.org)
1049
1076
 
@@ -27,8 +27,11 @@ The hosted instance is offered freely so people can try the Cloudflare AI stack.
27
27
 
28
28
  ## You pay for your own model inference
29
29
 
30
- The hosted instance does not pay for the models you run. You configure your own Cloudflare AI Gateway,
31
- and model inference is billed to **your** Cloudflare Unified Billing account. That means:
30
+ The hosted instance does not pay for the models you run, with one narrow exception below. You configure
31
+ your own Cloudflare account ID, AI Gateway, and API token, and model inference is billed to **your**
32
+ Cloudflare account. The exception: live voice chat, Deepgram file transcription, and six image models
33
+ cannot be routed through an AI Gateway, so they run on our Cloudflare account (the privacy notice lists
34
+ them). Using those does not bill you. Otherwise:
32
35
 
33
36
  - **Your gateway spend is yours.** You are solely responsible for the cost of the model calls you make
34
37
  and for keeping your own AI Gateway credentials and billing in order. Skyphusion Labs does not