Configure API Keys for Cloudflare Workers AI

Cloudflare Workers AI

In this example, we are using Cloudflare Workers AI to generate the keys.

:information_source: Cloudflare Workers AI is used as an embeddings provider in Discourse AI (e.g., for semantic search and RAG). It is not used as an LLM provider.

Note: Workers AI is available on both Free and Paid Cloudflare plans. Usage-based pricing may apply. See here for up-to-date details.

Platforms will always change so this guide may not reflect 100% process.

Generate the API key

  1. Log in to Cloudflare. Follow the instructions in their documentation to get an API key and the Account ID
  2. Generate the API Key and note the Account ID
  3. Once the key is generated, store it in a safe and secure place and copy it

Using API key for Discourse AI

Cloudflare Workers AI credentials are now configured through the AI Secrets and AI Embeddings admin pages, not through plugin site settings.

  1. Go to Admin → Plugins → Discourse AI → AI Secrets (/admin/plugins/discourse-ai/ai-secrets)
  2. Create a new secret with your Cloudflare API token
  3. Go to Admin → Plugins → Discourse AI → AI Embeddings (/admin/plugins/discourse-ai/ai-embeddings)
  4. Create or edit an embedding definition, selecting Cloudflare as the provider
  5. Set the URL to your Cloudflare Workers AI endpoint, which includes your Account ID, e.g.:
    https://api.cloudflare.com/client/v4/accounts/YOUR_ACCOUNT_ID/ai/run/@cf/baai/bge-large-en-v1.5
  6. Select the AI Secret you created in step 2

:information_source: The old site settings ai_cloudflare_workers_api_token and ai_cloudflare_workers_account_id are now hidden and deprecated. Existing configurations were automatically migrated to the new Embedding Definitions and AI Secrets system.

Last edited by @hugh 2024-05-29T06:10:50Z

Check documentPerform check on document:
6 Likes