Admin reference — owner only

Env Setup

The complete, updated cloudflare-env-import.env file — every variable, every key, ready to import into Cloudflare Pages. Follow the steps below exactly; the whole site, the API, the Telegram bot and the GET endpoints are configured from this single file.

🔒 Security warning

This page ships with placeholders only — real API keys are never published here. An earlier version did embed live keys, and GitHub push protection blocked the push: anyone could read them in the page source. Use the generator below — the keys you type stay in your browser only, are sent nowhere, and produce the real import file. Never commit real keys to the repo.

1. Import into Cloudflare Pages (exact clicks)

  1. Open dash.cloudflare.com → Workers & Pages → aigateway.
  2. Go to Settings → Variables and Secrets.
  3. Click + Import .env → select the downloaded cloudflare-env-import.env file (or copy-paste the whole block below into the first variable's edit box using Import .env — it parses KEY=value lines). Confirm.
  4. Switch to the Preview environment tab on the same page and repeat the import there too.
  5. Redeploy: Deployments → latest deployment → ⋯ → Retry deployment (or push any commit). Variables only take effect after a deploy.

2. The complete file (v1.4.0)

The template below lists every variable with safe placeholders. Use the generator right under it to stamp in your real keys and download the ready-to-import file.

cloudflare-env-import.env
…
🔑 Generate your real file — 100% in your browser

Type your two provider keys and press the button: the page builds your complete real cloudflare-env-import.env and downloads it — ready for the Cloudflare import in step 1. The keys never leave this page: no server, no storage, no log receives them.

3. What each variable does (and where it's used)

VariableExample / valueUsed by
APP_NAME / APP_VERSIONAI Gateway API / 1.4.0Navbar chip, footer, /api/v1/config, health — one change rebrands everything.
OPENROUTER_API_KEYsk-or-v1-…OpenRouter chat + model catalog (server-side only).
POOLSIDE_API_KEYsky_…Poolside Laguna models chat + catalog.
OPENCODEZEN_API_KEYoptionalEnables OpenCode Zen CHAT (its model list is public without a key).
CUSTOM_BASE_URL/KEY/MODELoptionalThe zero-code custom provider (any OpenAI-compatible endpoint).
DEFAULT_PROVIDERopenrouterWhich provider answers when the request doesn't name one; failover starts here.
FAILOVER_*true / 3 / 800 / 6 / 12Deep failover: switch, max chain rounds, round pause, max models tried per provider, hard cap on total attempts. Every model of a provider is tried before moving to the next provider.
TELEGRAM_BOT_TOKEN7216…:AAH8…The Telegram bot webhook (/telegram guide). Empty = bot disabled.
TELEGRAM_WEBHOOK_SECRETany random stringSecret path segment for /api/telegram/<secret> — other paths get 403.
API_SECRET_KEYoptionalProtects POST /api/v1/chat with X-API-Key. GET chat & /ask stay open.
ALLOWED_ORIGINS*CORS allow-list (who may call your API from browsers).
RATE_LIMIT_* / CHAT_RATE_LIMIT_*100 / 30Per-IP request caps for the whole API and for chat specifically.
MODELS_CACHE_TTL_MS21600000How long the auto-fetched model catalog is cached (6 h).
APP_URL / API_BASE_URLpages.dev URL / emptyAttribution header + optional base-URL override (leave empty = auto-detect).

4. After importing — verify in 60 seconds

  1. Open /api/v1/config → should show version: 1.4.0 and your base URL.
  2. Click /ask?prompt=Say GATEWAY-OK → JSON answer straight in the browser.
  3. Open /status/ → provider tiles should be live.
  4. If you set the Telegram vars, run the setWebhook command from the Telegram page and message your bot.
Common issues
  • UPSTREAM_AUTH_ERROR → the provider key is wrong/expired: update it here and redeploy.
  • Variables changed but nothing happened → you forgot the redeploy (step 1e).
  • Import button missing → use the classic "Add variables" flow and paste each KEY=value, or update Cloudflare dashboard language/permissions — the Import .env button exists on all current Pages projects.
  • "Variables are managed through wrangler.toml" → a wrangler.toml was added back to the repo. Delete it, commit, redeploy — dashboard variables become editable again. This project ships WITHOUT that file on purpose.