Budget Example Manifests

These examples are in the budgets/ folder of the example manifests repository, except for the Stackademy project budget, which is in the smarter-sh/stackademy repository with the rest of the Stackademy example project. Apply one with smarter apply -f <file>. Only superusers may apply a Budget.

Each example is detached: its spec.resources is empty, resources: [], and the resources that it could be attached to are shown above it as a commented-out example. Uncomment them, or list your own, to attach it. manage.py initialize_platform creates a built-in budget from each of the examples, with manage.py load_from_github, so they enforce nothing until a superuser attaches them. A detached budget is created once: one that already exists is left as it is, so a superuser’s attachments and changes survive the next initialization. The Stackademy project budget is different: initialize_platform applies it, as the Smarter admin, with the rest of the Stackademy repository, so it is attached to the Smarter account’s stackademy_sql LLMClient and SqlPlugin.

Overview

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: student_monthly_allowance
 5  description: Each student may spend $10 a month on AI, and $100 in total.
 6  version: 1.0.0
 7  tags:
 8    - education
 9  annotations:
10    - smarter.sh/budget/purpose: example
11spec:
12  config:
13    unit: cost # cost, in USD, or tokens
14    period: month # hour, day, week or month
15    periodicLimit: 10.00 # the most that may be spent in a billing period. 0 means no limit.
16    absoluteLimit: 100.00 # the most that may be spent in total. 0 means no limit.
17    duration: 0 # billing periods after which the budget no longer applies. 0 means never.
18    action: block # block further charges, or warn only
19    warningThreshold: 80 # the percentage of a limit at which a warning is sent. 0 means never.
20    message: You have used this month's AI allowance. It renews on the 1st of next month.
21  resources:
22    - kind: User
23      name: student1
24    - kind: User
25      name: student2
26    - kind: LLMClient
27      name: stackademy_sql
28      accountNumber: "3141-5926-5359" # optional. Defaults to your own account.
29    - recordLocator: provider-rc2x # any resource, by its record locator

Per-user monthly allowance

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: student_monthly_allowance
 5  description: |
 6    An example Budget manifest: a per-user allowance. Each student may spend $10 a month on AI,
 7    and $100 in total. When a student reaches a limit, their chat is answered with the message
 8    below until the limit renews, or the budget is raised.
 9    It is detached: it enforces nothing until a superuser attaches it to its students.
10  version: 1.0.0
11  tags:
12    - example
13    - education
14    - user
15  annotations:
16    smarter.sh/budget/purpose: per-user allowance
17spec:
18  config:
19    unit: cost
20    period: month
21    periodicLimit: 10.00
22    absoluteLimit: 100.00
23    duration: 0
24    action: block
25    warningThreshold: 80
26    message: You have used this month's AI allowance. It renews on the 1st of next month.
27  # Detached: it enforces nothing until a superuser attaches it. For example:
28  # resources:
29  #   - kind: User
30  #     name: student1
31  #   - kind: User
32  #     name: student2
33  resources: []

From budgets/student-monthly-allowance.yaml in the example manifests repository.

Per-user hourly token throttle

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: user_hourly_token_throttle
 5  description: |
 6    An example Budget manifest: throttling individual users. Each user may use 50,000 tokens an
 7    hour, whatever the tokens cost. A budget that measures tokens works without LLMPrices.
 8    It is detached: it enforces nothing until a superuser attaches it to its users.
 9  version: 1.0.0
10  tags:
11    - example
12    - throttle
13    - user
14  annotations:
15    smarter.sh/budget/purpose: per-user throttle
16spec:
17  config:
18    unit: tokens
19    period: hour
20    periodicLimit: 50000
21    absoluteLimit: 0
22    duration: 0
23    action: block
24    warningThreshold: 0
25    message: You are sending requests faster than your plan allows. Please try again next hour.
26  # Detached: it enforces nothing until a superuser attaches it. For example:
27  # resources:
28  #   - kind: User
29  #     name: student1
30  #   - kind: User
31  #     name: student2
32  resources: []

From budgets/user-hourly-token-throttle.yaml in the example manifests repository.

Organizational monthly cost constraint

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: account_monthly_cap
 5  description: |
 6    An example Budget manifest: an organization's monthly cost constraint. Everything that is
 7    charged to the account, LLM prompts, Proxy requests and LLMHost compute alike, counts
 8    towards $1,000 a month.
 9    It is detached: it enforces nothing until a superuser attaches it to the platform's demo account.
