Privacy-Preserving University Chatbot with LiteLLM Proxy for Multi-Model Governance and Cost Control

unnamed_private_university · Education · 2025 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: University LLM gateway governance and cost control

A private university needed a privacy-preserving chatbot for students and employees that could swap models, potentially self-host models later, distribute API access to courses, enforce budgets, and handle provider capacity limits without locking applications to one LLM provider.

Constraints:

Architecture

The implementation uses LiteLLM's proxy server as an OpenAI-compatible gateway between university applications and multiple model providers. The proxy is deployed from a Docker image with a mounted YAML configuration defining model names, provider credentials, and routing rules. PostgreSQL enables spend logging and budget enforcement by user/team, Redis supports load-balancing strategies across model deployments, the admin UI supports non-technical budget administration, and application code can keep using direct HTTP calls or the OpenAI client against a custom base URL.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  university-chat-application["University chat application"] --> litellm-proxy["LiteLLM proxy"]
  litellm-proxy["LiteLLM proxy"] --> university-chat-application["University chat application"]
  litellm-proxy["LiteLLM proxy"] --> model-configuration["Model configuration"]
  model-configuration["Model configuration"] --> litellm-proxy["LiteLLM proxy"]
  litellm-proxy["LiteLLM proxy"] --> postgresql-budget-database["PostgreSQL budget database"]
  postgresql-budget-database["PostgreSQL budget database"] --> litellm-proxy["LiteLLM proxy"]
  litellm-proxy["LiteLLM proxy"] --> redis-routing-cache["Redis routing cache"]
  redis-routing-cache["Redis routing cache"] --> litellm-proxy["LiteLLM proxy"]
  litellm-proxy["LiteLLM proxy"] --> model-provider-deployments["Model provider deployments"]
  model-provider-deployments["Model provider deployments"] --> litellm-proxy["LiteLLM proxy"]
  litellm-proxy["LiteLLM proxy"] --> admin-user-interface["Admin user interface"]
  admin-user-interface["Admin user interface"] --> litellm-proxy["LiteLLM proxy"]
  admin-user-interface["Admin user interface"] --> postgresql-budget-database["PostgreSQL budget database"]
  postgresql-budget-database["PostgreSQL budget database"] --> admin-user-interface["Admin user interface"]
  litellm-proxy["LiteLLM proxy"] --> observability-integrations["Observability integrations"]
  observability-integrations["Observability integrations"] --> litellm-proxy["LiteLLM proxy"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
University chat application Student and employee-facing chatbot that sends model requests and user identifiers to the gateway. LiteLLM proxy
LiteLLM proxy OpenAI-compatible gateway that issues API keys, abstracts providers, enforces budgets, routes requests, and exposes administration features. University chat application, Model configuration, PostgreSQL budget database, Redis routing cache, Model provider deployments, Admin user interface, Observability integrations
Model configuration Mounted YAML configuration file defining model mappings, provider URLs/keys, model information, routing limits, and Redis settings. LiteLLM proxy
PostgreSQL budget database Database used by LiteLLM to persist user/team spend and support budgeting features. LiteLLM proxy, Admin user interface
Redis routing cache State store needed by LiteLLM routing strategies for load balancing across model instances. LiteLLM proxy
Model provider deployments Underlying OpenAI, Azure, or other LLM provider endpoints, including duplicate deployments and fallback models. LiteLLM proxy
Admin user interface Proxy-provided UI for creating budgets, managing teams and members, and monitoring spend. LiteLLM proxy, PostgreSQL budget database
Observability integrations Optional integrations such as Langfuse, MLflow, and OpenTelemetry that receive centralized request information from the proxy. LiteLLM proxy

Data flow

A student or employee sends a chat request through the university application. The app calls the LiteLLM proxy, either directly over HTTP or through an OpenAI-compatible client pointed at the proxy URL. LiteLLM maps the requested model to the provider configuration, checks user/team budget state in PostgreSQL, calculates cost from model token pricing, and routes the request to an available provider deployment. If a primary model is rate-limited, router settings and Redis state can distribute traffic across multiple deployments or fall back to another model.

3 supporting quotes
“a proxy um which is basically a server an open AAI compatible server uh which sits between your application and different model providers”transcript, stated
“we just need to deploy a possql database uh and connect this database with light LLM and then the cost to automatically get saved into the database.”transcript, stated
“routter settings. So there are some kind of algorithms um they use to um direct our requests uh to each of these models”transcript, stated

Why this architecture

The proxy architecture was chosen because it gave the university model flexibility, API-key distribution, OpenAI-client compatibility, governance features, and future self-hosting options without changing every downstream application when providers or models change.

3 supporting quotes
“the proxy rather provides more flexibility for future requirements. So let's go with that one for the moment.”transcript, stated
“we could easily give them an API key to our server and they can use this in all kind of applications or libraries which allows for a custom open AI URL.”transcript, stated
“The second option would be to use the open AAI library directly as it is open AAI compatible.”transcript, stated

Models used: GPT-4.1 · DALL-E 3 · GPT-5 · Gemma 3 · GPT OSS

Scale

Alternatives considered (roads not taken)

Use LiteLLM as only a Python library

Rejected because: The proxy provided more flexibility for API keys, future requirements, and OpenAI-compatible access by many applications.

“light LLM provides generally provides two options uh a Python library and a proxy server.”transcript, stated
“the proxy rather provides more flexibility for future requirements. So let's go with that one for the moment.”transcript, stated

Implement all provider-specific API handling in the chat application

Rejected because: The proxy abstracts different providers behind an OpenAI-compatible server and lets existing OpenAI-based tooling continue to work.

“an open AAI compatible server uh which sits between your application and different model providers”transcript, stated
“I can uh use this open AAI client and over my API key and the URL and then I'm ready to go with all the open AI uh kind of features and methods.”transcript, stated

Rely entirely on LiteLLM built-in budgeting for complex university requirements

Rejected because: Specific requirements such as per-message cost education and temporary budget increases for user subsets were not available out of the box.

“that's something actually which is not available out of the box as light LLM does not allow us to send any custom meter data”transcript, stated
“again that's something which is not available out of the box but of course we could implement our own process around that.”transcript, stated

Use LiteLLM when there is only one provider and no governance need

Rejected because: The speaker says the tool is most useful for multiple providers, models, and governance needs like cost control.

“I think it's really great if you need multiple providers, multiple um models um and have these kind of governance needs like like the cost control for example.”transcript, stated
“you don't need light lm if you use one provider only or do not have any uh government's requirement.”transcript, stated

Patterns

model-routing (gateway)

LiteLLM routes requests through a central proxy to multiple model providers and can distribute traffic across duplicate model deployments.

“a server an open AAI compatible server uh which sits between your application and different model providers”transcript, stated
“we can also deploy the same model uh different times and then you see here there is like a TPM and RPM with numbers”transcript, stated

cost-aware-routing (governance)

The proxy calculates cost from model token prices, records it by user/team, checks budgets, and returns budget-exceeded errors when limits are reached.

“costs for this user are automatically calculated or for this call are automatically calculated during the request and then in the background the costs are assigned to this user”transcript, stated
“light LLM automatically checks if the budget is already exceeded for this user or not and if it is exceeded it just result in a budget exceeded error.”transcript, stated

fallback-degradation (reliability)

The configuration can route to duplicate deployments and then a fallback model if capacity is exceeded.

“we could also use some kind of fallback model if all of that uh still exceeds the cap capities at any moment.”transcript, stated
“so that we then route our requests um further to a fallback model.”transcript, stated

observability-tracing (operations)

Centralizing requests in LiteLLM enables one proxy configuration to send request information to observability tools.

“they have a lot of LLM observability tools which you can also use in other cases like langu mlflow open telemetry”transcript, stated
“with one call to light LLM you also have all the information available in these other external integrations.”transcript, stated

privacy-preserving-processing (governance)

The architecture was selected for a privacy-preserving university chatbot and future self-hosting option, keeping model/provider choices under institutional control.

“their own privacy preserving chatbot um and make it accessible for both students and employees.”transcript, stated
“it may make sense that we are also able to self-host uh our own models um if we decide so in the future.”transcript, stated

latency-optimization (performance)

The team explicitly considered proxy latency and accepted the observed roughly 200ms overhead for this use case.

“light ll M actually does add some latency and more latency than other other libraries do.”transcript, stated
“in my use cases, this this was not a problem. I don't know, I had like 200 milliseconds more of a latency um in the setup.”transcript, stated

Tradeoffs

Use a proxy server as the central gateway.

Chose LiteLLM proxy server over Only the LiteLLM Python library or direct provider clients.

Rationale: The proxy supported OpenAI compatibility, API-key distribution, centralized governance, and future flexibility.

“the proxy rather provides more flexibility for future requirements. So let's go with that one for the moment.”transcript, stated
“it's it can also issue API keys for you”transcript, stated

Accept a proxy abstraction to simplify multi-provider governance.

Chose Unified LiteLLM API gateway over Application-specific integrations for each provider.

Rationale: The abstraction reduces provider complexity and centralizes governance, but may hide provider-specific capabilities.

“with every project with every library you do have some kind of abstraction layer and that may be nice because you don't need to handle all the complexity on your own.”transcript, stated
“it may also mean that in some points you don't get all the provider specifics you may need in your certain project”transcript, stated

Use built-in LiteLLM budgeting for basic cost control while accepting custom work for advanced requirements.

Chose Built-in team/user budgets plus custom processes where needed over Building all cost governance from scratch.

Rationale: LiteLLM handled automatic spend calculation and budget errors, but custom education and temporary-budget features required additional implementation.

“that actually works quite good out of the box to provide this basic cost control thing.”transcript, stated
“if you get super specific customer requirements on all this budgeting and cost handling stuff um light LLM may not fulfill all your requirements”transcript, stated

Add Redis-backed routing and fallback models for capacity.

Chose LiteLLM routing strategies, duplicate model deployments, Redis state, and fallback models over Only retrying failed requests in the chat application.

Rationale: Retries alone could not handle too many simultaneous users when model capacity was exhausted.

“if the capacity of the GPT5 model is exceeded, we do get back some rate limit errors which we can handle of course in our chat applications by using some kind of retry logic.”transcript, stated
“we decide we could um deploy a second model somewhere else so that we have like maybe this capacity doubled.”transcript, stated

Consider alternatives such as OpenRouter or TensorZero before committing to LiteLLM.

Chose Evaluate the gateway landscape for current project requirements over Assuming LiteLLM is always the best choice.

Rationale: The speaker notes that similar API gateway and budgeting capabilities are now implemented in other projects too.

“this uh unified API kind of API gateway for different models and budgeting is uh also implemented now in other projects like open rout or tensor zero.”transcript, stated
“before considering light lm you might also want to have a look into these alternatives as well.”transcript, stated

Gotchas (what bit them)

LiteLLM's basic budget controls did not cover detailed educational cost attribution.

Root cause: The proxy did not allow custom metadata to be sent and stored with requests in the way the university needed.

Resolution: The suggested workaround was to capture cost information returned in response headers and implement a separate process around it.

“light LLM does not allow us to send any custom meter data to to this request uh interfaces and so also these kind of things are not saved”transcript, stated
“a potential workaround would be using the cost information we get back in request headers and uh implement our own process around that.”transcript, stated

Temporary budget increases for subsets of users were not supported in the needed form.

Root cause: The enterprise feature existed for API keys but not for individual users or teams in this implementation.

Resolution: The team would need to implement budgeting outside LiteLLM, wrap calls in custom budget checks, or contribute the feature upstream.

“light LLM has something like that exactly um for API keys in their enterprise version but not for individual users or teams um which we would need in this case.”transcript, stated
“take out all this budgeting stuff from light LLM handle that on our own and then somehow wrap the light LLM calls into our own budget check”transcript, stated

Pricing calculations can drift unless the proxy is updated regularly.

Root cause: Model pricing is maintained inside LiteLLM's internal model-spec data, so deployed images need updates to pick up price changes.

Resolution: The team must regularly deploy new Docker image versions to keep pricing data current.

“we do not need to deal with the pricing updates on our own. Yeah. because like we may host a lot of different models in the future”transcript, stated
“we regularly need to update our proxy server um thus deploy a new docker image version otherwise we do not get the updates the prices in as well.”transcript, stated

The abstraction layer can block provider-specific features and brand-new models.

Root cause: LiteLLM has to implement provider-specific capabilities and new model support before users can access them through the proxy.

Resolution: Teams should be cautious when they need many provider-specific features or immediate access to new models.

“you don't get all the provider specifics you may need in your certain project as they did not implement this into light LLM yet.”transcript, stated
“if you want to use them through light LLM, you first have to wait until they uh integrated these models into the library.”transcript, stated

Fast-moving features were sometimes buggy in production.

Root cause: LiteLLM developed many new features quickly, but some existing or new features did not work as expected.

Resolution: Production teams may need capacity to fix, patch, contribute, or run their own Docker image.

“already existing features were kind of buggy. Um, and so when you wanted to use them in production, you needed to to fix them first”transcript, stated
“if you do not have the time or the capability to contribute to light LLM on your own to fix things or maybe temporarily patch um your own version”transcript, stated

Evaluation

The case evaluates LiteLLM through production use in a university chatbot: whether it can support OpenAI-compatible access, budget enforcement, admin workflows, custom requirements, load balancing, routing, observability integrations, and acceptable latency.

Metrics: Budget-exceeded checks by user/team · Spend by model/provider in the admin UI · TPM and RPM capacity limits for model deployments · Approximately 200ms added proxy latency in this setup · Observed rate-limit errors under concurrent use

4 supporting quotes
“light LLM automatically checks if the budget is already exceeded for this user or not and if it is exceeded it just result in a budget exceeded error.”transcript, stated
“upper right you see the spend over different models and on the down um side the pro spent by different provider”transcript, stated
“TPM means tokens per minute and RPM requests per minute. So that's these are actually the limits these two models can take”transcript, stated
“I don't know, I had like 200 milliseconds more of a latency um in the setup.”transcript, stated

Outcomes

The system covered students and employees, began with two teams, used TPM/RPM capacity settings for duplicate deployments, and accepted roughly 200ms of additional proxy latency.

4 supporting quotes
“we now have a working chat applications but some basic budget control so that we don't uh exceed our budgets which are set anymore.”transcript, stated
“we can also deploy the same model uh different times and then you see here there is like a TPM and RPM with numbers”transcript, stated
“I presented some of the pitfalls um I encountered while using light LLM in production”transcript, stated
“it's really great if you need multiple providers, multiple um models um and have these kind of governance needs like like the cost control for example.”transcript, stated