Skip to content

feat(azure): add AzureServerlessPathHook for legacy serverless support#436

Draft
Nelson-PROIA wants to merge 1 commit intomainfrom
nelson.proia/air-142-azure-foundry-path-fix
Draft

feat(azure): add AzureServerlessPathHook for legacy serverless support#436
Nelson-PROIA wants to merge 1 commit intomainfrom
nelson.proia/air-142-azure-foundry-path-fix

Conversation

@Nelson-PROIA
Copy link
Contributor

@Nelson-PROIA Nelson-PROIA commented Mar 19, 2026

Related to #292

Summary

  • Add is_foundry parameter (default True) to MistralAzure.__init__
  • Add AzureServerlessPathHook that rewrites Foundry Resource paths to legacy serverless paths when is_foundry=False, allowing users on *.models.ai.azure.com to continue using the SDK
  • Fix pre-commit mypy hook missing httpx/pydantic dependencies

Important

This PR must be merged only after the Azure OpenAPI spec is updated to use Foundry Resource paths and the SDK is regenerated from it.

Once the spec is fixed and code regenerated, the generated paths will match Foundry Resource format (/models/chat/completions, /providers/mistral/azure/ocr). The hook added here is not needed for Foundry users (the default) — it exists solely to support legacy serverless users who pass is_foundry=False.

Context

Azure has two endpoint types with different path formats:

Endpoint type Host pattern Chat path OCR path
Foundry Resource (current standard) <resource>.services.ai.azure.com /models/chat/completions /providers/mistral/azure/ocr
Serverless (legacy) <deployment>.<region>.models.ai.azure.com /chat/completions /ocr

The spec update will make generated paths match Foundry format. Without the hook, legacy serverless users would have no workaround (you can't strip path prefixes via server_url). The hook follows the same pattern as the existing GCPVertexAIPathHook.

Test plan

  • Verify Foundry Resource endpoints work with default is_foundry=True (no path rewriting)
  • Verify legacy serverless endpoints work with is_foundry=False (paths rewritten)
  • Run Azure integration tests with required env vars
  • Run GCP integration tests with required env vars

…nt support

Add is_foundry parameter (default True) to MistralAzure. When is_foundry=False,
a BeforeRequestHook rewrites Foundry Resource paths to legacy serverless paths,
allowing users on *.models.ai.azure.com to continue using the SDK after the spec
is updated to Foundry Resource format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant