To directly send OpenTelemetry metrics and traces generated by OpenLIT SDK from your LLM Application to Middleware, Follow the below steps.

1

Get your Middleware credentials

  1. Sign in to your Middleware account.
  2. Go to settings and click on API Key. Link
  3. Copy and save the value for MW_API_KEY and MW_TARGET
2

Add the following lines to your application code:

import openlit

openlit.init(
  otlp_endpoint="MW_TARGET",
  application_name="YOUR_APPLICATION_NAME",
  otlp_headers={
      "Authorization": "MW_API_KEY",
      "X-Trace-Source": "openlit",
  },
)

Replace:

  1. MW_TARGET with your middleware target URL
  • Example - https://abcd.middleware.io:443
  1. MW_API_KEY with your middleware API key.
  • Example - dxyxsdojzrgpsvizzzcsvhrwnmzqdsdsd

Refer to the OpenLIT Python SDK repository for more advanced configurations and use cases.

For detailed information on LLM Observability with Middleware and OpenLIT, consult Middleware Documentation: LLM Observability Documentation.

3

Visualize in Middleware

Once your LLM application is instrumented, you can view the traces, metrics and dashboards in the Middleware LLM Observability section. To access this:

  1. Log in to your Middleware account
  2. Navigate to the LLM Observability Section in the sidebar