10  version: 1.0.0
11  tags:
12    - example
13    - account
14  annotations:
15    smarter.sh/budget/purpose: organizational monthly cost constraint
16spec:
17  config:
18    unit: cost
19    period: month
20    periodicLimit: 1000.00
21    absoluteLimit: 0
22    duration: 0
23    action: block
24    warningThreshold: 75
25    message: Your organization has reached its monthly AI budget. Please contact your account administrator.
26  # Detached: it enforces nothing until a superuser attaches it. For example:
27  # resources:
28  #   - kind: Account
29  #     name: "3141-5926-5359"
30  resources: []

From budgets/account-monthly-cap.yaml in the example manifests repository.

Project budget

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: stackademy_project
 5  description: |
 6    An example Budget manifest: a project budget. The Stackademy LLMClient and its SQL plugin may
 7    spend $10,000 over the six months of the project, and no more than $2,500 in any one month.
 8    After six months the budget no longer applies.
 9  version: 1.0.0
10  tags:
11    - example
12    - project
13  annotations:
14    - smarter.sh/budget/purpose: project budget
15spec:
16  config:
17    unit: cost
18    period: month
19    periodicLimit: 2500.00
20    absoluteLimit: 10000.00
21    duration: 6
22    action: block
23    warningThreshold: 80
24    message: The Stackademy project has used its budget. Please contact the project owner.
25  resources:
26    - kind: LLMClient
27      name: stackademy_sql
28    - kind: SqlPlugin
29      name: stackademy_sql

From budgets/stackademy-project.yaml in the Stackademy example project.

Provider daily budget

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: openai_daily
 5  description: |
 6    An example Budget manifest: a provider budget. Prompts sent to OpenAI, through LLMClients or
 7    the openai Proxy, may cost $200 a day. Cost is priced with LLMPrices, in USD per million tokens.
 8    It is detached: it enforces nothing until a superuser attaches it to the openai Provider.
 9  version: 1.0.0
10  tags:
11    - example
12    - provider
13  annotations:
14    smarter.sh/budget/purpose: provider budget
15spec:
16  config:
17    unit: cost
18    period: day
19    periodicLimit: 200.00
20    absoluteLimit: 0
21    duration: 0
22    action: block
23    warningThreshold: 90
24    message: OpenAI has reached today's spending limit. It renews at midnight UTC.
25  # Detached: it enforces nothing until a superuser attaches it. For example:
26  # resources:
27  #   - kind: Provider
28  #     name: openai
29  resources: []

From budgets/provider-daily.yaml in the example manifests repository.

LLMHost compute budget

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: gpu_l4_monthly
 5  description: |
 6    An example Budget manifest: an infrastructure budget. The nodes of the gpu_l4_1x LLMHostCompute
 7    are charged hourly, at its price per hour. When they have cost $500 in a month, no more
 8    LLMHosts are launched on it until the next month. Nodes that are already running are not removed.
 9    It is detached: it enforces nothing until a superuser attaches it to the gpu_l4_1x LLMHostCompute.
10  version: 1.0.0
11  tags:
12    - example
13    - llmhost
14    - compute
15  annotations:
16    smarter.sh/budget/purpose: infrastructure budget
17spec:
18  config:
19    unit: cost
20    period: month
21    periodicLimit: 500.00
22    absoluteLimit: 0
23    duration: 0
24    action: block
25    warningThreshold: 80
26    message: The gpu_l4_1x compute has used this month's budget.
27  # Detached: it enforces nothing until a superuser attaches it. For example:
28  # resources:
29  #   - kind: LLMHostCompute
30  #     name: gpu_l4_1x
31  resources: []

From budgets/llmhost-compute.yaml in the example manifests repository.

Spending alerts only

 1apiVersion: smarter.sh/v1
 2kind: Budget
 3metadata:
 4  name: openai_proxy_weekly_watch
 5  description: |
 6    An example Budget manifest: a budget that only warns. Requests through the openai Proxy are
 7    never refused, but the budget_warning and budget_exceeded signals are sent when its spending
 8    reaches $50, and then $100, in a week, e.g. to notify an administrator.
 9    It is detached: it enforces nothing until a superuser attaches it to the openai Proxy.
10  version: 1.0.0
11  tags:
12    - example
13    - proxy
14    - monitoring
15  annotations:
16    smarter.sh/budget/purpose: spending alerts
17spec:
18  config:
19    unit: cost
20    period: week
21    periodicLimit: 100.00
22    absoluteLimit: 0
23    duration: 0
24    action: warn
25    warningThreshold: 50
26  # Detached: it enforces nothing until a superuser attaches it. For example:
27  # resources:
28  #   - kind: Proxy
29  #     name: openai
30  resources: []

From budgets/proxy-warn-only.yaml in the example manifests repository.