OpenLIT with Muapi

OpenLIT can instrument an application that calls Muapi through the OpenAI Python SDK. The key requirement is that the SDK client uses Muapi's compatible chat-completions endpoint.

Install and initialize

Install OpenLIT and the OpenAI SDK:

pip install openlit openai

Initialize OpenLIT before creating requests. Set an OTLP endpoint for your OpenTelemetry collector or OpenLIT deployment:

import openlit

openlit.init(otlp_endpoint="http://127.0.0.1:4318")

Send a traced Muapi request

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MUAPI_API_KEY"],
    base_url="https://api.muapi.ai/v1",
)

response = client.chat.completions.create(
    model="YOUR_MUAPI_TEXT_MODEL_ID",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Replace the model ID with one returned by Muapi's GET /v1/models?type=text endpoint. Follow your collector's configuration and privacy policies for trace data, which may include prompts and responses.