Budget Example Manifests
These examples are in smarter/apps/account/data/example-manifests/budgets/. Apply one with
smarter apply -f <file>. Only superusers may apply a Budget.
manage.py initialize_platform creates a built-in budget from each of them, with
manage.py add_builtin_budgets. Built-in budgets are created detached: their spec.resources
is ignored, so they enforce nothing until a superuser attaches them. A budget that already
exists is left as it is.
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 version: 1.0.0
10 tags:
11 - example
12 - education
13 - user
14 annotations:
15 - smarter.sh/budget/purpose: per-user allowance
16spec:
17 config:
18 unit: cost
19 period: month
20 periodicLimit: 10.00
21 absoluteLimit: 100.00
22 duration: 0
23 action: block
24 warningThreshold: 80
25 message: You have used this month's AI allowance. It renews on the 1st of next month.
26 resources:
27 - kind: User
28 name: student1
29 - kind: User
30 name: student2
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 version: 1.0.0
9 tags:
10 - example
11 - throttle
12 - user
13 annotations:
14 - smarter.sh/budget/purpose: per-user throttle
15spec:
16 config:
17 unit: tokens
18 period: hour
19 periodicLimit: 50000
20 absoluteLimit: 0
21 duration: 0
22 action: block
23 warningThreshold: 0
24 message: You are sending requests faster than your plan allows. Please try again next hour.
25 resources:
26 - kind: User
27 name: student1
28 - kind: User
29 name: student2
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 version: 1.0.0
10 tags:
11 - example
12 - account
13 annotations:
14 - smarter.sh/budget/purpose: organizational monthly cost constraint
15spec:
16 config:
17 unit: cost
18 period: month
19 periodicLimit: 1000.00
20 absoluteLimit: 0
21 duration: 0
22 action: block
23 warningThreshold: 75
24 message: Your organization has reached its monthly AI budget. Please contact your account administrator.
25 resources:
26 - kind: Account
27 name: "3141-5926-5359"
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
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 version: 1.0.0
9 tags:
10 - example
11 - provider
12 annotations:
13 - smarter.sh/budget/purpose: provider budget
14spec:
15 config:
16 unit: cost
17 period: day
18 periodicLimit: 200.00
19 absoluteLimit: 0
20 duration: 0
21 action: block
22 warningThreshold: 90
23 message: OpenAI has reached today's spending limit. It renews at midnight UTC.
24 resources:
25 - kind: Provider
26 name: openai
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 version: 1.0.0
10 tags:
11 - example
12 - llmhost
13 - compute
14 annotations:
15 - smarter.sh/budget/purpose: infrastructure budget
16spec:
17 config:
18 unit: cost
19 period: month
20 periodicLimit: 500.00
21 absoluteLimit: 0
22 duration: 0
23 action: block
24 warningThreshold: 80
25 message: The gpu_l4_1x compute has used this month's budget.
26 resources:
27 - kind: LLMHostCompute
28 name: gpu_l4_1x
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 version: 1.0.0
10 tags:
11 - example
12 - proxy
13 - monitoring
14 annotations:
15 - smarter.sh/budget/purpose: spending alerts
16spec:
17 config:
18 unit: cost
19 period: week
20 periodicLimit: 100.00
21 absoluteLimit: 0
22 duration: 0
23 action: warn
24 warningThreshold: 50
25 resources:
26 - kind: Proxy
27 name: openai