Ir al contenido

Quickstart: OpenLLMetry

Esta página aún no está disponible en tu idioma.

In about five minutes, you export an OpenLLMetry-instrumented OpenAI call to Mibo, send one trace, and create a test from it. OpenLLMetry is Traceloop’s open-source OpenTelemetry instrumentation for LLM SDKs and frameworks such as LangChain. Mibo evaluates the traces your code sends. It never calls your Agent. If you already export traces to another backend, keep it and add Mibo with the Collector fan-out.

  • A Mibo account with a verified email. Open the verification link in the browser you signed up with.
  • Python 3.10 or later, or Node.js 22 or later.
  • An OpenAI API key.

Create an account at app.mibo-ai.com, or sign in. Open the verification link in the browser you signed up with. If you open it elsewhere, Mibo asks you to choose a new password and earlier API keys stop working. If you own the workspace, create an API key in Settings and copy it. Mibo shows the key only once. If you’re a workspace member, ask the owner for a key.

OpenLLMetry sets service.name from the app name in the example below. When Mibo receives the first trace for a new service.name, it creates an Agent with that name. You can rename the Agent afterwards. A key scoped to one Agent routes traces to that Agent instead. See trace routing for other key scopes and the Agent limit.

The examples pass a custom OTLP exporter with the full Mibo URL. To use OpenLLMetry’s default exporter, remove the exporter option. Export MIBO_API_KEY first, as the install block below does, then run the following. OpenLLMetry appends /v1/traces to the base URL and sends the key in the x-api-key header.

Terminal window
export TRACELOOP_BASE_URL=https://api.mibo-ai.com
export TRACELOOP_HEADERS="x-api-key=$MIBO_API_KEY"
Terminal window
pip install traceloop-sdk openai
export MIBO_API_KEY='<YOUR_MIBO_API_KEY>'
export OPENAI_API_KEY='<YOUR_OPENAI_API_KEY>'

Save this as agent.py:

import json
import os
from openai import OpenAI
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import tool, workflow
Traceloop.init(
app_name="support-agent-prod",
exporter=OTLPSpanExporter(
endpoint="https://api.mibo-ai.com/public/traces",
headers={"x-api-key": os.environ["MIBO_API_KEY"]},
),
)
client = OpenAI()
TOOLS = [
{
"type": "function",
"function": {
"name": "lookup_order",
"description": "Look up an order by ID",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"],
},
},
}
]
@tool(name="lookup_order")
def lookup_order(order_id: str) -> dict:
return {"order_id": order_id, "status": "shipped", "eta": "Friday"}
@workflow(name="support_agent")
def answer(question: str) -> str:
messages = [
{"role": "system", "content": "You are a support agent for an online store."},
{"role": "user", "content": question},
]
first = client.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=TOOLS)
reply = first.choices[0].message
if not reply.tool_calls:
return reply.content or ""
messages.append(reply.model_dump(exclude_none=True))
for call in reply.tool_calls:
result = lookup_order(**json.loads(call.function.arguments))
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=TOOLS)
return final.choices[0].message.content or ""
print(answer("Where is my order A-1042?"))

Run it:

Terminal window
python agent.py

The script prints the model’s reply, for example Your order A-1042 has shipped and should arrive on Friday. The OpenTelemetry SDK flushes the trace when the process exits.

Open Traces and select your Agent. The trace has a support_agent.workflow root span, two openai.chat or chat gpt-4o-mini spans, and a lookup_order.tool span.

  1. Open the trace on the Traces page and click Create test from this trace. The editor opens with a draft built from that trace.
  2. Review the generated test cases and click Save test. Keep the test Active.
  3. Run the script again. Mibo evaluates each new trace against your saved tests.
  4. Open the new trace on the Traces page and read Test results.
Data Attribute Notes
User input gen_ai.input.messages on the LLM span Recorded while content tracing is on
Final response gen_ai.output.messages on the LLM span Recorded while content tracing is on
Tool calls gen_ai.tool.name on the lookup_order.tool span Python only. The span carries the tool name but no gen_ai.tool.call.arguments. In TypeScript, the span has no gen_ai.tool.name, so Mibo treats it as a step named lookup_order.tool.
Token usage gen_ai.usage.input_tokens and gen_ai.usage.output_tokens Always recorded

OpenLLMetry records prompts and completions by default. Setting TRACELOOP_TRACE_CONTENT=false removes them. The trace_content=False option in Python and traceContent: false in TypeScript do the same. Without them, Mibo has no user input, so tests with a Checks a trace when condition are skipped and the trace shows This trace had no usable user input for scenario routing.. Tests with an empty Checks a trace when still run, but checks on the reply have no text to read.

Prompts and replies can contain personal data. Mibo redacts secrets on a best-effort basis, and personal data when your workspace enables it. See Data handling.

For other OpenTelemetry instrumentations, see Capture the content Mibo needs.

Setting Value
Endpoint POST https://api.mibo-ai.com/public/traces. Set the full URL. Exporters that take a base URL append /v1/traces.
Authentication x-api-key header
Encoding OTLP/HTTP protobuf, as in these examples, or JSON. Mibo does not accept OTLP/gRPC.
Compression gzip is accepted.
Size limit 10 MB per request. See Payload size limits.
Routing A workspace key creates an Agent for a new service.name.