On this page
01
What you'll set up
A virtual key is what your app uses to call the gateway. It carries a team, an app, and an environment, so every request is labeled before it leaves your code. In about ten minutes you will create a key, label it well, test it, and learn how to rotate and revoke it.
- One key per app, agent, or environment
- Labels that drive policy and reports
- A test from the console
- A rotation and revocation routine
You need an owner or admin role. Provider credentials come from the previous guide.
02
Why one key per app
Sharing one key across apps hides who spent what and makes every incident a company-wide one.
| One shared key | One key per app |
|---|---|
| Spend cannot be traced to an owner | Spend, blocks, and errors show by key |
| Revoking it breaks everything | Revoke one app and leave the rest |
| Labels come from every caller | Labels are set once on the key |
| Everything shares one policy | Each key can follow its own policy |
03
Create a key
Keys are on the Virtual Keys card in AI → Credentials & Keys.
- 1
Choose + Create Key
It is at the top of the Virtual Keys card.
- 2
Enter a Key name
Say what and where, such as support-chatbot-prod.
- 3
Set Valid for (days)
Choose a lifetime that fits your rotation habit. The default is 3,650 days.
- 4
Set the default Team ID, App ID, and Environment
These labels travel with every request the key makes.
- 5
Optionally set an Upstream credential override
Override which provider credential the key uses, for all providers or for particular ones.
- 6
Create and copy the secret
It is shown once. Store it in your secret manager.
- 2Key name
- support-chatbot-prod
- 3Valid for (days)
- 3650
- 4Default team ID
- platform
- 4Default app ID
- support-chatbot
- 4Default environment
- production
- 5Upstream credential override
- Use policy default
04
Name keys so reports read well
A good name tells a reviewer what the key is for without opening it.
| Pattern | Example |
|---|---|
| app-environment | support-chatbot-prod |
| team-service-environment | platform-summarizer-staging |
| agent-purpose | billing-agent-reconcile |
05
Labels that drive policy and reports
Team, App, and Environment do two jobs.
- They choose which policy applies, through the bindings you set
- They label spend, blocks, and errors in the Explorer
- They are set once on the key, so every call carries them
Request headers such as x-cloptima-team label usage but cannot move a key onto a different policy. The key decides.
06
Credential overrides
By default a key uses the credentials the policy names. You can point a key at its own.
| Setting | Use it for |
|---|---|
| Default credential | A key that should always use one provider account |
| Per-provider overrides | A key that uses account A for OpenAI and account B for Anthropic |
| Use policy default | Everything else |
Separate bills by team
Two teams share one policy but have separate OpenAI accounts. Each team's key overrides the OpenAI credential, so each provider invoice matches one team.
07
Test the key from the console
Test Virtual Key sends a real call through the gateway so you can check policy and speed before you ship.
- 1
Open Test Virtual Key
It is at the bottom of the Virtual Keys card.
- 2
Select the key
A key you just created is ready to use.
- 3
Enter a model and a prompt
Use something short.
- 4
Choose Send Test Call
You see the answer, or the block reason if a policy applies.
08
Use the key in your app
Point any OpenAI-compatible client at the gateway and use the virtual key as the API key.
from openai import OpenAI
client = OpenAI(base_url="https://api.cloptima.ai/v1/ai", api_key="clop_vk_...")
reply = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Say hello"}],
)A virtual key can only call models through the gateway. It cannot change settings or read your data.
09
Rotate and expire
Rotate issues a new secret for the same key. It is also how you change a key's expiry.
- 1
Choose Rotate on the key
Set a new name or lifetime if you want one.
- 2
Copy the new secret
It is shown once.
- 3
Update your app
Deploy the new secret.
10
Revoke
Revoke ends a key at once and keeps its history.
Use it when a key may have leaked, when an app is retired, or when a person leaves a team. Spend history stays in the Explorer under the key's name.
11
Virtual keys and telemetry keys
Cloptima has two kinds of key. They do different jobs.
| Virtual key | Telemetry key | |
|---|---|---|
| Prefix | clop_vk_ | clop_tk_ |
| Used for | Sending requests through the gateway | Sending usage events from SDKs or OpenTelemetry |
| Where to create | Virtual Keys card | Telemetry Keys card |
| Labels | Team, App, Environment | Optional team, app, and environment |
| Shown | Once, at creation | Once, at creation |
Use a telemetry key when your app calls a provider directly and reports usage to Cloptima, and a virtual key when your app calls through the gateway.
12
If something goes wrong
Most problems are the secret or the labels.
| What you see | Likely cause | Fix |
|---|---|---|
| 401 from the gateway | The secret is wrong, expired, or revoked | Rotate the key and update the app |
| 403 policy_not_configured | No policy is bound to the key's labels | Bind a policy to the team, app, or key |
| Spend shows under unknown | The key has no team or app | Edit the key and set the labels |
| The wrong provider account is billed | The key uses the policy's default credential | Set a credential override on the key |