cloudflare_ai_gateway
A Drupal client for the Cloudflare AI Gateway: it stores each gateway as configuration, builds the gateway's request URLs and cf-aig-* control headers, and exposes its live model catalogue.
A Cloudflare AI Gateway is a hosted service that sits in front of AI providers and adds caching, logging, cost analytics and fallbacks. This module is the layer that lets Drupal talk to one. Most sites install it as a dependency of the Cloudflare AI Gateway Provider, which connects it to the Drupal AI module; developers can also use its client service directly.
Features
- A gateway configuration entity, so you can define one or more gateways (host, slug, default provider, and the credential set that authorizes them).
- URL building for the gateway's endpoint styles (the OpenAI-compatible endpoint, the universal endpoint, and per-provider passthrough).
- The cf-aig-* request headers for cache TTL, metadata and fallbacks, built from an immutable options object.
- Access to the gateway's live model catalogue, the union of models across every provider it fronts, cached per gateway.
- Credentials (account ID and token) are resolved from settings.php through the Cloudflare SDK, never stored in configuration.
Use it as the foundation for the AI provider, or directly from your own code when you need to send requests through a Cloudflare AI Gateway.
Post-Installation
This module has no user-facing AI features on its own. It provides the gateway client and configuration that other modules (or your own code) build on. After enabling it:
- Add a credential set in the Cloudflare SDK module, and put its account ID and token in settings.php.
- Add a gateway at Configuration > Web services > Cloudflare AI Gateways. Set the host (the global endpoint is the default), the gateway slug from your Cloudflare dashboard, the default upstream provider, and the credential set that supplies its authorization token.
To route the Drupal AI module through the gateway, also install the Cloudflare AI Gateway Provider.
Additional Requirements
This module requires the Cloudflare SDK module, which provides the credential framework and the shared HTTP client. Installing with Composer pulls it in:
composer require drupal/cloudflare_ai_gatewayWhile the suite is in alpha, require it as drupal/cloudflare_ai_gateway:^1.0@alpha (or set your project's minimum-stability to alpha) so the pre-stable releases resolve. You also need a Cloudflare account with an AI Gateway configured.
Recommended modules/libraries
Install the Cloudflare AI Gateway Provider to use a configured gateway with the AI module, so every AI feature in your site routes through it.
Similar projects
The existing Cloudflare module focuses on CDN and cache management and does not cover the AI Gateway. This module is part of a small Cloudflare suite built on the Cloudflare SDK, alongside the AI Gateway Provider.
Supporting this Module
Issue reports, patches and feedback are welcome in the project's issue queue.
Community Documentation
Cloudflare's AI Gateway documentation is at developers.cloudflare.com/ai-gateway.