New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

openlit

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openlit

OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects

latest
Source
npmnpm
Version
1.11.0
Version published
Weekly downloads
1.8K
19.18%
Maintainers
2
Weekly downloads
 
Created
Source
OpenLIT Logo

OpenTelemetry-native

AI Observability, Monitoring and Evaluation Framework

Documentation | Quickstart | Roadmap | Feature Request | Report a Bug

OpenLIT License Downloads GitHub Last Commit GitHub Contributors

Slack X

OpenLIT Connections Banner

OpenLIT SDK is a monitoring framework built on top of OpenTelemetry that gives your complete Observability for your AI stack, from LLMs to vector databases, with just one line of code with tracing and metrics. It also allows you to send the generated traces and metrics to your existing monitoring tools like Grafana, New Relic, and more.

This project proudly follows and maintains the Semantic Conventions with the OpenTelemetry community, consistently updating to align with the latest standards in Observability.

⚡ Features

  • 🔎 Auto Instrumentation: Works with 12+ LLM providers, vector databases, and AI frameworks with just one line of code.
  • 🔭 OpenTelemetry-Native Observability SDKs: Vendor-neutral SDKs that can send traces and metrics to your existing observability tool like Prometheus and Jaeger.
  • 💲 Cost Tracking for Custom and Fine-Tuned Models: Pass custom pricing files for accurate budgeting of custom and fine-tuned models.
  • 🚀 Support for OpenLIT Features: Includes support for prompt management and secrets management features available in OpenLIT.

Auto Instrumentation Capabilities

LLMs
✅ OpenAI
✅ Anthropic
✅ Cohere
✅ Groq
✅ Mistral
✅ Google AI Studio
✅ Together AI
✅ Ollama
✅ AWS Bedrock
✅ Hugging Face
✅ Replicate
✅ Azure OpenAI (via OpenAI SDK)
Vector Databases
✅ Chroma
✅ Pinecone
✅ Qdrant
✅ Milvus
Frameworks
✅ LangChain
✅ LlamaIndex
✅ Vercel AI SDK

Supported Destinations

Supported Metrics

The following metrics are supported across all integrations:

  • genaiClientUsageTokens: Histogram for total input/output tokens used.
  • genaiClientOperationDuration: Histogram for GenAI operation duration.
  • genaiServerTbt: Histogram for time per output token after the first token.
  • genaiServerTtft: Histogram for time to first token for successful responses.
  • genaiRequests: Counter for number of GenAI requests.
  • genaiPromptTokens: Counter for number of prompt tokens processed.
  • genaiCompletionTokens: Counter for number of completion tokens processed.
  • genaiReasoningTokens: Counter for number of reasoning thought tokens processed.
  • genaiCost: Histogram for distribution of GenAI request costs (USD).

These metrics allow you to monitor usage, performance, and cost for supported GenAI operations.

💿 Installation

npm install openlit

🚀 Getting Started

Step 1: Install OpenLIT

Open your command line or terminal and run:

npm install openlit

Step 2: Initialize OpenLIT in your Application

Integrate OpenLIT into your AI applications by adding the following lines to your code.

import Openlit from 'openlit';

Openlit.init();

Configure the telemetry data destination as follows:

PurposeParameter/Environment VariableFor Sending to OpenLIT
Send data to an HTTP OTLP endpointotlpEndpoint or OTEL_EXPORTER_OTLP_ENDPOINT"http://127.0.0.1:4318"
Authenticate telemetry backendsotlpHeaders or OTEL_EXPORTER_OTLP_HEADERSNot required by default

💡 Info: If the otlp_endpoint or OTEL_EXPORTER_OTLP_ENDPOINT is not provided, the OpenLIT SDK will output traces directly to your console, which is recommended during the development phase.

Example

Initialize using Function Arguments

Add the following two lines to your application code:

import Openlit from 'openlit';

Openlit.init({ 
  otlpEndpoint: 'YOUR_OTEL_ENDPOINT',
  otlpHeaders: 'YOUR_OTEL_ENDPOINT_AUTH'
});
Initialize using Environment Variables

Add the following two lines to your application code:

import Openlit from "openlit"

Openlit.init()

Then, configure the your OTLP endpoint using environment variable:

export OTEL_EXPORTER_OTLP_ENDPOINT = "YOUR_OTEL_ENDPOINT"
export OTEL_EXPORTER_OTLP_HEADERS = "YOUR_OTEL_ENDPOINT_AUTH"

Step 3: Visualize and Optimize!

Now that your LLM observability data is being collected and sent to configured OpenTelemetry destination, the next step is to visualize and analyze this data. This will help you understand your LLM application's performance and behavior and identify where it can be improved.

