Skip to content

Azure Foundry Provider ​

Azure Foundry and Azure OpenAI deployments as native Pi providers — config-driven, JSONC support, validation.

Overview ​

The Azure Foundry provider registers Azure Foundry and Azure OpenAI deployments as native Pi providers from a JSONC configuration file. Each deployment becomes a provider whose model IDs are selected as <deployment-id>/<model-id>.

Key features:

  • Config-driven setup with JSONC support
  • Two API modes: openai-completions and azure-openai-responses
  • Custom headers support
  • Multiple deployments per configuration
  • Built-in validation and verification

Install ​

sh
pi install npm:@pi-stef/azure-foundry

Start Pi once after installing. On first load, the extension creates:

text
~/.pi/azure-foundry/config.json
~/.pi/azure-foundry/config.schema.json

Configuration ​

Edit config.json, uncomment or add a deployment, and export the bearer-token env var named by apiKeyEnv.

bash
export AZURE_API_KEY=...

Azure Foundry (openai-completions) ​

For Azure Foundry, use the modern OpenAI-compatible v1 endpoint:

jsonc
{
  "id": "azure-foundry",
  "name": "Azure Foundry East US",
  "baseUrl": "https://<resource>.services.ai.azure.com/openai/v1/",
  "apiKeyEnv": "AZURE_API_KEY",
  "api": "openai-completions",
  "models": [
    {
      "id": "Kimi-K2.6",
      "name": "Kimi K2.6",
      "reasoning": false,
      "input": ["text"],
      "contextWindow": 128000,
      "maxTokens": 2048,
      "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
    }
  ]
}

Azure OpenAI (azure-openai-responses) ​

Classic Azure OpenAI via azure-openai-responses:

jsonc
{
  "id": "aoai-eastus",
  "name": "Azure OpenAI East US",
  "baseUrl": "https://my-aoai.openai.azure.com",
  "apiKeyEnv": "AZURE_OPENAI_API_KEY",
  "api": "azure-openai-responses",
  "models": [
    {
      "id": "o4-mini",
      "name": "o4-mini",
      "reasoning": true,
      "input": ["text"],
      "contextWindow": 200000,
      "maxTokens": 16000,
      "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
    }
  ]
}

Config Reference ​

Top-level shape:

jsonc
{
  "$schema": "./config.schema.json",
  "deployments": []
}

Deployment fields:

FieldRequiredNotes
idYesProvider id. Lowercase letters, numbers, and hyphens.
nameYesDisplay name.
baseUrlYeshttps:// endpoint. Rules depend on api.
apiKeyEnvYesEnv-var name containing the bearer token.
apiYesopenai-completions or azure-openai-responses.
authHeaderNoDefaults to true.
headersNoMap of header name to env-var name.
modelsYesOne or more model entries.

Multiple Deployments ​

jsonc
{
  "deployments": [
    { "id": "foundry-east", "name": "Foundry East", "baseUrl": "https://east.services.ai.azure.com/openai/v1/", "apiKeyEnv": "AZURE_EAST_KEY", "api": "openai-completions", "models": [] },
    { "id": "foundry-west", "name": "Foundry West", "baseUrl": "https://west.services.ai.azure.com/openai/v1/", "apiKeyEnv": "AZURE_WEST_KEY", "api": "openai-completions", "models": [] },
    { "id": "aoai-eastus", "name": "AOAI East US", "baseUrl": "https://my-aoai.openai.azure.com", "apiKeyEnv": "AZURE_OPENAI_API_KEY", "api": "azure-openai-responses", "models": [] }
  ]
}

Custom Headers ​

jsonc
"headers": {
  "api-key": "AZURE_HEADER_KEY",
  "x-ms-useragent": "AZURE_USER_AGENT"
}

Header values are env-var names. Pi resolves them at request time.

Verification ​

Run the package verifier after exporting the configured API key:

bash
pnpm -F @pi-stef/azure-foundry verify

Common outputs:

OutputFix
200The deployment is reachable.
401Check the env var named by apiKeyEnv.
404Check the model deployment id and base URL.
timeout after 10sCheck network access, proxy, and endpoint host.

Environment Variables ​

VariablePurpose
PI_AZURE_FOUNDRY_CONFIGOverride config path for tests or alternate profiles.
PI_AZURE_FOUNDRY_DEBUGSet to 1 for debug logging.
AZURE_OPENAI_API_VERSIONOptional Pi-side version for azure-openai-responses; defaults to v1.

Remove ​

sh
pi remove @pi-stef/azure-foundry

Update ​

sh
pi update @pi-stef/azure-foundry