Ir al contenido

Quickstart: OpenInference

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

OpenInference defines attributes for prompts, replies, and tool calls on OpenTelemetry spans. If your app already emits OpenInference spans, use the exporter settings below with your existing instrumentation. The Python example sends a sample trace and gives you a tool call to test.

  • A Mibo account with a verified email. Open the verification link in the browser you signed up with.
  • Python 3.14 and uv for the example.

Tested with Python 3.14.10 and the package versions pinned below.

Open the verification link in the browser you signed up with. If you open it in another browser where you’re signed out, Mibo asks you to choose a new password and revokes your existing API keys. 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.

Run these commands in a new project directory to try the Python example.

Terminal window
uv venv --python 3.14
uv pip install openinference-instrumentation==0.1.83 opentelemetry-sdk==1.45.2 \
opentelemetry-exporter-otlp-proto-http==1.45.2

Set these values in the same shell. Replace <YOUR_MIBO_API_KEY> with the key you copied.

Terminal window
export OTEL_SERVICE_NAME=openinference-support
export MIBO_OTLP_TRACES_ENDPOINT=https://api.mibo-ai.com/public/traces
export MIBO_API_KEY='<YOUR_MIBO_API_KEY>'

OTEL_SERVICE_NAME sets the service.name resource attribute. With a workspace key, Mibo routes by that name. If the name is new and the workspace has a free Agent slot, Mibo creates an Agent on the first trace. A key scoped to one Agent sends traces to that Agent. See trace routing.

In an existing app, pass the endpoint and the x-api-key header directly to the OTLP/HTTP exporter you configure for Mibo. If your exporter only takes a base URL and appends /v1/traces, use https://api.mibo-ai.com. In Python, attach the exporter and batch span processor to the tracer provider your instrumentor uses. If you already export through a collector, use Collector fan-out to send Mibo a copy.

Save the following as support.py. It uses OpenInference’s Python tracing helpers and a local order lookup. The chat span stands in for a model call. Mibo records the trace’s model from an llm span that sets llm.model_name. Without one, the dashboard shows Model not reported.

import os
from openinference.instrumentation import (
TracerProvider,
get_llm_input_message_attributes,
get_llm_output_message_attributes,
)
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider(
resource=Resource.create({"service.name": os.environ["OTEL_SERVICE_NAME"]}),
)
provider.add_span_processor(
BatchSpanProcessor(
OTLPSpanExporter(
endpoint=os.environ["MIBO_OTLP_TRACES_ENDPOINT"],
headers={"x-api-key": os.environ["MIBO_API_KEY"]},
timeout=10,
)
)
)
tracer = provider.get_tracer(__name__)
@tracer.tool
def lookup_order(order_id: str) -> str:
"""Look up shipping status by order ID."""
orders = {"A-1042": "shipped"}
return orders.get(order_id, "unknown")
try:
with tracer.start_as_current_span("support_agent", openinference_span_kind="agent"):
status = lookup_order("A-1042")
reply = f"Order A-1042: {status}."
with tracer.start_as_current_span("chat", openinference_span_kind="llm") as llm:
llm.set_attribute("llm.model_name", "gpt-5.4-mini")
llm.set_attributes(get_llm_input_message_attributes([
{"role": "user", "content": "What is the status of order A-1042?"},
]))
llm.set_attributes(get_llm_output_message_attributes([
{"role": "assistant", "content": reply},
]))
print(reply)
finally:
provider.shutdown()

Run the script.

Terminal window
uv run --no-project python support.py

The script prints Order A-1042: shipped. and shuts down the tracer provider, which exports the buffered spans. The Python exporter in the script always uses HTTP/protobuf.

Open Traces and select the Agent that received the trace by its current name. If Mibo created the Agent for this example, its initial name is openinference-support. Open the order trace and find lookup_order under What the agent did. Select View raw trace data to inspect the OpenInference attributes.

If the Python exporter logs 403 Forbidden, open Traces and check Waiting traces for an Agent limit notice. If you see it, set OTEL_SERVICE_NAME to the Service name of an active Agent or free an Agent slot. Then run the script again.

  1. Wait for the trace to finish, then click Create test from this trace.
  2. Open Draft if the editor shows tabs. Set Name to Looks up the order and clear Checks a trace when so the test checks each new trace for this Agent.
  3. Keep the Tool call check. If the draft omits it, choose Tool call from Does check. Set Tool name to lookup_order and select Must call. Remove the other checks and click Save test.
  4. Run the script again. Open the new trace on Traces and look under Test results. The check passes when the trace records a call to lookup_order.

For your own app, use the name of a tool you expect it to call. Keep message capture enabled so Mibo can use prompts and replies. If a trace is missing, check your instrumentor’s capture settings and look for llm.input_messages.* or llm.output_messages.* in the export. See content capture settings and Data handling.