Data Director model broker¶
A separate service that lets a person's own AI provider account pay for model calls, so that no agent, and neither the app nor the harness, ever holds that person's key. The design is in A person's own model account; running it is in The model broker.
The broker:
- holds each person's provider key, sealed with AES-256-GCM under a key-encryption key only it
reads, with the person's pseudonym bound in as associated data (
dd_broker.seal); - knows a person only by a pseudonym, which reaches it sealed inside a model grant
(
dd_broker.grants); - makes a model call only for an agent that proves who it is with its own broker credential and presents a grant the harness signed for that agent, before the grant expires, for a model the grant allows;
- decides from the grant alone whose account pays, and says so on every answer
(
X-DD-Model-Account: ownordeployment); - reduces every refusal and provider error to a status and a reason code, keeps no prompt and no
reply, and counts tokens per pseudonym and day (
dd_broker.store); - refuses a custom base URL unless the operator allow-listed it, and one that resolves to a
private or reserved address unless the operator said so (
dd_broker.guard).
It is alpha and off by default: until the profile's model_accounts turns own accounts on, every
call is paid for by the deployment, as before. When it does, the grant names the providers and
base URL origins the profile allows, and the broker refuses a person's account outside them. The harness mints the grants (dd_harness.model_grants)
and every model-backed agent can call through the broker (dd_sdk.credentials.model_endpoint). A
person adds, replaces or removes their own key from the app's Profile page through the broker's
enrolment interface, with a single-use ticket the app issues (dd_broker.enrolment).
It serves Anthropic's Messages API at /anthropic/v1/messages, and the OpenAI Chat Completions API
at /{provider}/chat/completions for openai, gemini and openai-compatible
(dd_broker.chat_completions). An account may be any of the four, with a base URL for
openai-compatible. An account with another provider than the path names counts as none for
that call, and the broker says which provider served each call in X-DD-Model-Provider.
GET /admin/summary answers the admin service, with the operators' credential
(DD_BROKER_ADMIN_CREDENTIAL, a digest) only: people's own accounts counted by provider and tokens
summed over everyone, never a pseudonym, label or key (dd_broker.admin). Without the setting the
route is not served.
uv run dd-model-broker serve # 127.0.0.1:8300; settings in dd_broker.settings