diff --git a/docs/my-website/docs/observability/openmeter.md b/docs/my-website/docs/observability/openmeter.md new file mode 100644 index 00000000000..64d9c39d215 --- /dev/null +++ b/docs/my-website/docs/observability/openmeter.md @@ -0,0 +1,97 @@ +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# OpenMeter - Usage-Based Billing + +[OpenMeter](https://openmeter.io/) is an Open Source Usage-Based Billing solution for AI/Cloud applications. It integrates with Stripe for easy billing. + + + +:::info +We want to learn how we can make the callbacks better! Meet the LiteLLM [founders](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version) or +join our [discord](https://discord.gg/wuPM9dRgDw) +::: + + +## Quick Start +Use just 2 lines of code, to instantly log your responses **across all providers** with OpenMeter + +Get your OpenMeter API Key from https://openmeter.cloud/meters + +```python +litellm.success_callback = ["openmeter"] # logs cost + usage of successful calls to openmeter +``` + + + + + +```python +# pip install langfuse +import litellm +import os + +# from https://openmeter.cloud +os.environ["OPENMETER_API_ENDPOINT"] = "" +os.environ["OPENMETER_API_KEY"] = "" + +# LLM API Keys +os.environ['OPENAI_API_KEY']="" + +# set langfuse as a callback, litellm will send the data to langfuse +litellm.success_callback = ["openmeter"] + +# openai call +response = litellm.completion( + model="gpt-3.5-turbo", + messages=[ + {"role": "user", "content": "Hi 👋 - i'm openai"} + ] +) +``` + + + + +1. Add to Config.yaml +```yaml +model_list: +- litellm_params: + api_base: https://openai-function-calling-workers.tasslexyz.workers.dev/ + api_key: my-fake-key + model: openai/my-fake-model + model_name: fake-openai-endpoint + +litellm_settings: + success_callback: ["openmeter"] # 👈 KEY CHANGE +``` + +2. Start Proxy + +``` +litellm --config /path/to/config.yaml +``` + +3. Test it! + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--data ' { + "model": "fake-openai-endpoint", + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ], + } +' +``` + + + + + + \ No newline at end of file diff --git a/docs/my-website/docs/proxy/logging.md b/docs/my-website/docs/proxy/logging.md index 60a5d060a59..81c27e7e13c 100644 --- a/docs/my-website/docs/proxy/logging.md +++ b/docs/my-website/docs/proxy/logging.md @@ -10,6 +10,7 @@ Log Proxy Input, Output, Exceptions using Custom Callbacks, Langfuse, OpenTeleme - [Async Custom Callbacks](#custom-callback-class-async) - [Async Custom Callback APIs](#custom-callback-apis-async) - [Logging to Langfuse](#logging-proxy-inputoutput---langfuse) +- [Logging to OpenMeter](#logging-proxy-inputoutput---langfuse) - [Logging to s3 Buckets](#logging-proxy-inputoutput---s3-buckets) - [Logging to DataDog](#logging-proxy-inputoutput---datadog) - [Logging to DynamoDB](#logging-proxy-inputoutput---dynamodb) @@ -591,6 +592,59 @@ litellm_settings: +## Logging Proxy Cost + Usage - OpenMeter + +Bill customers according to their LLM API usage with [OpenMeter](../observability/openmeter.md) + +**Required Env Variables** + +```bash +# from https://openmeter.cloud +export OPENMETER_API_ENDPOINT="" +export OPENMETER_API_KEY="" +``` + +### Quick Start + +1. Add to Config.yaml +```yaml +model_list: +- litellm_params: + api_base: https://openai-function-calling-workers.tasslexyz.workers.dev/ + api_key: my-fake-key + model: openai/my-fake-model + model_name: fake-openai-endpoint + +litellm_settings: + success_callback: ["openmeter"] # 👈 KEY CHANGE +``` + +2. Start Proxy + +``` +litellm --config /path/to/config.yaml +``` + +3. Test it! + +```bash +curl --location 'http://0.0.0.0:4000/chat/completions' \ +--header 'Content-Type: application/json' \ +--data ' { + "model": "fake-openai-endpoint", + "messages": [ + { + "role": "user", + "content": "what llm are you" + } + ], + } +' +``` + + + + ## Logging Proxy Input/Output - DataDog We will use the `--config` to set `litellm.success_callback = ["datadog"]` this will log all successfull LLM calls to DataDog diff --git a/docs/my-website/img/openmeter.png b/docs/my-website/img/openmeter.png new file mode 100644 index 00000000000..29fa9655732 Binary files /dev/null and b/docs/my-website/img/openmeter.png differ diff --git a/docs/my-website/img/openmeter_img_2.png b/docs/my-website/img/openmeter_img_2.png new file mode 100644 index 00000000000..e96edc2e49e Binary files /dev/null and b/docs/my-website/img/openmeter_img_2.png differ diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index e4f4e806e1c..ef2ddb57e5f 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -170,6 +170,7 @@ const sidebars = { "observability/custom_callback", "observability/langfuse_integration", "observability/sentry", + "observability/openmeter", "observability/promptlayer_integration", "observability/wandb_integration", "observability/langsmith_integration", @@ -177,7 +178,6 @@ const sidebars = { "observability/traceloop_integration", "observability/athina_integration", "observability/lunary_integration", - "observability/athina_integration", "observability/helicone_integration", "observability/supabase_integration", `observability/telemetry`,