This directory contains an implementation of the Braintrust AI Proxy that runs on Node.js runtimes and can be bundled as an Express server or AWS Lambda function.
To build the proxy, you'll need to install pnpm, and then from the repository's root, run:
pnpm install
pnpm build
To run the proxy locally, you need to connect to a Redis instance. The easiest way to run Redis locally is with Docker. Once you have Docker installed, you can run (full instructions)
docker run --name some-redis -d redis
to run Redis on port 6379. Then, create a file named .env.local
with the following contents:
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
Finally, you can run the proxy with
pnpm dev
To run on AWS, you'll need
- The AWS CLI
- A Lambda function with a Node.js runtime
- A function URL for your Lambda function
Once you've created and configured a Lambda function, you can deploy the proxy with
aws lambda update-function-code --function-name <YOUR_LAMBDA_FUNCTION> --zip-file fileb://$PWD/dist/index.zip
If you're using the proxy to access Braintrust AI from a browser, you'll need to enable CORS on your Lambda function. This is a tricky process, but the following function URL CORS settings should work:
Allow origin
:*
Expose headers
:content-type, keep-alive, access-control-allow-credentials, access-control-allow-origin, access-control-allow-methods
Allow headers
:authorization
Allow methods
:POST, GET
Max age
:86400
Allow credentials
:true