Why LiteLLM service account keys for production applications belong on the gateway
Production applications that call models through a shared LiteLLM gateway should authenticate with service account keys issued to the application and its team, not with keys tied to an individual engineer. When a key belongs to a person, every outage, rotation or budget change depends on that person still being employed and still holding the right role. A service account key keeps access attached to the team that owns the application, so the workload keeps running when staff move on. Per the LiteLLM service accounts docs, these keys always have a null user_id, require a team_id, apply only team-level limits, and are not deleted when a user is deleted.
Those four properties shape how a team uses the feature. Because the key has no user, spend and audit records point to the team and the application rather than a person, which is usually what finance and security reviewers ask for. Because only team limits apply, budgets and rate limits must be set on the team that owns the key, so a team planning several applications should confirm how it will split its budget and TPM and RPM limits across them. Because a team_id is mandatory, the team structure must exist before the key is created. Teams that build internal tools, batch jobs or customer-facing backends on the gateway are the usual candidates. Personal experiments and developer laptops generally belong on user keys.
Before rollout, confirm with your own gateway configuration how the key is created, stored and rotated, and where its secret is kept. Check that your LiteLLM version supports service account keys as described in the current docs, since the feature set changes between releases. Then decide which team owns each production key and who holds administrative rights over that team. The key itself is only half the control. The team's model access, limits and logging determine what a leaked or misused key can do, so those settings should be reviewed together with the key.
How service account keys compare with user keys
This table compares LiteLLM service account keys with user-owned keys on ownership, team requirements, applicable limits, deletion behavior and suitable workloads. Read each row against your own LiteLLM version and configuration, since user key behavior depends on settings you must confirm. The main takeaway is that service account keys are built to outlive individual staff, while user keys stay tied to a person.
| Attribute | Service account key | User key |
|---|---|---|
| Owner | No user; user_id is always null | Tied to a specific user_id |
| Team requirement | team_id is required | Confirm whether team assignment is required in your configuration |
| Limits applied | Team limits only | Confirm whether key-level and user-level budgets and limits apply in your version |
| When the owning person is deleted | Key is not deleted with a user, because it has no user | Confirm in your version whether the key is deleted, disabled or kept when the user is removed |
| Survives staff changes | Yes, by design | Depends on your offboarding process and deletion behavior |
| Best fit | Production applications and shared services | Interactive use by an individual, such as developer testing |
| Audit attribution | Attributed to the service account and its team | Attributed to the person; confirm how logs show the key owner |
How team-only limits shape budgets for production applications
Because a service account key only applies team limits, the spend, TPM and RPM ceilings that govern it are set on the team and shared by every key that team holds. A production application that uses a service account key therefore draws from the same budget pool as every other application, script and key under that team. Nothing in the key itself caps one application's share. Before issuing keys, the team's budget and rate limits need to be sized for the combined demand of all applications it will serve, and the owner should confirm with the LiteLLM documentation how the team limits are configured in their version, since the exact fields and their behavior depend on the release they run.
The planning question is whether one team should own several applications. If the applications share a cost center, a model allowlist and a similar risk profile, one team with shared limits is simple to operate, but a runaway job in one application can exhaust the budget for the others. If an application needs its own ceiling, its own spend view or a different model set, it probably needs its own team, which means a separate team_id on its keys and a separate budget line. Ask the application owners which failure they would rather accept: shared exhaustion or more teams to manage. Write that decision down before the first key is issued, because changing team membership later changes which limits a key draws from.
Per-application budgets are a separate design question with their own controls, and this section does not settle them. Compare the sibling topics on projects, model access groups and dynamic rate limit sharing to see how they address budgets and access per application, and confirm each capability against the version you deploy before relying on it in a design.
How a service account key links the application, team and gateway
The diagram starts in the application network, where a production service sends a request with its service account key to the LiteLLM gateway. The gateway checks that the key carries a team_id and applies only that team's limits before it calls the model provider. A separate path shows a staff member being deleted: the user record goes, but the service account key and its team stay in place, so the application keeps running. Check that the trust boundary sits where your network controls put it.
Service account keys stay bound to their team after a staff member leaves.
Setting up a service account key with a required team_id
This sequence produces a LiteLLM service account key that belongs to a team rather than a person, is limited to approved models and team budgets, sits in the application's secret manager, and has been checked against spend and log records before production use.
Confirm PostgreSQL backs virtual keys
The platform engineer checks that the proxy runs with a PostgreSQL database, because LiteLLM virtual keys, including service account keys, need one. Confirm the database connection in the proxy configuration and in the proxy's startup logs, and confirm that the database is the one your backup policy covers. Do not proceed until a key can be created and read back from the database. If you run more than one proxy instance, also confirm that Redis is in place for shared rate limits, since the production guide requires Redis 7.0 or newer in that case. Check the exact configuration keys and admin screens against the LiteLLM version you run, because they change between releases.
Identify or create the owning team and its limits
The platform or AI governance owner identifies the team that will own the application, or creates it if it does not exist yet. Set the team's model access, budget and rate limits (TPM and RPM) before issuing any key, because a service account key applies only team limits and inherits no personal limits. Record the team's name and ID in your inventory so the key can be traced back to the application and its owner. Verify the team in the admin UI or through the API by confirming the limits and allowed models match the written request. Confirm the exact field names for team budgets and limits in the release you run.
Create the service account key with its team_id
An administrator creates the service account key and sets the required team_id to the team from the previous step. The key is saved with a null user_id, so it is not tied to any staff member, and it will not be deleted when a person leaves. Record the service account ID that LiteLLM returns, since it identifies the key in logs and spend reports. Confirm in the key listing that the user field is empty, the team field shows the expected team, and the key is marked as a service account. If the team_id is missing, the request should fail, and you should treat any key created without one as a defect to fix.
Restrict the key to approved models
The administrator limits the key to the models the application is approved to call, and no others. Use the model list or model access settings on the key, or on a model group your team already uses, so that a change to the approved set can be made without reissuing the key. Keep production and development models separate so a production key cannot reach experimental or costly models. Verify the restriction by requesting an approved model, which should succeed, and an unapproved model, which should be refused. Check the exact restriction options for your release, since model access controls have changed across versions.
Store the key in the application's secret manager
The application owner places the key in the secret manager the application already uses, such as a cloud secret store or a Vault-style service, and never in source code, container images or shared chat. Grant read access only to the workload identity that runs the application, and keep the LITELLM_MASTER_KEY in its own separate secret. Confirm that the application reads the key at runtime from the secret store, that the key does not appear in build logs or configuration files committed to version control, and that the secret store records access. Record where the secret lives and who can read it, so rotation has a known owner.
Run a test call against the gateway
The application owner, or a platform engineer acting for them, sends a test request through the gateway using the stored key and an approved model. Confirm the response arrives in the format the calling code expects and that the request completes within the team limits. Then send one request to a model outside the allowlist and confirm it is refused. The test passes when both results match the design. Keep the test request and its response as evidence for the change record.
Check spend and log entries for the key
The platform engineer checks that the test call appears in the request logs and the spend records under the service account ID and the owning team, with no user attached. Compare the recorded spend with the provider's usage for the same call, noting that the gateway may batch spend writes to the database, so allow for a short delay before comparing. Confirm that the logs contain the fields your logging design requires, and that prompt content is handled according to your data policy. The step is complete when the key's spend is visible at team level and the entries are retrievable by the service account ID. Confirm the logging and spend views for your release, since their location and detail differ between versions.
Securing service account keys once applications depend on them
Once production applications depend on a LiteLLM gateway, the keys they hold become the main control point for model access and spend. The cards below cover how the master key and issued keys are stored, restricted, rotated, logged and separated by environment, and who can reach the admin interface that issues them.
Store the master key in a secret manager
The production guide recommends that LITELLM_MASTER_KEY start with sk- and live in a secret manager, not in a configuration file or container image. Anyone holding this key can administer the proxy, so it should be injected at runtime and read by as few workloads as possible. Check that the key is absent from Git history, Helm values and pod environment dumps, and confirm who can read it in the secret manager.
Keep issued service keys out of plain storage
Service account keys are the credentials your applications send with every request, so treat them like database passwords. Store each key in the owning application's secret store, scoped to that application's namespace or service identity. Record which application holds which key ID in your inventory so a leaked key can be traced to one workload quickly.
Restrict each key to the models it needs
Apply model restrictions on every service account key so that a leaked key cannot reach expensive or unrelated models. Start from the smallest model list the application uses, then widen it only through a reviewed change. Confirm during testing that a request for a model outside the list is rejected, and keep the allowed list in your configuration as code.
Rotate keys without staff involvement
Plan rotation as a routine change that an automated job or pipeline can perform, not a task that depends on a named person. Create the replacement key, deploy it to the application's secret store, confirm traffic has moved, then revoke the old key. Test this sequence in a non-production environment before relying on it, and confirm the rotation steps with your LiteLLM version's key management documentation.
Log and review key use
Review request logs by service account key to see which applications call which models, how much they spend and when usage changes. Unexpected model names, spend spikes or calls from unknown networks are the signals to investigate. Decide who reviews these logs, how often, and where the records are retained, and confirm that your logging setup captures the key identity on every request.
Separate production and development keys
Issue separate service account keys, and ideally separate team boundaries, for production and development so that test traffic never draws on production budgets. A development key that leaks should not expose production models or spend. Name keys by environment and application so reviewers can tell them apart in logs and budget reports.
Limits to confirm before issuing production service account keys
Platform administrators own the gateway itself, so they are the first to confirm whether service account keys behave as expected in the LiteLLM version they run. The documented behavior is that a service account key has no user, must belong to a team and carries only team limits. Whether your admin UI shows these keys in the same views as user keys, and whether you can filter or export them, depends on your release, so check this before you build a process around it. Confirm the behavior on a test instance first.
- Admin view visibility: Check whether service account keys appear in the key list, spend reports and audit exports for your version.
- Migration behavior: Confirm what happens to existing keys and team records during a database migration, and test a restore of a backup that contains service accounts.
- Upgrade path: Verify that service account keys survive a move to the next supported minor release on a staging copy.
- Key rotation tooling: Confirm how a key is regenerated and whether the old key is invalidated immediately.
Run each check on a non-production instance that matches your database and Redis setup before scheduling any production key issuance.
Application owners need to know how team-level limits behave when several applications share one team. Because service account keys apply only team limits, a budget or rate limit set on the team is consumed by every key under it. That can be the intended design, or it can starve one application when another grows. Ask the platform team to show you the limit configuration and test how the team reacts when two applications send traffic at the same time.
- Shared team budget: Confirm how spend from several applications accumulates against one team budget and when requests start failing.
- Shared rate limits: Verify how TPM and RPM limits are divided across keys on the same team under load.
- Model restrictions: Check whether model allowlists set on the team apply to every service account key beneath it.
- Spend attribution: Confirm whether spend can be read per service account key or only per team, since this affects chargeback.
Bring a load test with two realistic workloads to the review, and record the team budget and rate limit values you approved.
Security reviewers focus on whether the identity of a key holds up over time. The documented design says service account keys are not deleted when a user is deleted, which removes one staff-change risk. Reviewers should still confirm that service account IDs are immutable in practice, that deletion and rotation are restricted to the roles you intend, and that every key change is recorded in a form your auditors can use.
- Immutable IDs: Test whether a service account ID can be renamed or reassigned, and whether a recreated account gets a new identity.
- Ownership after staff changes: Confirm that removing the user who created a key does not change the team, limits or model access of that key.
- Admin role scope: Verify which roles can create, edit, rotate or delete service account keys, including delegated team admins.
- Audit evidence: Check whether key creation, rotation and deletion appear in audit logs, and whether those logs are retained according to your policy. Audit logging may depend on your edition, so confirm this against the LiteLLM Enterprise documentation.
Document the answer to each point with a test result, so the evidence stays with the key register rather than in someone's memory.
What service account keys cost to implement and what drives the effort
What does it cost to move applications onto LiteLLM service account keys?
No fixed price applies, because the cost follows the written scope: how many applications move, how many teams own them, and how much secret manager work and testing the change needs. Your costs fall into two groups. One-time costs cover inventorying existing user keys, creating teams and service accounts, updating each application's secret, and verifying calls. Recurring costs cover key rotation, model list changes and reviews of team limits. Ask for a quote that lists each application, its owning team, the secret store it reads from, and the test evidence you expect at handover. DeployOpen does not publish a price list, and a quote follows from that written scope.
How long does moving applications to service account keys take?
Duration depends mainly on the number of applications and how many need code or configuration changes. An application that only reads a key from an existing secret is a smaller change than one with hard-coded keys, several environments or no owner. Teams that already run a secret manager and have clear application owners move faster than teams still deciding who owns each service. The work should be scheduled in a rollout order that keeps production traffic stable, and the timeline should appear in the written scope before work starts. Ask for a schedule that separates inventory, pilot, rollout and cleanup of old user keys.
What does our internal team need to provide for a service account key project?
Your team needs to supply four things before implementation can start:
- Team structure: the LiteLLM teams that will own service accounts, and the limits each team is allowed to hold.
- Model list: the models each application may call, grouped by environment, so keys are not granted broad access by default.
- Secret manager access: read and write permission for the store where application keys will live, plus a named owner for that store.
- Named owners: one accountable person or group per application who approves changes and receives rotation alerts.
Missing any of these usually adds rework, because a service account needs a team_id and team-only limits before it can be issued.
Can our own engineers set up LiteLLM service account keys without a partner?
Yes, a capable platform team can do this internally, since the core steps are configuration and application updates rather than custom code. The work is mostly ownership design and careful testing across applications. Internal teams usually find the inventory of existing user keys and the change coordination the hardest parts, because those depend on people outside the platform group. Consider a partner when the number of applications is large, when several secret managers are involved, or when your team cannot spare engineers for testing and rollout. Confirm your version and deployment details against the LiteLLM documentation before you start.
What happens to running applications if the user who created their key is deleted?
Keys issued to people are tied to that person, so deleting the user can stop the applications that depend on those keys. A service account key is different. Per the LiteLLM service account documentation, a service account key has a null user_id, requires a team_id, applies only team limits, and is not deleted when a user is deleted. That is why moving production applications to service account keys is the usual fix for staff changes. Before you delete any user, check which keys they created, reissue any that applications still use, and confirm the new keys work in each environment.
Which factors make the service account key project cost more or less?
The biggest drivers are:
- Number of applications and environments, since each one needs its own key, secret entry and test.
- Team structure, since unclear ownership delays every decision.
- Secret manager integration, since a store that already feeds your applications is far quicker to use than building one.
- Testing depth, including how many model routes and failure cases each application is checked against.
- Existing key hygiene, since applications still using shared or personal keys need more inventory work.
A smaller, well-owned estate with a working secret manager usually costs less to change than a large estate that has no owners.
How should we ask for a quote for service account key implementation?
Ask for a written scope that names each application, its owning team, the environments it runs in, the secret manager it reads from and the models it calls. Request the proposed deliverables, such as a key inventory, team and service account definitions, updated application secrets, test results and a runbook for rotation. Ask what the internal team must provide and which dates depend on it. Quotes should state what happens after handover, including whether ongoing rotation and model list changes are included or offered as a retainer. Most engagements are fixed-scope, so the written scope is the basis for the quote.
Who owns a service account key when teams and staff change
The first question after a service account key is issued is who owns it. Because a service account key has no person attached (its user_id is null) and must be tied to a team_id, the team on that record is the only ownership signal LiteLLM gives you. Name one owning team for each key and make that team's name the start of the record, not an afterthought. Then write down the application, the environment and the on-call contact for that team, since LiteLLM will not tell the next engineer any of this. If a key is shared by two services, treat that as a finding to resolve, because a single owner is what makes handoffs and revocations clear.
Handoffs are where ownership usually breaks. When a team reorganizes or an engineer leaves, the key does not move on its own, and the old team may still be listed as the owner. Build a handoff step into your offboarding checklist: confirm which keys list the departing team, assign each one to a successor team in your records, and confirm with that team that they know which application depends on it. Because service account keys are not deleted when a user is deleted, a departing employee's keys will keep working until someone reviews them, so the handoff review is the control that catches them. Ask your team leads to confirm the owner list at each reorganization.
Document each application that uses a key in a register that your team controls. For every key, record the owning team, the application and repository, the models and budget the key is meant to use, the environment, the secret location, the date of issue, and the date of the last review. Use the key alias or description field your LiteLLM version supports to point back to this register, and confirm with your vendor and your own test environment which fields are stored in the proxy. Review the register on a fixed cadence that your security team sets, and revoke keys whose application no longer exists. The next engineer should be able to start from a key identifier, find the application in minutes, and know who to call.
How DeployOpen works on this
DeployOpen plans and deploys self-hosted LiteLLM inside your own infrastructure, so service account keys for each production application are designed, configured and documented before any application depends on them. Work is agreed in a written, fixed scope, and ongoing support is available as a retainer.
How we scope
- Inventory every production application that will call the gateway and assign each one its own service account key.
- Confirm which team owns each service account, and that every key will carry a team_id and team-level limits only.
- Agree in writing which models each application may reach, how keys are stored, and who may rotate them.
How we build
- Create service account keys through the proxy with a required team_id, then verify the null user_id and team-only limits.
- Test that deleting a staff member's user account leaves the service account keys and their applications running.
- Configure secret storage for key values and confirm that no application code or repository holds a plaintext key.
How we hand over
- Deliver a key register listing each service account, owning team, permitted models, limits and secret location.
- Document the runbook for issuing, rotating and revoking service account keys, with the steps owners perform themselves.
- Walk your platform and security teams through the setup and record the decisions made during the build.
How we support
- Offer a retainer to review new service accounts, adjust team limits and retest key handling as applications change.
- Keep the key register and runbook current when LiteLLM upgrades change how service accounts behave.
- Ask your team to confirm the current behavior of service account keys against the LiteLLM documentation for your version.

