npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

openlit

v1.3.1

Published

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

Downloads

214

Readme

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 30+ LLM providers and vector databases 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.
  • 🚀 Suppport for OpenLIT Features: Includes suppprt for prompt management and secrets management features available in OpenLIT.

Auto Instrumentation Capabilities

| LLMs | | --------------------------------------------------------------------- | | ✅ OpenAI | ✅ ChromaDB | ✅ LiteLLM | | | ✅ Anthropic | | ✅ Cohere |

Supported Destinations

💿 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:

| Purpose | Parameter/Environment Variable | For Sending to OpenLIT | |-------------------------------------------|--------------------------------------------------|--------------------------------| | Send data to an HTTP OTLP endpoint | otlpEndpoint or OTEL_EXPORTER_OTLP_ENDPOINT | "http://127.0.0.1:4318" | | Authenticate telemetry backends | otlpHeaders or OTEL_EXPORTER_OTLP_HEADERS | Not 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



Add the following two lines to your application code:

import Openlit from 'openlit';

Openlit.init({ 
  otlpEndpoint: 'YOUR_OTEL_ENDPOINT',
  otlpHeaders: 'YOUR_OTEL_ENDPOINT_AUTH'
});


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:

| Argument | Description | Default Value | Required | | ------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------ | -------- | | environment | The deployment environment of the application. | "default" | No | | applicationName | Identifies the name of your application. | "default" | No | | tracer | An instance of OpenTelemetry Tracer for tracing operations. | undefined | No | | otlpEndpoint | Specifies the OTLP endpoint for transmitting telemetry data. | undefined | No | | otlpHeaders | Defines headers for the OTLP exporter, useful for backends requiring authentication. | undefined | No | | disableBatch | A flag to disable batch span processing, favoring immediate dispatch. | true | No | | traceContent | Enables tracing of content for deeper insights. | true | No | | disabledInstrumentations | List of instrumentations to disable. | undefined | No | | instrumentations | Object of instrumentation modules for manual patching | undefined | No | | pricing_json | URL or file path of the pricing JSON file. | https://github.com/openlit/openlit/blob/main/assets/pricing.json | No |

OpenLIT Prompt Hub - Openlit.getPrompt()

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

| Parameter | Description | |------------------|------------------------------------------------------------------------------------------------------------------------------------| | url | Sets the OpenLIT URL. Defaults to the OPENLIT_URL environment variable or http://127.0.0.1:3000 if not set. | | apiKey | Sets the OpenLIT API Key. Can also be provided via the OPENLIT_API_KEY environment variable. | | name | Sets the name to fetch a unique prompt. Use this or promptId. | | promptId | Sets the ID to fetch a unique prompt. Use this or name. Optional | | version | Sets the version to retrieve a specific prompt. Optional | | shouldCompile | Boolean value that compiles the prompt using the provided variables. Optional | | variables | Sets the variables for prompt compilation. Optional | | metaProperties | Sets 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:

| Parameter | Description | |------------------|------------------------------------------------------------------------------------------------------------------------------------| | url | Sets the Openlit URL. Defaults to the OPENLIT_URL environment variable or http://127.0.0.1:3000 if not set. | | apiKey | Sets the OpenLIT API Key. Can also be provided via the OPENLIT_API_KEY environment variable. | | key | Sets the key to fetch a specific secret. Optional | | tags | Sets the tags for fetching only the secrets that have the mentioned tags assigned. Optional | | shouldSetEnv | Boolean value that sets all the secrets as environment variables for the application. Optional |

🌱 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.