Feature Request: Admin API for API Key Management with Key-Bound Tags #7021
engel75
started this conversation in
Feature Requests
Replies: 1 comment 1 reply
-
|
Hi @engel75 - thanks for the post. For [2], we automatically assign the tag For [1], we are planning a comprehensive RBAC solution in Q2 so let's wait for that, which should solve this use case. Thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request: Admin API for API Key Management with Key-Bound Tags
Summary
We'd like to request two closely related features:
Motivation
We are building a multi-tenant LLM platform where customers provision API keys through our self-service portal. Currently, TensorZero only supports key management via the UI (
/api-keys) and the CLI (--create-api-key/--disable-api-key). Neither can be integrated into an external application programmatically.Beyond key lifecycle management, we need a reliable way to associate billing metadata (e.g. customer ID, project ID, cost center) with every inference. Today, this can be done by having clients pass
tensorzero::tagsat request time, but this has a fundamental trust problem: any client can set arbitrary tags, including another customer's identity. For billing and compliance, this is not acceptable.Key-bound tags solve both problems at once: metadata is attached to the key by an admin, the gateway injects it server-side, and the client cannot override it.
Proposed Functionality
1. Admin API for API Key Management
A set of authenticated HTTP endpoints for programmatic key lifecycle management:
POST/admin/api-keysGET/admin/api-keysGET/admin/api-keys/:public_idPATCH/admin/api-keys/:public_idDELETE/admin/api-keys/:public_idThe admin API itself should require elevated authentication (e.g. a dedicated admin key, or a scope/role on existing keys).
Example — creating a key with tags:
Response:
{ "api_key": "sk-t0-xxxxxxxxxxxx-yyyy...", "public_id": "xxxxxxxxxxxx", "tags": { "customer_id": "acme-corp", "project_id": "proj-a1b2c3", "billing_tier": "premium" }, "expiration": "2026-12-31T23:59:59Z", "created_at": "2026-03-18T17:00:00Z" }2. Key-Bound Tags
Tags attached to an API key should be:
tagsmap onChatInference/JsonInference/ModelInference) alongside any client-provided tagsThis effectively turns API keys from simple auth tokens into tenant-scoped identity tokens.
Use Case: Multi-Tenant Billing
Our platform runs on OpenStack with self-hosted LLMs (vLLM, sglang on GPU nodes). TensorZero serves as the central LLM gateway. Each customer gets their own API key through our portal. We need to:
Today, we work around this by querying on
tensorzero::api_key_public_idand maintaining an external mapping table. Key-bound tags would eliminate this indirection entirely.Additional Considerations
admin::orkey::) to clearly distinguish key-bound tags from client-provided tags in ClickHouse queries.tensorzero::api_key_public_idtag that is already auto-injected today is conceptually the same mechanism — key-bound tags would generalize this pattern.Context
We've been following the progress on making the UI standalone (#5062) and the migration of direct database queries to gateway API endpoints. This feature request aligns with that direction — the Admin API would be another gateway endpoint that both the UI and external systems can consume.
Thank you for building TensorZero — the architecture and performance are excellent, and these additions would make it even more compelling for multi-tenant production deployments.
Beta Was this translation helpful? Give feedback.
All reactions