[STG-2090] Add Azure Entra model auth support
Merged
MO
4mo ago+932+932+012345678901234567890123456789-51-51-01234567890123456789
Why
Support Azure OpenAI Microsoft Entra ID bearer-token auth through the Stagehand model config shape.
What changed
- Adds an explicit Azure model config branch with
auth: { type: "azureEntraId", token }andproviderOptions.azure. - Adapts Azure Entra auth to the AI SDK Azure
tokenProvideroption. - Bumps
@ai-sdk/azureto the v5-compatible release withtokenProvidersupport. - Regenerates the server-v3 OpenAPI spec and adds parser/schema/runtime tests.
Validation
pnpm --filter @browserbasehq/stagehand run build:esmpnpm --filter @browserbasehq/stagehand run test:core -- packages/core/dist/esm/tests/unit/llm-provider.test.js packages/core/dist/esm/tests/unit/api-variables-schema.test.js packages/core/dist/esm/tests/unit/public-api/llm-and-agents.test.jspnpm --filter @browserbasehq/stagehand-server-v3 run gen:openapipnpm --filter @browserbasehq/stagehand-server-v3 run build:esm-testspnpm --filter @browserbasehq/stagehand-server-v3 run test:server -- packages/server-v3/dist/tests/unit/requestModelConfig.test.jspnpm --filter @browserbasehq/stagehand run typecheckpnpm --filter @browserbasehq/stagehand-server-v3 run typecheck
Summary by cubic
Adds Azure OpenAI Microsoft Entra ID bearer-token auth to Stagehand. Implements STG-2090 and updates types, schemas, and OpenAPI to support the new azure provider.
-
New Features
- Add
provider: "azure"withauth: { type: "azureEntraId", token }andproviderOptions.azure(resourceName, baseURL, apiVersion, useDeploymentBasedUrls, headers). - Map Entra auth to the
@ai-sdk/azuretokenProvider; Azure runs without experimental mode and never sends an API key when provider auth is set. - Preserve same-provider non-credential options when overriding credentials (inherit baseURL/headers/providerOptions; strip
apiKey/auth) across client and server. - Prevent API key fallback when provider auth exists: ignore env/header/base-config keys, keep per-request Azure configs via
withModelApiKeyFallback, and reject configs that mixapiKeywith Entra auth. - Expand public types and Zod schemas (add
AgentType: "azure"); regenerate OpenAPI with Azure schemas and normalize the generator output to preserve Azure union branches. - Add unit tests for schema validation, AI SDK client options, API client defaults, server request model config parsing, and tokenProvider behavior.
- Add
-
Dependencies
- Bump
@ai-sdk/azureto^2.0.109.
- Bump