Worker code is in cloudflare-worker/ and runs on Cloudflare Workers.
- Cloudflare account
- Node.js 20+
- Wrangler CLI (via
npx wrangler) - OpenAI API key
cd cloudflare-worker
npm install
cp .env.example .env
cp wrangler.toml.example wrangler.tomlnpx wrangler kv namespace create DEVICE_STATECopy the returned namespace ID into wrangler.toml (local file, ignored by git).
npx wrangler secret put OPENAI_API_KEY
npx wrangler secret put DEVICE_SHARED_SECRETOptional stronger model:
- Store per-device secrets in KV (
device:<deviceId>)
Key vars include:
CHAT_MODELTRANSCRIBE_MODELTTS_MODELTTS_VOICERATE_LIMIT_PER_MINMAX_TEXT_CHARSMAX_REPLY_CHARSREPLY_MAX_TOKENS
At minimum, ensure your key has access to:
- Responses API (
/v1/responses) - Audio transcription (
/v1/audio/transcriptions) - Audio speech (
/v1/audio/speech)
Recommended:
- Restrict key to only required model capabilities for this project
- Set project budget and usage alerts
- Keep key server-side only (Worker secrets), never in firmware
npm run deploynpx wrangler deployments list- Signed request auth and nonce replay protection are enforced by worker
- Per-device minute rate limits backed by KV
- Keep
MAX_*limits conservative on tiny-device workflows - Never commit
.env,wrangler.toml, or firmware secrets
POST /v1/voice-turnPOST /v1/voice-turn-text(text-only fallback path)POST /v1/ttsPOST /v1/picture
All protected routes require signed auth headers.
For full variable/secret definitions, see Configuration Reference.