Skip to main content
Official TypeScript/Node.js SDK supports tracing LLM calls for OpenAI, Anthropic, Google Gemini.

Installation

Install your preferred LLM SDK(s):

Quick Start

That’s it! Every OpenAI, Anthropic, and Google call is now traced to your AmberTrace dashboard.

Usage Examples

OpenAI (ESM)
Anthropic
Google (ESM) Using the original @google/generative-ai SDK:
Using the newer @google/genai SDK:
CommonJS
Express.js API
Next.js API Route
Multi-Provider (OpenAI + Anthropic + Gemini)

Error Handling

The SDK follows a never-fail philosophy:
  • Network errors are logged but never thrown
  • Trace collection errors never impact your application
  • If the backend is unavailable, traces are silently dropped
  • Your LLM calls always succeed/fail based on the provider, not the SDK
Enable debug: true to see trace delivery logs:

What’s Traced?

Successful Calls For each successful LLM API call, AmberTrace captures:
  • Request Data
    • Model name
    • Full conversation history (all messages)
    • Parameters (temperature, max_tokens, etc.)
  • Response Data
    • Response ID
    • Model used
    • Generated messages
    • Token usage (prompt, completion, total)
    • Finish reason
  • Metadata
    • Unique trace ID
    • Timestamp (ISO 8601 UTC)
    • Duration in milliseconds
    • SDK version
    • Environment tag (if configured)

Failed Calls

When an LLM call fails, AmberTrace traces:
  • Request data (same as above)
  • Error information:
    • Exception type
    • Error message
    • Error code (if available)