replicate/cloudflare-ai-gateway-replicate-test
Shell
Captured source
source ↗replicate/cloudflare-ai-gateway-replicate-test
Language: Shell
Stars: 0
Forks: 0
Open issues: 0
Created: 2025-10-29T16:55:14Z
Pushed: 2025-10-29T17:12:20Z
Default branch: main
Fork: no
Archived: no
README:
Cloudflare AI Gateway with Replicate
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.
Setup
1. Create a Cloudflare AI Gateway by following the getting started guide
2. Copy .env.example to .env:
cp .env.example .env
3. 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
Usage
Run the script with an optional prompt:
./replicate-test.sh "Your prompt here"
Or use the default prompt:
./replicate-test.sh
Parameters
Prompt (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.
How it works
The script: 1. Loads environment variables from .env 2. Validates required credentials are present 3. Constructs the Cloudflare AI Gateway endpoint for the ai-gateway-ziki gateway 4. Makes a POST request to create a prediction with the Claude 4.5 Haiku model 5. Uses standard Replicate authentication with Authorization: Bearer header 6. Includes Prefer: wait header to get synchronous responses 7. Routes the request through Cloudflare AI Gateway for monitoring and caching
Endpoint Format
https://gateway.ai.cloudflare.com/v1/{account_id}/ai-gateway-ziki/replicate/predictionsExample Response
The script will output the JSON response from Replicate, which includes the model's completion when using Prefer: wait.
Notability
notability 1.0/10Trivial test repo, no traction