If you want to use OpenLIT's Observability Dashboard to monitor LLM usage—like cost, tokens, and user interactions—please check out our Quickstart Guide.

If you're sending metrics and traces to other observability tools, take a look at our Connections Guide to start using a pre-built dashboard we have created for these tools.

Configuration

Observability - Openlit.init()

Below is a detailed overview of the configuration options available, allowing you to adjust OpenLIT's behavior and functionality to align with your specific observability needs:

ArgumentDescriptionDefault ValueRequired
environmentThe deployment environment of the application."default"No
applicationNameIdentifies the name of your application."default"No
tracerAn instance of OpenTelemetry Tracer for tracing operations.undefinedNo
otlpEndpointSpecifies the OTLP endpoint for transmitting telemetry data.undefinedNo
otlpHeadersDefines headers for the OTLP exporter, useful for backends requiring authentication.undefinedNo
disableBatchA flag to disable batch span processing, favoring immediate dispatch.trueNo
traceContentEnables tracing of content for deeper insights.trueNo
disabledInstrumentationsList of instrumentations to disable.undefinedNo
instrumentationsObject of instrumentation modules for manual patchingundefinedNo
pricing_jsonURL or file path of the pricing JSON file.https://github.com/openlit/openlit/blob/main/assets/pricing.jsonNo

OpenLIT Prompt Hub - Openlit.getPrompt()

Below are the parameters for use with the SDK for OpenLIT Prompt Hub for prompt management:

ParameterDescription
urlSets the OpenLIT URL. Defaults to the OPENLIT_URL environment variable or http://127.0.0.1:3000 if not set.
apiKeySets the OpenLIT API Key. Can also be provided via the OPENLIT_API_KEY environment variable.
nameSets the name to fetch a unique prompt. Use this or promptId.
promptIdSets the ID to fetch a unique prompt. Use this or name. Optional
versionSets the version to retrieve a specific prompt. Optional
shouldCompileBoolean value that compiles the prompt using the provided variables. Optional
variablesSets the variables for prompt compilation. Optional
metaPropertiesSets the meta-properties for storing in the prompt's access history metadata.

OpenLIT Vault - Openlit.getSecrets()

Below are the parameters for use with the SDK for OpenLIT Vault for secret management:

ParameterDescription
urlSets the Openlit URL. Defaults to the OPENLIT_URL environment variable or http://127.0.0.1:3000 if not set.
apiKeySets the OpenLIT API Key. Can also be provided via the OPENLIT_API_KEY environment variable.
keySets the key to fetch a specific secret. Optional
tagsSets the tags for fetching only the secrets that have the mentioned tags assigned. Optional
shouldSetEnvBoolean value that sets all the secrets as environment variables for the application. Optional

OpenLIT Rule Engine - Openlit.evaluateRule()

Evaluate trace attributes against the OpenLIT Rule Engine to retrieve matching rules and associated entities (contexts, prompts, evaluation configurations).

ParameterDescription
urlSets the OpenLIT URL. Defaults to the OPENLIT_URL environment variable or http://127.0.0.1:3000.
apiKeySets the OpenLIT API Key. Can also be provided via the OPENLIT_API_KEY environment variable.
entityTypeType of entity to match: "context", "prompt", or "evaluation".
fieldsObject of trace attributes to evaluate against rules. e.g. { "gen_ai.system": "openai" }
includeEntityDataIf true, include full entity data in the response. Default: false. Optional
entityInputsOptional object of inputs for entity resolution (e.g. prompt variables).

Example

import Openlit from 'openlit';

const result = await Openlit.evaluateRule({
  entityType: 'context',
  fields: {
    'gen_ai.system': 'openai',
    'gen_ai.request.model': 'gpt-4',
    'service.name': 'my-app',
  },
  includeEntityData: true,
});

if (!('err' in result)) {
  console.log('Matching rules:', result.matchingRuleIds);
  console.log('Entities:', result.entities);
}

🌱 Contributing

Whether it's big or small, we love contributions 💚. Check out our Contribution guide to get started

Unsure where to start? Here are a few ways to get involved:

  • Join our Slack or Discord community to discuss ideas, share feedback, and connect with both our team and the wider OpenLIT community.

Your input helps us grow and improve, and we're here to support you every step of the way.

💚 Community & Support

Connect with the OpenLIT community and maintainers for support, discussions, and updates:

  • 🌟 If you like it, Leave a star on our GitHub
  • 🌍 Join our Slack or Discord community for live interactions and questions.
  • 🐞 Report bugs on our GitHub Issues to help us improve OpenLIT.
  • 𝕏 Follow us on X for the latest updates and news.

Keywords

OpenTelemetry

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts