Cloudflare R2
R2 is the zero-egress alternative. It speaks the S3 API, supports the conditional writes NamiDB depends on, and charges no egress fees.
If you’re running NamiDB outside AWS — on Cloudflare Workers, Fly.io, your own VPS, your laptop — R2 is almost always the right call.
Open a namespace
import osos.environ["AWS_ACCESS_KEY_ID"] = "<R2 access key>"os.environ["AWS_SECRET_ACCESS_KEY"] = "<R2 secret>"
client = tg.Client( "s3://my-bucket?ns=prod" "&endpoint=https://<ACCOUNT_ID>.r2.cloudflarestorage.com" "®ion=auto")The R2 endpoint lives at https://<ACCOUNT_ID>.r2.cloudflarestorage.com.
Region must be auto.
Creating a bucket + token
- In the Cloudflare dashboard, go to R2 → Create bucket.
- R2 → Manage R2 API Tokens → Create API Token with “Object Read & Write” on your bucket.
- The token download includes an
Access Key IDand aSecret Access Key. Set them asAWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYand you’re done.
What works
| Capability | Status |
|---|---|
Conditional writes (If-Match / If-None-Match) | ✅ |
| Multi-region replication | ✅ (R2 jurisdictions) |
| Per-bucket lifecycle policies | ✅ |
| Custom endpoints / DNS | ✅ (R2 public buckets) |
Cost considerations
- Storage: $0.015/GB-month (Standard).
- Class A operations (PUT, COPY, LIST): $4.50 per million.
- Class B operations (GET, HEAD): $0.36 per million.
- Egress: $0.
For agent-memory workloads with read-heavy patterns, R2 is usually ~30% cheaper than equivalent S3, dominated by zero egress.
See also
- AWS S3 — the primary backend
- URI grammar