Braintrust
Connect
Connect Braintrust from the terminal. Pass --help for the flags Braintrust accepts.
polylane integration connect --type braintrustA service token from Settings → Service tokens in Braintrust, created in the organization you want to connect, in a permission group that can read and update all projects.
Connect your Braintrust organization with a service token. Polylane watches your projects, receives your Braintrust alerts as issues, and queries logs and experiments to find the cause.
- In Braintrust, open Settings → Service tokens and create a token in the organization you want to connect. Add it to a permission group that can read and update all projects, such as Owners or Engineers.
- Paste the token into Polylane. Polylane checks that the token belongs to one organization and can read and update all of its projects. Personal API keys are refused, because they follow a person into every organization they join.
On connect, Polylane adds its webhook to each time window alert in the organization. Your other actions on each alert stay as they are.
How it works
Braintrust alerts become issues
Your Braintrust time window alerts reach Polylane. Polylane adds its webhook to each one on connect and again every hour, so an alert that you create later gets the webhook within an hour. A firing alert opens an issue, and a recovery marks it recovered. When the same alert fires again while its issue is open, the alert goes to that issue. Polylane investigates each issue.
Braintrust alerts carry no severity. When an alert also has a PagerDuty action, Polylane uses the severity of that action. Other alerts arrive as warnings.
Log alerts send to a single action, so Polylane does not attach to them.
Checks on your projects
Polylane watches each project for changes in errors, latency, tokens, and cost. Every 30 minutes, it reads the 50 newest projects and runs one SQL query over all of them. It then checks seven series for the ten projects with the most root spans:
- Root-span error rate, p99 duration, and volume
- LLM spans with an error
- Estimated cost, prompt tokens, and completion tokens
A clear change opens an issue. If the query fails or Braintrust limits it, Polylane skips that run and tries again, so a failed read never looks like a quiet project. On the integration page, you can change how often the checks run or turn them off.
Braintrust allows 20 SQL queries a minute for each organization. The checks and the agents share that limit and one cache.
Polylane also explores the connection when you connect it and every 12 hours after that, and records what it finds as issues. Every six hours, Polylane checks that the token still belongs to one organization and can read and update all projects.
During an investigation
Read Braintrust logs, traces, and experiments through Polylane, query them with SQL, and request API changes. Agents search traces, open one trace as a span tree, list experiments, and compare the scores of an experiment with a baseline. Changes require safety review and approval.
Braintrust APIs
Polylane uses these Braintrust APIs:
| Braintrust API | What it unlocks |
|---|---|
POST /api/apikey/login, POST /api/self/get_object_info | Finds the organization of the token and checks that it can read and update all projects. |
GET /v1/project | Lists your projects. |
POST /btql | Runs read-only SQL over logs, experiments, and datasets: trace search, trace trees, and the error, latency, token, and cost series per project. |
GET /v1/experiment, GET /v1/experiment/{id}/summarize | Lists experiments and compares their scores with a baseline. |
GET /v1/project_automation, PATCH /v1/project_automation/{id} | Finds your time window alerts, adds the Polylane webhook to each one, and removes it when you disconnect. |
braintrustApi | Calls any other Braintrust API under /v1/. API keys, service tokens, secrets, inserts, the AI proxy, and function invoke are not available. |
Disconnecting
Disconnecting removes the Polylane webhook from your alerts and leaves the service token in Braintrust. Remove the token under Settings → Service tokens in Braintrust.
An alert whose only action is the Polylane webhook keeps it, because Braintrust requires one action, and Polylane ignores its deliveries.
Disconnect
Disconnecting stops every sync and check and deletes the credentials Polylane held. Polylane removes what Braintrust's API lets it remove. The following stays until you remove it yourself:
- Braintrust service token
polylane integration disconnect <id>Tools
7Operations agents can perform in threads.