# Cloudflare Workers AI (https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints/cloudflare)

Cloudflare Workers AI runs open models on Cloudflare's network, and its AI Gateway exposes an OpenAI-compatible endpoint scoped to your account and gateway.

## Get an API key

Create an AI Gateway by following the [AI Gateway setup guide](https://developers.cloudflare.com/ai-gateway/get-started/), then add your credentials to your `.env` file:

```bash filename=".env"
CF_API_TOKEN=your-api-key
CF_ACCOUNT_ID=your-account-id
CF_GATEWAY_ID=your-gateway-id
```

## Configuration

Add the endpoint under `endpoints.custom` in your `librechat.yaml`. The `baseURL` embeds your account ID and gateway ID:

```yaml filename="librechat.yaml"
    - name: "Cloudflare Workers AI"
      apiKey: "${CF_API_TOKEN}"
      baseURL: "https://gateway.ai.cloudflare.com/v1/${CF_ACCOUNT_ID}/${CF_GATEWAY_ID}/workers-ai/v1"
      models:
        default: [
          "@cf/google/gemma-3-12b-it",
          "@cf/meta/llama-4-scout-17b-16e-instruct",
          "@cf/qwen/qwq-32b",
          "@cf/qwen/qwen2.5-coder-32b-instruct",
          "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b",
          "@cf/openai/gpt-oss-120b"
        ]
        fetch: false
      titleConvo: true
      titleModel: "@cf/google/gemma-3-12b-it"
      modelDisplayLabel: "Cloudflare AI"
```

## Notes

- This uses the [OpenAI-compatible endpoint](https://developers.cloudflare.com/ai-gateway/providers/workersai/#openai-compatible-endpoints) of Workers AI. Browse available models in the [Workers AI model catalog](https://developers.cloudflare.com/workers-ai/models/).
- `@cf/openai/gpt-oss-*` models may not work due to spec incompatibility.
- The `CF_API_TOKEN`, `CF_ACCOUNT_ID`, and `CF_GATEWAY_ID` variable names can be renamed as long as they match between your `.env` and `librechat.yaml`.
