Tracing
To trace Groq with Braintrust’s TypeScript SDK, use auto-instrumentation, manual instrumentation, or the Braintrust gateway. Auto-instrumentation is the recommended path for most users.- Auto-instrumentation
- Manual instrumentation
- Gateway
Auto-instrumentation patches the The auto-instrumentation example uses plain JavaScript so
groq-sdk client at runtime when you run your app with Braintrust’s import hook, so you don’t modify your application code.Setup
Install the Braintrust and Groq SDKs, then set your API keys. Requiresgroq-sdk v1.0.0 or later..env
Trace your application
Initialize Braintrust and call Groq normally, then run your app with the import hook to patch the client at runtime.1
Initialize Braintrust and call Groq
2
Run with the import hook
node --import can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.If you’re using a bundler, see Trace LLM calls for plugin and loader setup.
What Braintrust traces
Braintrust patches thegroq-sdk client and captures:- Chat completion spans (
groq.chat.completions.create), with messages and request parameters as input, and response choices and token usage as output. - Reasoning content for Groq reasoning models, aggregated from streaming responses.
- Embedding spans (
groq.embeddings.create), with input and request parameters as input, and the first embedding’s vector length as output. - Token usage metrics (prompt, completion, total), including Groq cache metrics (
dram_cached_tokensandsram_cached_tokens) when reported. time_to_first_tokenfor chat completions.- Errors captured on every call.
Tracing resources
Evals
Run experiments against Groq models to measure quality and catch regressions. AnEval is composed of a dataset of inputs, a task, and a set of scorers. To learn more, see the Experiments guide.Add Groq as an AI provider
Configure your Groq API key in Braintrust to route requests through the gateway and use Groq models from the playground.1
Get a Groq API key
Get a Groq API key from Groq Console.
2
Add Groq as an AI provider
Add the Groq API key as an organization or project AI provider.
API keys are stored as one-way cryptographic hashes, never in plaintext.