Skip to content

Worker settings

Set local values in worker/.dev.vars (copy from .dev.vars.example); production values live in wrangler.toml [vars] or as encrypted secrets.

VariableRequiredDefaultDescription
ANTHROPIC_API_KEYYesAnthropic API key. Always set as a secret: npx wrangler secret put ANTHROPIC_API_KEY
ALLOWED_ORIGINYeshttp://localhost:5173Origin(s) allowed by CORS. Accepts a comma-separated list, e.g. https://a.example,https://b.example. Any http://localhost:* origin is always allowed for development
CLAUDE_MODELNoclaude-haiku-4-5-20251001Claude model used for replies
MAX_TOKENSNo1024Max response tokens
RATE_LIMIT_MINUTENo10Requests per minute per IP
RATE_LIMIT_HOURNo50Requests per hour per IP
ATTACHMENTS_ENABLEDNotrueAccept image/PDF attachments on user messages
ATTACHMENT_TYPESNoJPEG, PNG, GIF, WebP, PDFComma-separated MIME allowlist
ATTACHMENT_MAX_BYTESNo5242880Per-file size cap (5 MB)
ATTACHMENT_MAX_COUNTNo5Files per message
ATTACHMENT_MAX_REQUEST_BYTESNo20971520Attachment bytes forwarded to Claude per request (20 MB)
ATTACHMENT_QUOTA_IP_BYTESNo52428800Upload bytes per IP per UTC day (50 MB); 0 disables
ATTACHMENT_QUOTA_TENANT_BYTESNo524288000Upload bytes per tenant per UTC day (500 MB); 0 disables
TENANT_IDNoOrigin hostQuota tenant identifier
ATTACHMENT_STORAGENopassthroughpassthrough (forward and discard) or r2 (store with retention)
ATTACHMENT_RETENTION_HOURSNo24R2 mode: lifetime of stored files and signed URLs
ATTACHMENT_SIGNING_SECRETR2 onlySecret for signing download URLs. Set as a secret

See Attachments for how these fit together, the storage backends, and the privacy posture.

BindingRequiredPurpose
RATE_LIMIT (KV)YesPer-IP rate-limit counters and daily attachment quotas. Create with npx wrangler kv namespace create RATE_LIMIT
ANALYTICS_DB (D1)NoMetadata-only analytics events. When absent, the chat endpoint works normally and skips recording
ATTACHMENTS (R2)R2 onlyStores uploaded files when ATTACHMENT_STORAGE=r2. Create with npx wrangler r2 bucket create claudius-attachments

See Deploy the worker for the exact wrangler commands.

The bot’s personality, knowledge, and guardrails live in worker/src/system-prompt.ts. The repo ships a generic template; edit it to describe your business, services, pricing, and FAQ. The prompt also includes behavioral rules (response length, formatting, prompt-injection protection, when to recommend a contact form).

Redeploy the worker after editing:

Terminal window
cd worker
npx wrangler deploy

The worker validates every request before calling Claude:

  • messages is required and non-empty
  • At most 100 messages per request
  • Each message’s content is truncated to 2,000 characters
  • Roles must be user or assistant
  • A message must have text, attachments, or both
  • Attachments: allowlisted type matching the file’s bytes, at most ATTACHMENT_MAX_COUNT per user message, each under ATTACHMENT_MAX_BYTES

Violations return 400 with code VALIDATION_ERROR (or an ATTACHMENT_* code) — see the REST API reference.