Workers AI 與 AI Gateway:在 Cloudflare 上使用 AI,避免 API 金鑰散落各處
Workers AI and AI Gateway: using AI on Cloudflare without scattering API keys
Workers AI 和 AI Gateway 可讓用戶在 Cloudflare 上使用 AI,避免多個小型專案的 API 金鑰散落各處。Workers AI 透過 Worker binding 執行模型,程式碼無需外部金鑰。AI Gateway 則置於外部服務供應商之前,集中存放供應商金鑰,並提供快取、速率限制和記錄。
If you run several small projects, API keys tend to pile up: one per provider, copied into env files, CI secrets and old branches. Every copy is one more place a key can leak.
One way out is to keep inference inside Cloudflare. Workers AI runs models from a Worker binding, so there's no external key in the code at all, and AI Gateway sits in front of external providers so the provider key lives in one place, with caching, rate limits and logs on top.
I wrote up how I set this up across my projects, with the trade-offs I hit along the way (in Portuguese):
https://kevinbk.com/blog/evitar-acumulo-de-chaves-api-em-projetos-ia
來源:DEV Community · dev.to