Create an account at https://app.baserun.ai/sign-up. Then generate an API key for your project in the settings tab and set it as an environment variable.
Copy
Ask AI
export BASERUN_API_KEY="your_api_key_here"
3
Initialize baserun
You need to initialize Baserun in a body of every request handler where you want to use it.
your-project/instrumentation.ts
Copy
Ask AI
export const POST = async (req: any) => { await baserun.init() // your request handler code}
In this example, we’re using Vercel’s ai npm package to stream the result of an OpenAI chat completion to the client.
Note, that Baserun doesn’t support export const runtime = "edge";, we we’re keeping this in an ordinary Lambda function deployed by Vercel.