This repository contains a bash script to test Cloudflare AI Gateway with Replicate using the anthropic/claude-4.5-haiku model.
See the official Cloudflare documentation for more information about using Replicate with AI Gateway.
- 
Create a Cloudflare AI Gateway by following the getting started guide
 - 
Copy
.env.exampleto.env:cp .env.example .env
 - 
Fill in your credentials in
.env:CF_ACCOUNT_ID: Your Cloudflare account ID (find it here)REPLICATE_API_TOKEN: Your Replicate API token from https://replicate.com/account/api-tokens
 
Run the script with an optional prompt:
./replicate-test.sh "Your prompt here"Or use the default prompt:
./replicate-test.shPrompt (optional): The prompt to send to Claude. Default: "Write a haiku about Cloudflare"
The script uses a 30-second timeout with the Prefer: wait header, which tells Replicate to keep the connection open and wait for the model to complete, rather than returning immediately with a prediction ID.
The script:
- Loads environment variables from 
.env - Validates required credentials are present
 - Constructs the Cloudflare AI Gateway endpoint for the 
ai-gateway-zikigateway - Makes a POST request to create a prediction with the Claude 4.5 Haiku model
 - Uses standard Replicate authentication with 
Authorization: Bearerheader - Includes 
Prefer: waitheader to get synchronous responses - Routes the request through Cloudflare AI Gateway for monitoring and caching
 
https://gateway.ai.cloudflare.com/v1/{account_id}/ai-gateway-ziki/replicate/predictions
The script will output the JSON response from Replicate, which includes the model's completion when using Prefer: wait.