This directory contains an implementation of the Braintrust AI Proxy that runs on Cloudflare Workers. Because of their global network, you get the benefit of low latency and can scale up to millions of users.
You'll need the following prerequisites:
By default, the worker uses the local @braintrust/proxy package, which you need to build. From the
repository's root, run:
pnpm install --frozen-lockfile
pnpm buildThen, you return to this directory and setup a KV namespace for the proxy:
wrangler kv namespace create ai_proxyRecord the ID of the namespace that you just created. Then, copy wrangler-template.toml to
wrangler.toml and replace <YOUR_KV_ID> with the ID of the namespace.
Finally, you can run the worker locally with
npx wrangler devor deploy it to Cloudflare with
npx wrangler deployIf you'd like to use the proxy in your own project, that's fine too! Simply install the
@braintrust/proxy package with your favorite package manager, and follow/customize the
implementation in proxy.ts.