magpie-server takes traces over OTLP, the protocol of OpenTelemetry. So any app, in any language, with any framework that sends OpenTelemetry spans can send them to Magpie. You do not need a Magpie package in your app.
Start a server first (quickstart).
The endpoints
These are the standard OTLP ports. Change them with
--http-addr and --grpc-addr.
Point your app at Magpie
Most OpenTelemetry SDKs read these environment variables. No code change is needed:%20 is a space):
crates/server/e2e/ in the repo).
An example: an app in Python
This app makes one agent run by hand: an agent span with a model call inside. A real app gets such spans from its framework or from an instrumentation library.jq only makes the answer short):
provider.shutdown() (or force_flush()) before a short script ends. Else the last batch is not sent.
From an agent framework
Each framework below sends OpenTelemetry spans; Magpie reads their GenAI attribute names (Mapping). The setups are from each project’s own docs (links). Two were run against Magpie on 2026-12-03 with the framework’s own fake model (no API key, no call to a provider), in a scratch folder: the Vercel AI SDK and LangChain. The OpenAI Agents SDK and Mastra setups were not tested. With API keys, add the header to each exporter (authorization: Bearer mgp_...), or set OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer%20mgp_...".
OpenAI Agents SDK (Python)
Through the OpenInference instrumentation (its README; the SDK’s own tracing page lists such processors: openai.github.io/openai-agents-python/tracing). It writes OpenInference attributes (openinference.span.kind, input.value, output.value, llm.model_name). Not tested.
Vercel AI SDK
The setup is from ai-sdk.dev/docs/ai-sdk-core/telemetry. The current SDK sends its spans to the global OpenTelemetry tracer when you callregisterTelemetry(new OpenTelemetry()) (@ai-sdk/otel); it writes the GenAI names (gen_ai.input.messages, gen_ai.usage.input_tokens, …). AI SDK 5 used experimental_telemetry: { isEnabled: true } on each call instead (v5 docs) and the ai.* names, which Magpie reads too. The AI SDK docs show no exporter; the Node SDK below is the standard OpenTelemetry one (in Next.js: @vercel/otel in instrumentation.ts). Tested with this code as it is and the SDK’s MockLanguageModelV4 (ai 7.0.188, @ai-sdk/otel 1.0.188, @opentelemetry/sdk-node 0.302.0): a generateText run is found by a word of its prompt. It has three spans: invoke_agent (kind agent_run), chat (kind model_generation, with the model, the tokens, counted once, and the prompt and answer as text) and step 1. Call await sdk.shutdown() before a short script ends, or its spans are not sent.
LangChain and LangGraph (Python)
Through LangSmith’s OpenTelemetry mode (docs.langchain.com/langsmith/trace-with-opentelemetry, section “Configure alternate OTLP endpoints”).LANGSMITH_OTEL_ONLY=true sends to your endpoint only, not to LangSmith. Another way is the OpenInference instrumentation openinference-instrumentation-langchain (README), set up like the OpenAI Agents one above. Tested with the LangSmith way, this code as it is and LangChain’s FakeListChatModel in a prompt-and-model chain (langsmith 0.14.17, langchain 1.4.10, langchain-core 1.7.7): the run is found by a word of its prompt, with the chain’s input and output as text. Limits seen: the prompt-template step is stored with the kind model_generation (no tokens), the input of the model call is LangChain’s serialized message list as key: value lines, and the fake model has no model name (a real one sends ls_model_name; not checked). Call provider.force_flush() before a short script ends.
Mastra
Through@mastra/otel-exporter (mastra.ai/docs/observability/tracing/exporters/otel, “Custom or generic OTEL endpoints”). It follows the GenAI conventions (semconv 1.41: gen_ai.input.messages, gen_ai.output.messages, gen_ai.usage.*). Not tested.
From an OpenTelemetry Collector
Add Magpie as one more exporter. Not tested here (no Collector binary was run); it speaks the same protocol as the SDKs above.otlp with endpoint: magpie-host:4317.
What Magpie keeps
Each OpenTelemetry span becomes one Magpie span. Magpie reads the GenAI semantic conventions (release v0.1.0), older GenAI names, and some names of OpenInference and the Vercel AI SDK. The first name it finds wins.
The full table (cached and reasoning tokens, time to first token, cost, every name that is read): the server reference, “Mapping”.
Some rules to know:
- Text is made readable. A message list becomes one
role: textline per message (you sawuser: Where is my parcel?above). Other JSON objects becomekey: valuelines. - Tokens come from model calls only. An agent span reports the sum of the model calls under it. Magpie does not count those tokens twice. The agent’s own numbers stay in its attributes.
- Cost. The GenAI conventions have no cost attribute. Magpie reads
gen_ai.usage.costand OpenInferencellm.cost.*. Or give the server a price table (--prices), and it computes the cost of each model call: the server reference, “Cost”. - A retry does not make a copy. Spans are written with
upsert: a span with the same trace id and span id replaces the one before. - A bad span is refused alone. A span with bad ids, no start time, an end before its start, or (in OTLP/JSON) a value that is wrong for its field is refused. The answer is
200withpartialSuccess, and the other spans are stored. The message names the span by its number and the field. It does not give the value. - A text cut inside an emoji is kept. The half character is stored as U+FFFD (
�), as the protobuf exporters send it, andpartialSuccesssays how many there were."NaN"and"Infinity"in a JSONdoubleValueare kept as those values. The rules per value: the server reference, “Send traces to it”. - Every stored span has
magpie.mapping: 2in its attributes: the version of the mapping. The GenAI conventions are still in development. When they change, the mapping gets a new version. Spans that are stored keep the old one.
traceState, flags, dropped counts, scope attributes, schema URLs. tags are never set from OTLP: OpenTelemetry has no standard name for them.
What the server answers
The largest request is 64 MiB by default (
--max-body-bytes 67108864, the default that the OTLP spec recommends). That takes an SDK’s full batch with the default settings: 512 spans of 50 KB each, about 26 MB, over HTTP and gRPC (crates/server/tests/sdk_batch.rs in the repo). For larger batches, raise --max-body-bytes, or send fewer spans per export (OTEL_BSP_MAX_EXPORT_BATCH_SIZE). A 413 is not sent again: the batch is lost.
All errors and their limits: operations, “What an error means”.
Import old traces
Traces from before, in files (OTLP/JSON of the Collector’sfile exporter, LangSmith runs, or a Magpie export), go in with magpie-server import: operations, “Import”.