Skip to content

Conversation

ishaan-jaff
Copy link
Contributor

@ishaan-jaff ishaan-jaff commented Oct 10, 2025

[Feat] Tag Management - Add support for setting tag based budgets

Fixes LIT-903

How It Works

1. Create Tags with Budgets

You can create tags that represent different cost centers in your organization. Each tag can have its own budget and reset period.

Example: Let's say you want to give your Engineering department a $5000/month budget:

curl -X POST 'http://0.0.0.0:4000/tag/new' \
     -H 'Authorization: Bearer sk-1234' \
     -H 'Content-Type: application/json' \
     -d '{
           "name": "engineering",
           "description": "Engineering department cost center",
           "max_budget": 5000.0,
           "budget_duration": "30d"
         }'

You can do the same for Marketing, Customer Support, or any other department.

2. Use Tags in Your Requests

Now when you make LLM requests, just include the tag in your metadata:

import openai

client = openai.OpenAI(
    api_key="sk-your-key",
    base_url="http://0.0.0.0:4000"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Write a product description"}],
    extra_body={
        "metadata": {
            "tags": ["marketing"]  # This request counts against marketing budget
        }
    }
)

3. Budget Enforcement

When the tag hits its budget limit, requests with that tag will be automatically rejected:

{
  "error": {
    "message": "Budget has been exceeded! Tag=marketing Current cost: 2005.50, Max budget: 2000.0",
    "type": "budget_exceeded",
    "code": "400"
  }
}

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
✅ Test

Changes

Copy link

vercel bot commented Oct 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Oct 11, 2025 2:24am

@ishaan-jaff ishaan-jaff merged commit 527c8f5 into main Oct 11, 2025
11 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant