Prompt Chain

Secure API Gateway Access

Gateway is a prompt workflow example demonstrating Cloudflare provider integration for promptfoo, enabling users to test and evaluate AI prompts through

Works with cloudflare

81
Spark score
out of 100
Updated 3 months ago
Version 1.0.0
Models

Add to Favorites

Why it matters

This prompt chain integrates with Cloudflare Gateway to manage and audit API access, ensuring secure and controlled interactions with your services.

Outcomes

What it gets done

01

Configure API access policies

02

Audit and log access attempts

03

Manage API secrets and credentials

04

Deploy access control configurations

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-gateway | bash

Capabilities

What this chain does

Audit access

Reviews permissions and logs to flag unauthorized activity.

Manage secrets

Stores, rotates, and injects API keys and credentials.

Deploy / CI

Runs build pipelines, tests, and deploys to environments.

Overview

Gateway

What it does

Gateway is a runnable example prompt workflow that demonstrates how to use the Cloudflare provider within promptfoo. It serves as a reference implementation showing the configuration and execution pattern for testing prompts through Cloudflare's infrastructure.

How it connects

Use Gateway when you need a working example to understand how to integrate Cloudflare as a provider in promptfoo, or when you want a template to start building your own Cloudflare-based prompt evaluation workflows.

Source README

provider-cloudflare/gateway (Cloudflare AI Gateway)

You can run this example with:

npx promptfoo@latest init --example provider-cloudflare/gateway
cd provider-cloudflare/gateway

This example demonstrates how to route AI requests through Cloudflare AI Gateway for caching, rate limiting, and analytics.

Prerequisites

  1. A Cloudflare account with AI Gateway enabled
  2. An AI Gateway created in your Cloudflare dashboard
  3. API keys for the providers you want to use (OpenAI, Anthropic, Groq, etc.)

Setup

Set the required environment variables:

export CLOUDFLARE_ACCOUNT_ID=your_account_id
export CLOUDFLARE_GATEWAY_ID=your_gateway_id
export OPENAI_API_KEY=your_openai_key
export ANTHROPIC_API_KEY=your_anthropic_key
export GROQ_API_KEY=your_groq_key

Running the Example

npx promptfoo eval -c examples/provider-cloudflare/gateway/promptfooconfig.yaml

What This Example Does

The configuration compares responses from three different providers, all routed through Cloudflare AI Gateway:

  • OpenAI (gpt-4o-mini)
  • Anthropic (claude-haiku-4-5-20251001)
  • Groq (llama-3.1-8b-instant)

Each provider answers questions about technical topics, and the assertions verify that responses contain relevant keywords.

Benefits of Using AI Gateway

  • Caching: Identical requests are cached, reducing costs during development
  • Analytics: View usage across all providers in your Cloudflare dashboard
  • Rate Limiting: Protect against quota issues with request queuing
  • Logging: All requests and responses are logged for debugging

Documentation

See the Cloudflare AI Gateway provider documentation for more details.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.