Workshop, late afternoon. Two OpenAI keys hang by the door like mittens, the elves' home-trained toy sorter hums in the corner, and nobody agrees which key should pay.
- Sprocket
The toy-list script goes live tonight! I'm pasting the OpenAI key straight into the code.
- Ledger
Which key? Toy Shop is the default: that's the shop-floor budget. The toy list belongs on North Pole: Santa's own contract, his rate limits, his bill.
- Sprocket
Easy! I'll paste both and comment one out. What could possibly go wrong?
- Ledger
Then someone uncomments the wrong one, a month of experiments lands on Santa's contract, and I'm recounting tokens like a spilled jar of candy canes.
- Tinsel
Hang both keys in BYOK, not in the code. One header,
x-orq-integration-openai, says which mitten pays.
- clientYour appx-orq-integration-openai
- orq.aiAI Routerpicks key by id or name
- headerno headernamed keyNorth Poledefault keyToy Shop
- your accountopenai/gpt-6.2-solyour bill · your limits
How it works
Tinsel’s fix keeps the keys in the workshop, not in the script. There are three parts:
- Connect a key. Open BYOK in the AI Gateway sidebar, click Configure on a provider, choose Setup your own API key, then set a Name and paste the key. A provider can hold several keys. Requests use the one marked Default, or the first key added when none is.
- Pick a key per request. Send
x-orq-integration-<provider>with the key’s integration id or exact display name. The<provider>part matches the provider of the model you call, such asopenai,anthropic,googleorgoogle-ai. - Bring a private model. Fine-tuned, self-hosted and privately deployed models connect under Models, from an OpenAI-compatible endpoint, Azure AI Foundry, AWS Bedrock or LiteLLM. You call them on the same endpoint as public models.
The router then calls the provider with your credentials. Billing and rate limits stay on your own provider account.
Try it with curl
curl -X POST https://my.orq.ai/v3/router/chat/completions \
-H "Authorization: Bearer $ORQ_API_KEY" \
-H "Content-Type: application/json" \
-H "x-orq-integration-openai: North Pole" \
-d '{
"model": "openai/gpt-6.2-sol",
"messages": [{"role": "user", "content": "Count the toys"}]
}'
Or from the OpenAI SDK
Set the header once on the client. Every request from it uses that key.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ORQ_API_KEY"],
base_url="https://my.orq.ai/v3/router",
default_headers={"x-orq-integration-openai": "North Pole"},
)
response = client.chat.completions.create(
model="openai/gpt-6.2-sol",
messages=[{"role": "user", "content": "Count the toys"}],
)
print(response.choices[0].message.content)
Call a private model
After you import and enable a private model, reference it as <workspace>@<provider>/<model>. Here corp stands for your workspace and gpt-6-sol for your own Azure deployment:
response = client.chat.completions.create(
model="corp@azure/gpt-6-sol",
messages=[{"role": "user", "content": "Count the toys"}],
)
To register a self-hosted OpenAI-compatible endpoint from the terminal:
orq models create-openai-like \
--display-name "Workshop Llama" \
--base-url https://llm.workshop.internal/v1 \
--model-id workshop-llama \
--model-type chat \
--region us \
--api-key "$WORKSHOP_LLM_KEY"
The platform calls the endpoint with those credentials before it saves the model, so a wrong URL or key fails at create time. Then enable the model under Models, or with orq models enable, before you call it.
When to use your own keys
| Need | What BYOK gives you |
|---|---|
| Rate limits | Limits apply to your provider account, not a shared pool |
| Billing | The provider bills you directly |
| Data residency | No shared credential layer between the router and your account |
| Key rotation | Add the new key, then Set as Default |
A call fails while the workspace has neither credits nor a provider key.
Which key wins
A model that pins an integration keeps it, and a provider credential sent on the request is used for that call. Otherwise the header decides. Without a header, the request uses an integration id set on the request, if any, then the provider’s default key.
| Status | When |
|---|---|
400 |
The header is empty, or no key has that id or exact name |
409 |
More than one key for that provider has the same display name; send the integration id |
Names are unique per provider inside a workspace, so sending the id is always safe. A header for a provider the request does not call is ignored.
Nice list
- Name each key after who pays, like
North PoleorToy Shop. The header match is case-sensitive, so pick one spelling and keep it. - Rotate a key by adding the new one next to the old, then Set as Default on the new one when the old key is revoked or runs out.
- Give a non-production workspace its own keys. Keys belong to a single workspace.
- Send the integration id in code you ship. Ids cannot clash the way duplicate display names do, so you never see the
409.
Naughty list
- Pasting a provider key into your app code. Anyone who reads the code can spend on your account. Under BYOK the key is encrypted and only shown masked.
- Expecting the header to override a model that pins an integration. The pinned integration wins, and the header is ignored for that model.
- Clicking Edit to paste a new key value. Edit only renames: the key field is read-only. Add the new key and Set as Default instead.
Elf's challenge
Connect an OpenAI key named North Pole, then whisper it in lowercase: send x-orq-integration-openai: north pole. What status comes back, and how do you fix it?
Stuck? Ask Tinsel for a hint
400: no integration has that exact display name, because names are case-sensitive. Send North Pole exactly as stored, or send the integration id instead.
Christmas crackerWhy did the hardcoded API key land on the naughty list?Pull it for the punchline
Somebody checked it in. Twice.