All integrationsStorage
Cloudflare R2 Integration
S3-compatible object storage with zero egress fees.
R2 implements the S3 API, so the same upload code you'd write for AWS S3 works against R2 with just an endpoint change. The main draw is eliminating egress costs, which matter if your RAG pipeline re-reads source documents frequently.
Setup in 4 steps
- 1Create an R2 bucket and API token in the Cloudflare dashboard
- 2Set S3_ENDPOINT_URL to your R2 account endpoint alongside the usual access keys
- 3Reuse the same boto3/aioboto3 client code as an S3 integration — R2 is API-compatible
- 4Point the ingestion pipeline's storage read/write at R2 instead of AWS
What's included
- Drop-in for existing S3 client code — same API, different endpoint
- No egress fees, which matters for RAG pipelines that re-fetch source files
- Good option if the rest of your stack is on Cloudflare (Workers, Pages, D1)
- Same async upload pattern as the AWS S3 integration guide
Code example
# app/storage/r2.py — same client code as S3, different endpoint
import aioboto3
session = aioboto3.Session()
async def get_r2_client():
return session.client(
"s3",
endpoint_url=f"https://{ACCOUNT_ID}.r2.cloudflarestorage.com",
aws_access_key_id=R2_ACCESS_KEY_ID,
aws_secret_access_key=R2_SECRET_ACCESS_KEY,
)Full documentation: /docs/rag-pipeline
Cloudflare R2 integration pre-wired and ready.
FastAPI AI Kit ships with Cloudflare R2 configured out of the box. No manual setup required.
Ready to ship your AI backend this weekend?
Join developers who skipped weeks of boilerplate and went straight to building.
No subscriptions · One-time payment · Lifetime updates
