Skip to main content

lmux-azure-foundry

Azure AI Foundry provider for lmux. Talks to the Azure OpenAI REST API directly with httpx.

Supports chat completions, streaming, embeddings, and the Responses API.

Part of the lmux ecosystem: standardized interface, cost tracking on every response, and registry-based routing across providers.

Optional Extras

  • lmux-azure-foundry[identity]: Azure AD token authentication via azure-identity

Auth

Three authentication methods:

API Key (default)

Set AZURE_FOUNDRY_API_KEY in your environment:

from lmux_azure_foundry import AzureFoundryProvider

provider = AzureFoundryProvider(endpoint="https://your-resource.openai.azure.com")

Azure AD Token

from lmux_azure_foundry import AzureFoundryProvider, AzureAdToken

provider = AzureFoundryProvider(
    endpoint="https://your-resource.openai.azure.com",
    auth=my_auth_returning_azure_ad_token,
)

Token Provider

from lmux_azure_foundry import AzureFoundryTokenAuthProvider

provider = AzureFoundryProvider(
    endpoint="https://your-resource.openai.azure.com",
    auth=AzureFoundryTokenAuthProvider(),  # uses azure-identity DefaultAzureCredential
)

Usage

Chat

from lmux import UserMessage

response = provider.chat("gpt-4o", [UserMessage(content="Hello")])
print(response.content)
print(response.cost)

Streaming

for chunk in provider.chat_stream("gpt-4o", [UserMessage(content="Hello")]):
    if chunk.delta:
        print(chunk.delta, end="")

Embeddings

response = provider.embed("text-embedding-3-small", "Hello")
print(response.embeddings)

Responses API

Required for models that are only served through the Responses API:

response = provider.create_response("gpt-5-pro", "Hello")
print(response.output_text)

Async

All methods have async variants: achat, achat_stream, aembed, acreate_response.

Registry

Use with the lmux registry to route across multiple providers:

from lmux import Registry

registry = Registry()
registry.register("azure", provider)
response = registry.chat("azure/gpt-4o", messages)

Provider Params

from lmux_azure_foundry import AzureFoundryParams

response = provider.chat(
    "gpt-4o",
    messages,
    provider_params=AzureFoundryParams(deployment_type="data_zone"),
)
Parameter Type Description
reasoning_effort "low" | "medium" | "high" Reasoning effort for o-series models
seed int Deterministic sampling seed
user str End-user identifier
prompt_cache_key str Cache key for Azure's automatic prompt caching (chat + responses)
prompt_cache_retention "in_memory" | "24h" Prompt cache retention policy (chat + responses)
deployment_type "global" | "data_zone" | "regional" Affects cost calculation only, not sent to API

Constructor Options

AzureFoundryProvider(
    endpoint=...,      # required, Azure resource endpoint
    auth=...,          # AuthProvider, default: AzureFoundryKeyAuthProvider()
    api_version=...,   # API version (default: "2025-04-01-preview")
    timeout=...,       # Request timeout in seconds
    max_retries=...,   # Max retry attempts
    default_headers=...,  # Optional headers included with every request
    transport=...,        # Optional httpx.BaseTransport for the sync client (proxies, testing)
    async_transport=...,  # Optional httpx.AsyncBaseTransport for the async client
)

default_headers is useful for gateway authentication, tracing, and routing. Foundry-managed authentication and content-type headers take precedence over caller values, case-insensitively.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmux_azure_foundry-0.10.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmux_azure_foundry-0.10.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file lmux_azure_foundry-0.10.0.tar.gz.

File metadata

  • Download URL: lmux_azure_foundry-0.10.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for lmux_azure_foundry-0.10.0.tar.gz
Algorithm Hash digest
SHA256 5c69bb6268d436a35431a68c6f7e25688b7cb2c4c9ebf359c802c7ecb7b62b8c
MD5 391134a3e3233174d9644cc4b8e7f080
BLAKE2b-256 03e667651b2b7623b0ee1360653b04f8f821c4b693c8d2b7499d597cd25b4c0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_azure_foundry-0.10.0.tar.gz:

Publisher: publish.yml on cluebbehusen/lmux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lmux_azure_foundry-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lmux_azure_foundry-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1ed58d2bf106c898c0d94c45eba2a536f6601c0e3ac7398fd0f6488357c5de1
MD5 398f2ff2be530407e41006a2abc8a22c
BLAKE2b-256 48801ad800b6dbca1c6654fa10ad63cfd8fa16147f1915bb27db660885ad6c2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_azure_foundry-0.10.0-py3-none-any.whl:

Publisher: publish.yml on cluebbehusen/lmux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page