Azure OpenAI#
Route Azure OpenAI calls through Lockpin so they are priced and capped like any other provider’s. This page is for developers and admins who run OpenAI’s models on their own Azure resource.
How Azure OpenAI works with Lockpin#
Azure hosts OpenAI’s models on your own resource, and its paths name deployments rather than models. Lockpin needs to know where your resource is, and which model each deployment runs, so it can price each call.
Point the Azure SDK at http://127.0.0.1:8787/azure. It sends
/azure/openai/deployments/<deployment>/chat/completions?api-version=... as usual, and Lockpin
forwards the path and api-version unchanged to your resource. These forms work too:
Form |
Path |
|---|---|
Deployment (Chat Completions) |
|
Responses API |
|
Azure’s v1 API, model in the body |
|
With the plain OpenAI SDK, use http://127.0.0.1:8787/azure/openai/v1 as the base URL.
Before you begin#
Lockpin is installed. See Install.
You have an Azure OpenAI resource, its endpoint (
https://<resource>.openai.azure.com), and its key, or each agent signs in with Entra ID.You know which model each deployment runs, if a deployment’s name is not its model’s name.
Set up Azure OpenAI#
Set your resource, key and deployment map in the shell that starts Lockpin.
$env:AZURE_OPENAI_ENDPOINT = "https://<resource>.openai.azure.com" $env:AZURE_OPENAI_API_KEY = "..." $env:AZURE_OPENAI_DEPLOYMENTS = "prod-chat=gpt-6-sol,cheap=gpt-6-luna" lockpin
export AZURE_OPENAI_ENDPOINT=https://<resource>.openai.azure.com export AZURE_OPENAI_API_KEY=... export AZURE_OPENAI_DEPLOYMENTS=prod-chat=gpt-6-sol,cheap=gpt-6-luna lockpin
Variable
What it holds
AZURE_OPENAI_ENDPOINTYour resource. It must be
https, with no credentials, query or fragment; Lockpin refuses anything else.AZURE_OPENAI_API_KEYThe resource’s key. Optional: you can let each agent send its own.
AZURE_OPENAI_DEPLOYMENTSdeployment=modelpairs, comma-separated, when deployment names are not model names.Optional: keep the deployment map in a file instead.
-azure-deployments FILEtakes a JSON object, merged overAZURE_OPENAI_DEPLOYMENTS, and is reloaded with the-pricesfiles:{"prod-chat": "gpt-6-sol"}
lockpin -azure-deployments deployments.json
You can also put
"deployments"on theazureprovider in a-pricesfile.Point your agent at Lockpin. With the Azure SDK, set
azure_endpointto Lockpin’s address:from openai import AzureOpenAI client = AzureOpenAI(azure_endpoint="http://127.0.0.1:8787/azure", api_key="...", api_version="...")
Important
AZURE_OPENAI_ENDPOINT is also the Azure SDK’s own variable. Lockpin’s copy must hold your
resource, while the agent’s copy points at Lockpin. lockpin run sets the agent’s copy for
you. Lockpin refuses an endpoint that is not https, so an inherited
http://127.0.0.1:8787/azure can never make it forward to itself.
Keys and sign-in#
The agent’s own
api-keyheader, or its Entra ID bearer token (azure_ad_token_provider), is forwarded as sent. Lockpin never requests, refreshes or stores a token.In team mode, a Lockpin key or capability token may sit in the
api-keyheader, as the SDK’sapi_key=puts it. See Set up a team.
How deployments are priced#
A deployment is priced as the model it runs. Lockpin looks for it in this order:
The model an earlier reply of that deployment named.
The deployment map:
AZURE_OPENAI_DEPLOYMENTS,-azure-deployments FILE, or"deployments"in a-pricesfile.The deployment’s own name.
What the deployment runs beats the map, so a wrong map cannot under-reserve for good. Lockpin warns once when they disagree. When a reply names a priced model other than the one reserved, the call is charged at the reply’s model and the ledger says so.
A deployment none of these price is refused with 400 unknown_model, never guessed.
-unknown-model-price sends it at a conservative price and alerts, as for any unknown model.
See Prices and the price feed.
Note
Prices are OpenAI’s list prices. Azure’s differ by region, so where they do, override the
model as "azure/<model>" in a -prices file.
Limits#
Embeddings, images and audio are refused unless
-allow-uncappedlists their paths, as for OpenAI.Azure cannot be a fallback target yet:
fallbacks.jsoncannot name anazure/model.Under a signed machine policy, a deployment the map does not resolve is matched against the policy’s model rules by its own name. With
-unknown-model-priceset, it can pass a deny list once. Keep the map complete.
Verify#
Check the setup, including one
HEADrequest, with no credentials, to your resource’s host:lockpin doctor -network -providers azure
Make one Chat Completions call on the deployment form and one on
/azure/openai/v1, and check that both appear in the meter athttp://127.0.0.1:8787/lockpin/.Compare the ledger’s cost with Azure’s cost analysis.
A 503 no_endpoint reply means Lockpin has no resource to forward to: set
AZURE_OPENAI_ENDPOINT in the shell that starts Lockpin.