Skip to main content
Applies to:
  • Plan -
  • Deployment -

Summary

Issue: Running bt eval --dev <file> and connecting to the Playground causes gateway calls to fail with AI_APICallError: Not Found when the AI SDK client reads BRAINTRUST_API_KEY. Cause: bt eval --dev replaces BRAINTRUST_API_KEY with a short-lived Playground session token, which the Braintrust gateway does not accept as a valid credential. Resolution: Pass your real API key to the gateway client via a separate environment variable that bt eval --dev does not overwrite.

Environment variables injected by bt eval --dev

When the Playground connects to your local dev server, the following variables are overwritten in your process environment: The session token injected into BRAINTRUST_API_KEY carries your identity but is not accepted by the Braintrust gateway (gateway.braintrust.dev). Only real API keys (sk-...) or service tokens (bt-st-...) authenticate successfully to the gateway.

Resolution steps

Step 1: Set a separate env var for your real API key

Before launching the dev server, set an additional variable in the same shell:

Step 2: Update your gateway client to read the override first

The fallback to BRAINTRUST_API_KEY ensures the client still works in non-dev contexts where the override is not set.

Notes

  • A 404 Not Found from the AI SDK indicates a bad route or unaccepted credential at the gateway — not a missing org permission. A permission error would surface as 401 or 403.
  • Any env var name not in the injected list above can serve as the override. Common choices: BRAINTRUST_API_KEY_OVERRIDE, BT_API_KEY, BT_GATEWAY_KEY.
  • This workaround is required any time your gateway client reads BRAINTRUST_API_KEY directly in dev mode.