# Configure API Keys for Cloudflare Workers AI

**URL:** https://meta.discourse.org/t/configure-api-keys-for-cloudflare-workers-ai/283321
**Category:** Integrations
**Tags:** how-to, ai
**Created:** [October 24, 2023, 8:40pm UTC](https://meta.discourse.org/t/configure-api-keys-for-cloudflare-workers-ai/283321 "2023-10-24T20:40:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [October 24, 2023, 8:40pm UTC](https://meta.discourse.org/t/configure-api-keys-for-cloudflare-workers-ai/283321/1 "2023-10-24T20:40:03Z")

</div>

### Cloudflare Workers AI

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

> ℹ 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](https://developers.cloudflare.com/workers-ai/).

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](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) 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

> ℹ 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 document**
> >
> > Perform check on document:
