What the SDK gives you
Install
- TypeScript
- Python
Initialize the client
- TypeScript
- Python
Manage deployments
The SDK can fetch deployed prompt configurations — including the model, provider settings, messages, tools, and variables — so your application always uses the latest version without redeploying code.Fetch a specific deployment
- TypeScript
- Python
Fetch the latest deployment for an environment
- TypeScript
- Python
Auto-refresh deployments in production
For long-running services, useinitLatestDeployment to set up a cached deployment that refreshes automatically (default every 60 seconds) in the background. When you deploy a new prompt version in Adaline, your application picks it up without a restart.
- TypeScript
- Python
Initialize the monitor
The monitor manages the lifecycle of traces and spans — buffering them in memory, batching them together, and flushing them to the Adaline API on a timer or when the buffer fills up.- TypeScript
- Python
Create a trace
A trace represents a single end-to-end request flow — for example, one user message that triggers an LLM call, a tool execution, and a final response.- TypeScript
- Python
Add spans
Each operation inside a trace is a span. Spans carry a content type that tells Adaline what kind of operation it represents — an LLM call, a tool execution, a vector retrieval, and more.Create a span
- TypeScript
- Python
Update and end a span
After performing the operation, update the span with the result and end it:- TypeScript
- Python
Nested spans
Spans can contain child spans to model hierarchical workflows — an agent span containing tool call spans, or a RAG span containing embedding and retrieval sub-spans:Span content types
Thecontent.type field tells Adaline what kind of operation a span represents. Each type carries input and output as JSON strings, plus type-specific fields.
Model
LLM chat completions and text generation. Captures the provider, model, cost, and optionally expected output for evaluation. For the best experience, stringify the exact request payload you send to your AI provider asinput and the full response as output. When you use a supported provider, Adaline automatically extracts token usage, calculates cost, and surfaces model metadata. See Span content: input and output for full details and examples. You can also use Adaline’s own content schema for input and output, although this is more advanced and requires custom transformations.
ModelStream
Streaming LLM responses. Captures both the raw stream chunks and an aggregated output.Tool
Function or tool call execution.Retrieval
Vector search, document retrieval, or any RAG retrieval step.Embeddings
Embedding generation.Function
Custom business logic, data transforms, or any application-specific operation.Guardrail
Safety checks, content filters, PII detection, or compliance rules.Other
Any operation that doesn’t fit the types above.type, input (JSON string), and output (JSON string).
End the trace and flush
Always end the trace and flush remaining data. Callingend() on a trace recursively ends all child spans that haven’t been ended yet.
- TypeScript
- Python
Attach variables for evaluation
Attach variable values to spans so they flow into continuous evaluations and can be captured into datasets. Variables are set on the span’s content object (specifically onModel or ModelStream content types), not on logSpan() directly:
- TypeScript
- Python
text, image, and pdf modalities. See Log attachments for full details on attaching variables, attributes, and tags.
Buffering, batching, and retries
The SDK handles reliability so you don’t have to.How the buffer works
- When you call
logTrace()orlogSpan(), entries are added to an in-memory buffer. - A background timer flushes the buffer every
flushIntervalseconds. - If the buffer reaches
maxBufferSize, it flushes immediately. - Each flush sends a batch of entries in a single API call.
Retry behavior
Health monitoring
Inspect the monitor’s flush status at runtime to detect issues:- TypeScript
- Python
Graceful shutdown
In production, handle process signals to flush remaining data before the process exits:- TypeScript
- Python
Next steps
Advanced Tracing Patterns
Multi-step workflows, tool-calling agents, session tracking, and error handling patterns.
Log User Feedback
Attach thumbs up/down, ratings, and comments to traces.
Log Attachments
Attach attributes, tags, variables, and metadata to traces and spans.
SDK Reference
Complete class and type reference for the TypeScript and Python SDKs.