> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opal.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Cloudflare AI Gateway

> Set up Cloudflare AI Gateway so Paladin and Opal's other AI features can send their Claude calls through it.

> [!NOTE]
>
> AI gateways are currently in beta. Contact Opal support to enable them for your organization. If you self-host Opal, you need version `1.1252.0` or later.

## Overview

[Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/) works as an AI gateway for Opal through its Anthropic endpoint. Opal sends the same model names it would send to Anthropic, and Cloudflare's logging, policies, and spend controls apply to every call.

## Prerequisites

* A Cloudflare account with an AI gateway. Cloudflare creates a gateway named `default` on its first request if you don't have one.
* A Cloudflare API token with the **AI Gateway: Run** permission, if your gateway requires authentication.
* An Anthropic API key.

## Connect it in Opal

Follow [Connect your gateway](https://docs.opal.dev/docs/paladin/ai-gateway.md#connect-your-gateway) with:

| Field | Value |
| - | - |
| **Gateway URL** | `https://gateway.ai.cloudflare.com/v1/<account ID>/<gateway ID>/anthropic` |
| **Gateway key** | Your Anthropic API key |
| **Headers** | Name `cf-aig-authorization`, value `Bearer <your Cloudflare API token>` |

Your account ID and gateway ID are in the Cloudflare dashboard, on the AI Gateway page. With authentication on, Cloudflare rejects calls that don't carry the `cf-aig-authorization` header, and Opal's connection check reports "The gateway rejected the key".

Cloudflare's gateway log then shows each request Opal makes, with the model, status, tokens, and duration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.