Create a virtual key
/v1/virtual-keysCreate a virtual key.
Creates a key in a workspace and answers its API key (api_key: the slug, a dot, then a secret). The API key is shown only in this response: store it now. Send it as a bearer token in Authorization (or in x-virtual-key) on inference requests. A new key is ACTIVE.
Two credential modes:
BYOK(the default): you supply your provider keys incredentials. They are stored encrypted and only their last four characters are ever returned.initial_credits_usd,provider_whitelistandmarkup_pctare ignored.PLATFORM: requests use VectorAxis's own provider accounts and are paid from your organization's credit balance, at the provider's price plus a markup.initial_credits_usdis required and must be greater than 0; it also becomes the key's credit limit (credit_limit_usdis ignored).credentialsare ignored. A PLATFORM key cannot be created while a credit withdrawal is pending.
Every guardrail in guardrail_slugs must exist in the organization and, when the guardrail belongs to a workspace, in the key's workspace.
Requires an organization admin key, or a workspace admin key for workspace_id.
Errors: 400 when a PLATFORM key has no positive initial_credits_usd, provider_whitelist names an unknown provider, or a guardrail slug is unknown, duplicated or in another workspace; 403 without the required role; 409 when the organization already has a key with this name. The organization's subscription must be active and its plan's virtual key quota not yet reached.
Authorization
AuthorizationBearer va_A platform API key (
va_...), created under Settings > API keys. Scoped to an organization or one workspace, with an admin or member role. Used by the management API.
Request body application/json
the key to create
namestringrequiredThe key's name, unique within the organization. Required.
organizationstringrequiredThe slug of the organization the key belongs to. Required.
workspace_idstring<uuid>requiredThe workspace the key belongs to (UUID). Required.
notestringA free-text note about the key. Optional.
credential_modeenum<string>Where the provider credentials come from:
BYOK(your own provider keys, incredentials) orPLATFORM(VectorAxis's provider accounts, paid from your organization's credits). DefaultBYOK.One of
"BYOK","PLATFORM"credentialsobject[]Your provider keys, for a BYOK key: one entry per provider. Stored encrypted; only the last four characters of each are ever returned. Ignored for a PLATFORM key.
Child attributes
providerstringrequiredThe provider id, e.g.
OPENAIorANTHROPIC(see "List supported providers"). Required.keystringrequiredThe provider API key. For
VERTEX_AI, the Google service-account key file's JSON, as a string. Required.vertex_project_idstringFor
VERTEX_AI: the Google Cloud project id to call. A request'sx-vertex-projectheader overrides it. Ignored for other providers.vertex_regionstringFor
VERTEX_AI: the Vertex AI region (e.g.us-central1, orglobal). A request'sx-vertex-regionheader overrides it. Ignored for other providers.
expires_atstring<date-time>When the key expires (ISO 8601 date-time). From then on its requests are refused (403
VIRTUAL_KEY_EXPIRED) and its status becomesEXPIRED, which is final. Absent: the key never expires.metadatamap<string, string>Your own string key/value pairs, stored with the key. Optional.
model_allowliststring[]The models the key may call. A request for any other model is refused (403
MODEL_NOT_ALLOWED). A model matches with or without its provider prefix (openai/gpt-4omatchesgpt-4o). Empty or absent: every model.credit_limit_usdnumber<double>The most the key may spend, in USD. Once its spend reaches the limit the key becomes
EXHAUSTEDand its requests are refused (403VIRTUAL_KEY_EXHAUSTED) until the limit is raised or the spend is reset. Absent: no limit. Ignored for a PLATFORM key, whose limit isinitial_credits_usd.credit_alert_threshold_usdnumber<double>A soft limit in USD: once the key's spend reaches it, the key carries the
ALERT_THRESHOLD_EXCEEDEDwarning. Requests are not refused. Absent: no alert.credit_reset_policyenum<string>When the key's spend goes back to zero:
MONTHLY(the 1st of each month, 00:00 UTC),WEEKLY(each Monday, 00:00 UTC) orNEVER. A reset also makes anEXHAUSTEDkeyACTIVE. DefaultNEVER.One of
"MONTHLY","WEEKLY","NEVER"rate_limit_rpminteger<int32>The most requests the key may make per minute (a 60-second window); over it, 429. Absent: no limit.
rate_limit_tpminteger<int32>The most tokens the key may use per minute (a 60-second window); over it, 429. Absent: no limit.
rate_limit_rpdinteger<int32>The most requests the key may make per day (a UTC calendar day); over it, 429. Absent: no limit.
initial_credits_usdnumber<double>For a PLATFORM key: the credit in USD the key starts with, which is also its credit limit. Required and greater than 0 for a PLATFORM key; ignored for a BYOK key.
provider_whiteliststring[]For a PLATFORM key: the only providers it may use, as provider ids (e.g.
OPENAI,ANTHROPIC). A request for a model of another provider is refused (403PROVIDER_NOT_WHITELISTED). Empty or absent: any provider VectorAxis serves. Ignored for a BYOK key.guardrail_slugsstring[]Slugs of guardrails to run on every request made with this key, in addition to any named in the request's
x-guardrailheader. Each must belong to the organization and, when it belongs to a workspace, to the key's workspace; no duplicates. Optional.markup_pctnumber<double>For a PLATFORM key: the markup on the provider's price as a fraction (
0.06is 6%), replacing the platform's default markup for this key. Absent: the platform default. Ignored for a BYOK key.
Responses
Created
slugstringThe key's slug:
vk-followed by 16 hex characters. Use it to manage the key.api_keystringThe API key your applications send: the slug, a dot, then a secret. Send it as a bearer token in
Authorization(or inx-virtual-key). Shown only once; only a hash of the secret is kept.token_hintstringThe last characters of the API key's secret, as later shown on the key as
token_hint.key_hintstringThe last four characters of the first provider credential. An empty string for a PLATFORM key.