SDKs
Python SDK
Python SDK - Overview
6 min
the abv python sdk is designed for best in class developer experience and ease of use built on the robust opentelemetry python sdk, it offers a more intuitive api for comprehensive tracing of your llm application official link https //pypi org/project/abvdev/ https //pypi org/project/abvdev/ the sdk introduces several key benefits improved developer experience a more intuitive api means less code to write for tracing your application, simplifying the integration process unified context sharing seamlessly hook into the tracing context of the current span to update it or create child spans this is particularly beneficial for integrating with other instrumented libraries broad third party integrations any library instrumented with opentelemetry will work out of the box with the abv sdk spans from these libraries are automatically captured and correctly nested within your abv traces quickstart there are three main ways of instrumenting your application with the new abv sdk all of them are fully interoperable with each other using observe decorator the @observe decorator is the simplest way to instrument your application it is a function decorator that can be applied to any function it sets the current span in the context for automatic nesting of child spans and automatically ends it when the function returns it also automatically captures the function name, arguments, and return value from abvdev import observe, get client @observe def my function() return "hello, world!" # input/output and timings are automatically captured my function() \# flush events in short lived applications abv = get client() abv flush() using context managers context managers are the recommended way to instrument chunks of work in your application as they automatically handle the start and end of spans, and set the current span in the context for automatic nesting of child spans they provide more control than the @observe decorator from abvdev import get client abv = get client() \# create a span using a context manager with abv start as current span(name="process request") as span \# your processing logic here span update(output="processing complete") \# create a nested generation for an llm call with abv start as current generation(name="llm response", model="gpt 5 2025 08 07") as generation \# your llm call logic here generation update(output="generated response") \# all spans are automatically closed when exiting their context blocks \# flush events in short lived applications abv flush() using manual observations manual observations give you control over when spans start and end and do not set the current span in the context for automatic nesting of child spans you must explicitly call end() when theyโre complete from abvdev import get client abv = get client() \# create a span without a context manager span = abv start span(name="user request") \# your processing logic here span update(output="request processed") \# child spans must be created using the parent span object nested span = span start span(name="nested span") nested span update(output="nested span output") \# important manually end the span nested span end() \# important manually end the parent span span end() \# flush events in short lived applications abv flush() learn more python sdk setup docid\ qencsqitl93ijgjjq6zjk python sdk instrumentation docid\ oiklvy9cbvbt2jdltp3tp python sdk evaluations docid\ vrxzmbcxkyo oghjiduun python sdk advanced usage docid\ ys1 cfgrwyh1vygh1pypy python sdk troubleshooting docid\ en3jvyvbd2i4dbko65l m otel and abv the abv sdk is built upon opentelemetry (otel) https //opentelemetry io/ , a standard for observability understanding the relation between otel and abv is not required to use the sdk, but it is helpful to have a basic understanding of the concepts otel related concepts are abstracted away and you can use the sdk without being deeply familiar with them otel trace an otel trace represents the entire lifecycle of a request or transaction as it moves through your application and its services a trace is typically a sequence of operations, like an llm generating a response followed by a parsing step the root (first) span created in a sequence defines the otel trace otel traces do not have a start and end time, they are defined by the root span otel span a span represents a single unit of work or operation within a trace spans have a start and end time, a name, and can have attributes (key value pairs of metadata) spans can be nested to create a hierarchy, showing parent child relationships between operations abv trace a abv trace collects observations and holds trace attributes such as session id , user id as well as overall input and outputs it shares the same id as the otel trace and its attributes are set via specific otel span attributes that are automatically propagated to the abv trace abv observation in abv terminology, an "observation" is a abv specific representation of an otel span it can be a generic span (abv span) or a specialized "generation" (abv generation) or a point in time event (abv event) abv span a abv span is a generic otel span in abv, designed for non llm operations abv generation a abv generation is a specialized type of otel span in abv, designed specifically for large language model (llm) calls it includes additional fields like model , model parameters , usage details (tokens), and cost details abv event a abv event tracks a point in time action context propagation opentelemetry automatically handles the propagation of the current trace and span context this means when you call another function (whether it's also traced by abv, an otel instrumented library, or a manually created span), the new span will automatically become a child of the currently active span, forming a correct trace hierarchy the abv sdk provides wrappers around otel spans ( abvspan , abvgeneration ) that offer convenient methods for interacting with abv specific features like scoring and media handling, while still being native otel spans under the hood you can also use these wrapper objects to add abv trace attributes