Filter function for Open WebUI, which displays stats and cost tracking when using OpenRouter connection
""" title: OpenRouter Stats & Cost tracking author: Hristo Karamanliev author_url: https://github.com/karamanliev version: 1.1.0 """ import logging import time from typing import Dict, Optional, Callable import requests from pydantic import BaseModel, Field
Filter function for Open WebUI, which displays stats and cost tracking when using OpenRouter connection.
Utilizes usage accounting which OpenRouter enables after sending the updated user input. This makes it possible to report the exact cost and remaining credit as shown on the activity page on the OpenRouter dashboard.
Don't forget to enable the function globally after enabling it!
We use optional analytics to improve our websites, and advertising cookies on this site. Privacy Policy.