Learn how to observe your deployed AI capabilities in production using Axiom’s AI SDK to capture telemetry.
The Observe stage is about understanding how your deployed generative AI capabilities perform in the real world. After creating and evaluating a capability, observing its production behavior is crucial for identifying unexpected issues, tracking costs, and gathering the data needed for future improvements.
Capturing telemetry with the @axiomhq/ai
SDK
The foundation of the Observe stage is Axiom’s SDK, which integrates with your app to capture detailed OpenTelemetry traces for every AI interaction.
The initial release of @axiomhq/ai
is focused on providing deep integration with TypeScript applications, particularly those using Vercel’s AI SDK to interact with frontier models.
Instrumenting AI SDK calls
The easiest way to get started is by wrapping your existing AI model client. The @axiomhq/ai
package provides helper functions for popular libraries like Vercel’s AI SDK.
The wrapAISDKModel
function takes an existing AI model object and returns an instrumented version that will automatically generate trace data for every call.
Adding context with withSpan
While wrapAISDKModel
handles the automatic instrumentation, the withSpan
function allows you to add crucial business context to your traces. It creates a parent span around your LLM call and attaches metadata about the capability
and step
being executed.
Setting up instrumentation
The Axiom AI SDK is built on the OpenTelemetry standard. To send traces, you need to configure a Node.js or edge-compatible tracer that exports data to Axiom.
Configuring the tracer
You must configure an OTLP trace exporter pointing to your Axiom instance. This is typically done in a dedicated instrumentation file that is loaded before your application starts.
Your Axiom credentials (AXIOM_TOKEN
and AXIOM_DATASET
) should be set as environment variables.
Understanding your AI telemetry
Once instrumented, every LLM call will send a detailed span to your Axiom dataset. These spans are enriched with standardized gen_ai.*
attributes that make your AI interactions easy to query and analyze.
Key attributes include:
gen_ai.capability.name
: The high-level capability name you defined inwithSpan
.gen_ai.step.name
: The specific step within the capability.gen_ai.request.model
: The model requested for the completion.gen_ai.response.model
: The model that actually fulfilled the request.gen_ai.usage.input_tokens
: The number of tokens in the prompt.gen_ai.usage.output_tokens
: The number of tokens in the generated response.gen_ai.prompt
: The full, rendered prompt or message history sent to the model (as a JSON string).gen_ai.completion
: The full response from the model, including tool calls (as a JSON string).gen_ai.response.finish_reasons
: The reason the model stopped generating tokens (e.g.,stop
,tool-calls
).
Visualizing traces in the console
Visualizing and making sense of this telemetry data is a core part of the Axiom Console experience.
- Coming soonA dedicated AI Trace Waterfall view will visualize single and multi-step LLM workflows, with clear input/output inspection at each stage.
- Coming soonA pre-built Gen AI OTel Dashboard will automatically appear for any dataset receiving AI telemetry. It will feature elements for tracking cost per invocation, time-to-first-token, call counts by model, and error rates.
What’s next?
Now that you are capturing and analyzing production telemetry, the next step is to use these insights to improve your capability.
Learn more in the Iterate page.