Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 2.04 KB

README.md

File metadata and controls

64 lines (45 loc) · 2.04 KB

Braintrust AI Proxy (Node, AWS Lambda)

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.

Building

To build the proxy, you'll need to install pnpm, and then from the repository's root, run:

pnpm install
pnpm build

Running locally (Express server)

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

Running on AWS Lambda

To run on AWS, you'll need

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

CORS

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