Python
Azure OpenAI as its own provider card
Rohit C Prasad159a875c1e77
diff --git a/README.md b/README.mdindex b5281a55..c29a8a47 100644--- a/README.md+++ b/README.md@@ -87,10 +87,13 @@ Unattended runs never self-approve: their asks park in an inbox until a human anModel access is yours: pick a provider, paste your key, switch anytime. Supported out of the box:-**OpenAI · Anthropic · Google Gemini · BytePlus Ark · Volcengine Ark Agent Plan · Atlas Cloud · Inkling (Thinking Machines) · GLM (Z.ai) · DeepSeek · Kimi (Moonshot) · Qwen · MiniMax · Mistral · Grok (xAI) · Solar (Upstage)** - plus aggregators **OrcaRouter** and **OpenRouter**, open-weight models via **Together** and **Fireworks**, and fully local models via **Ollama**.+**OpenAI · Azure OpenAI · Anthropic · Google Gemini · BytePlus Ark · Volcengine Ark Agent Plan · Atlas Cloud · Inkling (Thinking Machines) · GLM (Z.ai) · DeepSeek · Kimi (Moonshot) · Qwen · MiniMax · Mistral · Grok (xAI) · Solar (Upstage)** - plus aggregators **OrcaRouter** and **OpenRouter**, open-weight models via **Together** and **Fireworks**, and fully local models via **Ollama**.A curated model list marks what we've verified for tool-calling work. Adding any model string works at your own risk.+Azure OpenAI uses your own resource: paste its endpoint and key (or set `AZURE_OPENAI_API_KEY`), then add your deployment names as models — on Azure the model id is the deployment name.++## PrivacyOpenWorker is local-first. Everything lives on your machine: the agent loop, your conversations, connector tokens, and model keys - all in the app's local secret store. The only cloud piece is a small service that brokers OAuth handshakes for connectors. You can always use the App without signing-in - use the connectors via manually-created credentials/API-keys.diff --git a/coworker/providers/capabilities.py b/coworker/providers/capabilities.pyindex f9285fa5..c4198643 100644--- a/coworker/providers/capabilities.py+++ b/coworker/providers/capabilities.py@@ -86,6 +86,15 @@ def capabilities_for(model: str) -> ModelCapabilities:tools=True, vision=False, parallel_tool_calls=True, streaming=True)+ # Azure OpenAI: the id is the user's deployment name, which may say nothing about+ # the model behind it (the GPT / o-series name checks above still apply when it+ # does). Every current OpenAI model there calls tools in parallel; vision stays+ # off until the name says otherwise, so images degrade to text instead of a 400.+ if provider == "azure":+ return ModelCapabilities(+ tools=True, vision=False, parallel_tool_calls=True, streaming=True+ )+# Conservative default for unknown models.return ModelCapabilities(tools=True, vision=False, parallel_tool_calls=False, streaming=Truediff --git a/coworker/providers/registry.py b/coworker/providers/registry.pyindex 6dc5a6df..d66e08e6 100644--- a/coworker/providers/registry.py+++ b/coworker/providers/registry.py@@ -7,8 +7,9 @@ a `ProviderClient`. The `ProviderRouter` selects a descriptor by the `provider:`model string and builds (and caches) its client from the matching SecretStore profile.Today: `openai` (the default — native models via the Responses API; an optional custom-endpoint covering Azure OpenAI's `/openai/v1` and any OpenAI-compliant gateway keeps the-Chat Completions path), `anthropic` (native Messages API via+endpoint for vLLM and any OpenAI-compliant gateway keeps the Chat Completions path),+`azure` (the user's own Azure OpenAI / Foundry resource through its `/openai/v1` API,+key-authenticated; model ids are deployment names), `anthropic` (native Messages API via`AnthropicProvider`), `gemini` (native Google GenAI API via `GeminiProvider`), `bedrock`(models in the user's own AWS account — Claude natively, everything else via Converse),`vertex` (the user's own GCP project — Gemini and Claude natively, open-weight via the@@ -125,15 +126,70 @@ def _normalize_ollama_url(url: Optional[str]) -> str:def _build_openai(profile: dict[str, Any], secrets: Any) -> ProviderClient:# Key resolution stays in resolve_api_key (explicit → env → SecretStore), so we just# hand over the SecretStore. Stock OpenAI (no custom endpoint) speaks the Responses- # API — the only wire with reasoning + tools on GPT-5.6+. A custom endpoint (Azure- # OpenAI /openai/v1, vLLM, any OpenAI-compliant gateway) keeps Chat Completions,- # which is what compat servers implement.+ # API — the only wire with reasoning + tools on GPT-5.6+. A custom endpoint (vLLM,+ # any OpenAI-compliant gateway) keeps Chat Completions, which is what compat servers+ # implement. Azure OpenAI has its own card below (`azure`); an Azure `/openai/v1`+ # URL pasted here keeps working for users who set it up before that card existed.base_url = ((profile or {}).get("base_url") or "").strip() or Noneif base_url:return OpenAIProvider(secrets=secrets, base_url=base_url)return OpenAIResponsesProvider(secrets=secrets)+AZURE_OPENAI_ENV_KEY = "AZURE_OPENAI_API_KEY"+_AZURE_V1_SUFFIX = "/openai/v1"+++def normalize_azure_endpoint(endpoint: Optional[str]) -> str:+ """The `/openai/v1` base URL for an Azure OpenAI or Foundry resource, from whatever the+ user pasted: the bare resource endpoint (`https://<resource>.openai.azure.com`, also+ `…services.ai.azure.com` and sovereign-cloud hosts), one already ending in `/openai`+ or `/openai/v1`, or a full request URL copied from the portal (its path and+ `?api-version=` query are dropped — the v1 API takes neither). Empty in ⇒ empty out.++ Base URL per learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle+ (read 2026-10-26): append `/openai/v1` to the resource endpoint; no api-version.+ """+ raw = (endpoint or "").strip().split("?", 1)[0].split("#", 1)[0].rstrip("/")+ if not raw:+ return ""+ if "://" not in raw:+ raw = "https://" + raw+ lowered = raw.lower()+ if lowered.endswith(_AZURE_V1_SUFFIX):+ return raw+ if lowered.endswith("/openai"):+ return raw + "/v1"+ # A deployments URL (`…/openai/deployments/<name>/chat/completions`) or any other+ # path under /openai: keep the origin and the /openai segment, drop the rest.+ marker = lowered.find("/openai/")+ if marker != -1:+ return raw[:marker] + _AZURE_V1_SUFFIX+ return raw + _AZURE_V1_SUFFIX+++def _build_azure(profile: dict[str, Any], secrets: Any) -> ProviderClient:+ """Azure OpenAI through the v1 API: the stock OpenAI SDK pointed at+ `<endpoint>/openai/v1`. The key comes from THIS provider's profile or+ AZURE_OPENAI_API_KEY only — never the OpenAI key or SecretStore fallback, so a+ configured OpenAI key is never sent to an Azure host (same guard as the compat+ vendors). Chat Completions, as the OpenAI custom-endpoint path always used for Azure."""+ p = profile or {}+ base_url = normalize_azure_endpoint(p.get("endpoint"))+ if not base_url:+ raise RuntimeError(+ "No Azure OpenAI endpoint configured — add it in Settings ▸ Models."+ )+ api_key = (p.get("api_key") or "").strip() or os.environ.get(+ AZURE_OPENAI_ENV_KEY, ""+ ).strip()+ if not api_key:+ raise RuntimeError(+ "No Azure OpenAI API key configured — add it in Settings ▸ Models."+ )+ return OpenAIProvider(api_key=api_key, base_url=base_url)++def _build_codex(profile: dict[str, Any], secrets: Any) -> ProviderClient:# Credentials come from the OAuth token set in the provider's own profile,# resolved (and refreshed) at call time by the token store — never a key.@@ -397,14 +453,46 @@ DESCRIPTORS: list[ProviderDescriptor] = ["Custom endpoint (optional)",secret=False,required=False,- placeholder="https://…/openai/v1",- help="For Azure OpenAI, vLLM, or any OpenAI-compliant server. Leave blank for api.openai.com.",+ placeholder="https://…/v1",+ help="For vLLM or any OpenAI-compliant server. Leave blank for api.openai.com. "+ "Azure OpenAI has its own card.",),],build=_build_openai,recommended_model="gpt-5.6-sol",env_key="OPENAI_API_KEY",),+ # Azure OpenAI as its own card (issue #457): before it, Azure meant pasting an+ # `/openai/v1` URL into the OpenAI card's custom endpoint, with the OpenAI key field+ # standing in for the Azure key. Entra ID sign-in is a second auth mode to follow (#507).+ ProviderDescriptor(+ name="azure",+ title="Azure OpenAI",+ needs_key=True,+ fields=[+ ProviderField(+ "endpoint",+ "Endpoint",+ secret=False,+ placeholder="https://<resource>.openai.azure.com",+ help="Your resource's endpoint, from Keys and Endpoint in the Azure portal "+ "or the Foundry portal. /openai/v1 is added automatically; Foundry "+ "(…services.ai.azure.com) and sovereign-cloud hosts work too.",+ ),+ ProviderField(+ "api_key",+ "Azure OpenAI API key",+ secret=True,+ ),+ ],+ build=_build_azure,+ # No catalogue: on Azure the model id is the user's own deployment name.+ recommended_model=None,+ env_key=AZURE_OPENAI_ENV_KEY,+ blurb="Your own Azure OpenAI or Foundry resource, through its v1 API — model ids "+ "are your deployment names.",+ ),+ProviderDescriptor(name="openai-codex",kind="subscription",@@ -927,9 +1015,14 @@ def descriptor_configured(d: ProviderDescriptor, profile: dict[str, Any]) -> booreturn True # keyless (Ollama) — usable out of the boxprofile = profile or {}if any(f.key == "api_key" for f in d.fields):- return bool(profile.get("api_key")) or bool(+ has_key = bool(profile.get("api_key")) or bool(d.env_key and os.environ.get(d.env_key))+ # A key alone is not enough where the card also requires a non-secret field+ # (Azure's endpoint): an env key with nowhere to send it is not configured.+ return has_key and all(+ profile.get(f.key) for f in d.fields if f.required and not f.secret+ )return all(profile.get(f.key) for f in d.fields if f.required)@@ -1213,6 +1306,27 @@ def verify_provider_key(params={"key": key},timeout=timeout,)+ elif name == "azure":+ # The Azure v1 API's own model list, at the user's resource — never+ # api.openai.com. The key rides as a bearer token, exactly as the OpenAI SDK+ # sends it at run time (the v1 spec takes the key in `authorization` as+ # well as `api-key`), so a passing Test proves the path the sessions use.+ endpoint = normalize_azure_endpoint(+ (fields or {}).get("endpoint") or base_url+ )+ if not endpoint:+ return {"ok": False, "error": "Enter the Azure OpenAI endpoint to test."}+ resp = httpx.get(+ endpoint + "/models",+ headers={"Authorization": f"Bearer {key}"},+ timeout=timeout,+ )+ if resp.status_code == 404:+ return {+ "ok": False,+ "error": "Reached the host, but no Azure OpenAI v1 API at this "+ "endpoint — check the resource endpoint.",+ }elif name == "ollama":base = _normalize_ollama_url(base_url)resp = httpx.get(base.rstrip("/") + "/models", timeout=timeout)diff --git a/surfaces/gui/e2e/fixtures.ts b/surfaces/gui/e2e/fixtures.tsindex 434f1a08..8f19715c 100644--- a/surfaces/gui/e2e/fixtures.ts+++ b/surfaces/gui/e2e/fixtures.ts@@ -379,7 +379,11 @@ const PROVIDERS = [{ name: "openai", title: "OpenAI", needs_key: true, fields: [{ key: "api_key", label: "OpenAI API key", secret: true, required: true, help: "", placeholder: "sk-…" }], configured: true, values: {}, suggested_models: ["gpt-5.5"], key_set_at: "2026-06-12", last_used_at: Math.floor(Date.now() / 1000) - 7200 },// anthropic: configured but never used ("Not used yet").{ name: "anthropic", title: "Claude (Anthropic)", needs_key: true, fields: [{ key: "api_key", label: "API key", secret: true, required: true, help: "", placeholder: "sk-…" }], configured: true, values: {}, suggested_models: ["claude-opus-4-8"], key_set_at: null, last_used_at: null },+ // azure: the user's own resource — a REQUIRED endpoint field (plain row, not the custom-endpoint+ // disclosure) ahead of the key; no suggested models (ids are deployment names).+ { name: "azure", title: "Azure OpenAI", needs_key: true, blurb: "Your own Azure OpenAI or Foundry resource, through its v1 API — model ids are your deployment names.", fields: [{ key: "endpoint", label: "Endpoint", secret: false, required: true, help: "Your resource's endpoint, from Keys and Endpoint in the Azure portal or the Foundry portal. /openai/v1 is added automatically; Foundry (…services.ai.azure.com) and sovereign-cloud hosts work too.", placeholder: "https://<resource>.openai.azure.com" }, { key: "api_key", label: "Azure OpenAI API key", secret: true, required: true, help: "", placeholder: "" }], configured: false, values: {}, suggested_models: [], key_set_at: null, last_used_at: null },// zai: an OpenAI-compatible vendor — unconfigured, with a prefilled editable endpoint + blurb.+{ name: "zai", title: "Z AI (GLM)", needs_key: true, blurb: "Uses Z AI's OpenAI-compatible API — the endpoint is prefilled, just add your key.", fields: [{ key: "api_key", label: "Z AI API key", secret: true, required: true, help: "", placeholder: "" }, { key: "base_url", label: "Endpoint", secret: false, required: false, help: "Prefilled with Z AI's international endpoint.", placeholder: "https://api.z.ai/api/paas/v4", default: "https://api.z.ai/api/paas/v4" }], configured: false, values: {}, suggested_models: ["glm-5.2"], key_set_at: null, last_used_at: null },// Ark uses two provider identities: BytePlus pay-as-you-go and Volcengine Agent Plan CN// have independent credentials, endpoints, and strict curated model lists.diff --git a/surfaces/gui/e2e/provider-keys.spec.ts b/surfaces/gui/e2e/provider-keys.spec.tsindex 9dc451aa..4628b555 100644--- a/surfaces/gui/e2e/provider-keys.spec.ts+++ b/surfaces/gui/e2e/provider-keys.spec.ts@@ -93,3 +93,32 @@ test("the subscription provider signs in from the browser flow, no key form", asawait page.getByTestId("set-back").click();await expect(card).toContainText("Sign in with your plan");});++test("Azure OpenAI: the endpoint is a plain required field, saved with the key", async ({+ page,+}) => {+ // The Azure card (issue #457) replaces the old trick of pasting an Azure /openai/v1 URL+ // into the OpenAI card's custom endpoint. Its endpoint is a first-class required field,+ // rendered as an ordinary row — not behind the "Custom endpoint" disclosure.+ await openModels(page);+ await page.getByTestId("set-provider-azure").click();+ await expect(page.getByTestId("set-field-endpoint")).toBeVisible();+ await expect(page.getByTestId("set-endpoint-link")).toHaveCount(0);+ await expect(page.getByText("model ids are your deployment names")).toBeVisible();+ await expect(page.getByText("portal.azure.com")).toBeVisible();++ await page.getByTestId("set-field-endpoint").fill("https://contoso.openai.azure.com");+ await page.getByTestId("set-field-api_key").fill("azure-key-1234");+ await page.getByTestId("set-test").click();+ await expect(page.getByTestId("set-saved-pill")).toContainText("Tested & saved");+ await expect(page.getByTestId("set-provider-azure")).toContainText("✓ Connected", {+ timeout: 5_000,+ });++ // Reopened: the endpoint is served back from the stored values, the key never is, and+ // the models section says what an Azure model id is.+ await page.getByTestId("set-provider-azure").click();+ await expect(page.getByTestId("set-field-endpoint")).toHaveValue("https://contoso.openai.azure.com");+ await expect(page.getByTestId("set-field-api_key")).toHaveValue("");+ await expect(page.getByTestId("set-azure-deployment-note")).toContainText("deployment name");+});diff --git a/surfaces/gui/e2e/settings.spec.ts b/surfaces/gui/e2e/settings.spec.tsindex 008c38c4..91ca111d 100644--- a/surfaces/gui/e2e/settings.spec.ts+++ b/surfaces/gui/e2e/settings.spec.ts@@ -88,7 +88,8 @@ test("Models: provider gallery states; vendor form previews models", async ({ paawait expect(page.getByTestId("set-provider-ollama")).toContainText("No key needed");await expect(page.getByTestId("provider-group-local")).toContainText("Ollama");await expect(page.getByTestId("set-provider-zai")).not.toHaveClass(/bg-panel/);- // Five API-key providers fit under the fold; the "Show N more" line only appears past six.+ // Six API-key providers fit under the fold; the "Show N more" line only appears past six.+await expect(page.getByTestId("provider-more-api_key")).toHaveCount(0);await expect(page.getByTestId("pick-model-btn")).toBeVisible();await expect(page.getByTestId("provider-search")).toBeVisible();diff --git a/surfaces/gui/src/components/ManageTabs.tsx b/surfaces/gui/src/components/ManageTabs.tsxindex 920b7f68..a666875b 100644--- a/surfaces/gui/src/components/ManageTabs.tsx+++ b/surfaces/gui/src/components/ManageTabs.tsx@@ -197,7 +197,14 @@ export function ModelsTab() {<p className="text-meta text-muted mb-2.5 leading-relaxed">{t("manage.models_help")}</p>+ {ps.sel === "azure" && (+ // No catalogue on Azure: the id to add is the deployment's name.+ <p className="text-meta text-muted mb-2.5 leading-relaxed" data-testid="set-azure-deployment-note">+ {t("manage.azure_deployment_help")}+ </p>+ )}<ModelChecklist+provider={ps.sel}knownProviders={knownNames}suggested={info?.suggested_models || []}diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex c1fecfe0..c023fb94 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -1326,6 +1326,8 @@"mcp_waiting_browser": "waiting for browser…","models": "Models","models_help": "Ticked models show in the composer's picker; the black badge marks the default for new sessions.",+ "azure_deployment_help": "On Azure the model id is your deployment name — add each deployment you want to use, as named in the Azure or Foundry portal.",+"one_click_coming": "One-click sign-in is coming soon — connect manually below for now:","optional": "(optional)","or_connect_manually": "or connect manually:",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex fa111121..26cbd7f0 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -1309,6 +1309,8 @@"mcp_waiting_browser": "正在等待浏览器…","models": "模型","models_help": "已勾选的模型会显示在输入框的选择器中;黑色徽标表示新会话的默认模型。",+ "azure_deployment_help": "在 Azure 上,模型 ID 就是你的部署名称——按 Azure 或 Foundry 门户中的名称,逐个添加你要使用的部署。",+"one_click_coming": "一键登录即将推出 —— 目前请在下方手动连接:","optional": "(可选)","or_connect_manually": "或手动连接:",diff --git a/surfaces/gui/src/providers/ProviderSetup.test.tsx b/surfaces/gui/src/providers/ProviderSetup.test.tsxindex 3ac4ed04..34538812 100644--- a/surfaces/gui/src/providers/ProviderSetup.test.tsx+++ b/surfaces/gui/src/providers/ProviderSetup.test.tsx@@ -39,13 +39,35 @@ const BEDROCK: ProviderInfo = {],};-function makePs(fields: Record<string, string>, setFieldValue = vi.fn()): ProviderSetupState {+// Azure OpenAI: a REQUIRED non-secret endpoint ahead of the key — a plain field row, since it+// is keyed `endpoint`, not `base_url` (which the form folds behind the custom-endpoint link).+const AZURE: ProviderInfo = {+ name: "azure",+ title: "Azure OpenAI",+ needs_key: true,+ configured: false,+ values: {},+ suggested_models: [],+ recommended_model: null,+ blurb: "Your own Azure OpenAI or Foundry resource, through its v1 API — model ids are your deployment names.",+ fields: [+ { key: "endpoint", label: "Endpoint", secret: false, required: true, help: "/openai/v1 is added automatically.", placeholder: "https://<resource>.openai.azure.com" },+ { key: "api_key", label: "Azure OpenAI API key", secret: true, required: true, help: "", placeholder: "" },+ ],+};++function makePs(+ fields: Record<string, string>,+ setFieldValue = vi.fn(),+ info: ProviderInfo = BEDROCK,+): ProviderSetupState {return {- providers: [BEDROCK],- ordered: [BEDROCK],+ providers: [info],+ ordered: [info],refreshProviders: async () => {},- sel: "bedrock",- info: BEDROCK,+ sel: info.name,+ info,+fields,setFieldValue,dirty: false,@@ -136,3 +158,24 @@ describe("Atlas Cloud provider presentation", () => {expect(container.querySelector("img")).not.toBeNull();});});++describe("Azure OpenAI provider presentation", () => {+ it("renders the endpoint as a plain required row, not the custom-endpoint disclosure", () => {+ render(<ProviderForm ps={makePs({}, vi.fn(), AZURE)} tp="t" />);+ const endpoint = screen.getByTestId("t-field-endpoint") as HTMLInputElement;+ expect(endpoint.type).toBe("text");+ expect(endpoint.placeholder).toBe("https://<resource>.openai.azure.com");+ expect(screen.queryByTestId("t-endpoint-link")).toBeNull();+ // Test sits beside the key (the required secret), as on every keyed card.+ expect(screen.getByTestId("t-field-api_key")).toBeTruthy();+ expect(screen.getByTestId("t-test")).toBeTruthy();+ expect(screen.getByText(/deployment names/)).toBeTruthy();+ });++ it("links to the Azure portal for a key and wears the bundled mark", () => {+ expect(KEY_HELP.azure.label).toBe("portal.azure.com");+ expect(KEY_HELP.azure.url).toMatch(/^https:\/\/portal\.azure\.com\//);+ const { container } = render(<ProviderMark name="azure" title="Azure OpenAI" />);+ expect(container.querySelector("img")).not.toBeNull();+ });+});diff --git a/surfaces/gui/src/providers/ProviderSetup.tsx b/surfaces/gui/src/providers/ProviderSetup.tsxindex 1227b51f..8469cb34 100644--- a/surfaces/gui/src/providers/ProviderSetup.tsx+++ b/surfaces/gui/src/providers/ProviderSetup.tsx@@ -34,6 +34,9 @@ const LOCAL_HELP: Record<string, { desc: string; link: string; url: string }> =export const KEY_HELP: Record<string, { url: string; label: string; labelKey?: string }> = {anthropic: { url: "https://console.anthropic.com/settings/keys", label: "console.anthropic.com" },openai: { url: "https://platform.openai.com/api-keys", label: "platform.openai.com" },+ // The Azure portal's Azure OpenAI hub: pick the resource, then Keys and Endpoint.+ azure: { url: "https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI", label: "portal.azure.com" },+gemini: { url: "https://aistudio.google.com/apikey", label: "aistudio.google.com" },ark: { url: "https://console.byteplus.com/ark/region:ark+ap-southeast-1/apiKey", label: "console.byteplus.com" },"ark-agent-plan-cn": { url: "https://console.volcengine.com/ark/region:cn-beijing/openManagement?LLM=%7B%7D&advancedActiveKey=agentPlan", label: "console.volcengine.com" },diff --git a/surfaces/gui/src/providers/logos.ts b/surfaces/gui/src/providers/logos.tsindex 7e2995e9..ddb0cd95 100644--- a/surfaces/gui/src/providers/logos.ts+++ b/surfaces/gui/src/providers/logos.ts@@ -7,6 +7,9 @@import anthropic from "./logos/anthropic.svg";import openai from "./logos/openai.svg";+// Azure: a simplified "A" mark drawn in-house in Azure blues (no vendored asset).+import azure from "./logos/azure.svg";+import gemini from "./logos/gemini.svg";import byteplus from "./logos/byteplus.svg";import volcengine from "./logos/volcengine.svg";@@ -44,7 +47,9 @@ export const PROVIDER_LOGOS: Record<string, string> = {// The subscription provider wears the same vendor mark — it's the same models,// different billing (owner call 2026-08-21: no bare-letter monogram)."openai-codex": openai,+ azure,gemini,+ark: byteplus,"ark-agent-plan-cn": volcengine,meta,@@ -79,8 +84,10 @@ export const PROVIDER_LOGOS: Record<string, string> = {export const PROVIDER_ORDER = ["anthropic","openai",+ "azure","gemini","ark",+"ark-agent-plan-cn","meta","ollama",diff --git a/surfaces/gui/src/providers/logos/azure.svg b/surfaces/gui/src/providers/logos/azure.svgnew file mode 100644index 00000000..f8228d1b--- /dev/null+++ b/surfaces/gui/src/providers/logos/azure.svg@@ -0,0 +1 @@+<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Azure OpenAI</title><path d="M8.3 2.5h5.5L8 20.2a1.1 1.1 0 01-1.05.76H2.35a1.1 1.1 0 01-1.04-1.46L7.25 3.26A1.1 1.1 0 018.3 2.5z" fill="#1E8BE0"/><path d="M15.2 2.5h.95c.47 0 .89.3 1.04.75l5.46 16.25a1.1 1.1 0 01-1.04 1.46H11.3l7.34-2.6-4.9-5.86L15.2 2.5z" fill="#1E8BE0" fill-opacity=".55"/><path d="M14 9.24l4.64 5.12-7.34 2.6-4.5 3.26 9.13-.06c.56 0 .9-.6.63-1.08L14 9.24z" fill="#0F62B8"/></svg>diff --git a/tests/test_provider_router.py b/tests/test_provider_router.pyindex ccf9bdd8..d399566d 100644--- a/tests/test_provider_router.py+++ b/tests/test_provider_router.py@@ -653,3 +653,49 @@ def test_manager_key_hygiene_stamps(tmp_path, monkeypatch):mgr2 = SessionManager(data_dir=tmp_path)provs2 = {p["name"]: p for p in mgr2.get_providers()}assert provs2["deepseek"]["last_used_at"] == first+++def test_manager_azure_card_saves_endpoint_and_key_and_verifies_at_the_resource(+ tmp_path, monkeypatch+):+ """Settings ▸ Models for Azure OpenAI: both fields are required to save; the stored+ endpoint comes back for prefilling, the key never does; Test probes the resource with+ the merged (stored + typed) fields; nothing is auto-added to the picker (no catalogue)."""+ monkeypatch.setenv("COWORKER_STATE_DIR", str(tmp_path / "state"))+ monkeypatch.delenv("AZURE_OPENAI_API_KEY", raising=False)+ from coworker.server.manager import SessionManager++ mgr = SessionManager(data_dir=tmp_path)+ res = mgr.set_provider("azure", {"api_key": "az-key"})+ assert res["ok"] is False and "Endpoint" in res["error"]+ res = mgr.set_provider(+ "azure", {"endpoint": "https://contoso.openai.azure.com", "api_key": "az-key"}+ )+ assert res["ok"] and res["recommended_model"] is None++ row = next(p for p in mgr.get_providers() if p["name"] == "azure")+ assert row["configured"] is True+ assert row["values"] == {"endpoint": "https://contoso.openai.azure.com"}+ assert row["suggested_models"] == []+ assert "api_key" not in row["values"]+ assert not any(m.startswith("azure:") for m in mgr.get_settings()["models"])++ # Test with the stored credentials: the probe goes to the resource's v1 model list.+ seen: dict = {}++ def fake_get(url, **kwargs):+ seen["url"] = url+ seen.update(kwargs)+ from types import SimpleNamespace++ return SimpleNamespace(status_code=200)++ monkeypatch.setattr("httpx.get", fake_get)+ assert mgr.verify_provider("azure", {}) == {"ok": True}+ assert seen["url"] == "https://contoso.openai.azure.com/openai/v1/models"+ assert seen["headers"]["Authorization"] == "Bearer az-key"++ # A deployment the user adds routes to the azure provider.+ added = mgr.add_model("azure:gpt-5-prod")+ assert added["ok"] and "azure:gpt-5-prod" in added["models"]+ assert mgr._model_provider("azure:gpt-5-prod") == "azure"diff --git a/tests/test_provider_verify.py b/tests/test_provider_verify.pyindex c16fd857..2f990fa4 100644--- a/tests/test_provider_verify.py+++ b/tests/test_provider_verify.py@@ -314,3 +314,46 @@ def test_verify_silent_exception_falls_back_to_class_name_only(monkeypatch):_patch_get(monkeypatch, raise_exc=Weird())assert verify_provider_key("openai", api_key="sk-x") == {"ok": False, "error": "Couldn't reach OpenAI (Weird)."}+++# -- verify_provider_key: Azure OpenAI probes the user's resource, never api.openai.com ----+def test_verify_azure_lists_models_at_the_resource_v1_api(monkeypatch):+ cap: dict = {}+ _patch_get(monkeypatch, status=200, capture=cap)+ assert verify_provider_key(+ "azure", api_key="az-key", fields={"endpoint": "https://contoso.openai.azure.com"}+ ) == {"ok": True}+ assert cap["url"] == "https://contoso.openai.azure.com/openai/v1/models"+ assert cap["headers"]["Authorization"] == "Bearer az-key"+ # One probe: /openai/v1 is always normalised in, so no completions-route check follows.+ assert [c["url"] for c in cap["calls"]] == ["https://contoso.openai.azure.com/openai/v1/models"]+ assert not any("api.openai.com" in c["url"] for c in cap["calls"])+++def test_verify_azure_accepts_an_endpoint_already_on_v1(monkeypatch):+ cap: dict = {}+ _patch_get(monkeypatch, status=200, capture=cap)+ verify_provider_key(+ "azure", api_key="az-key", fields={"endpoint": "https://contoso.openai.azure.com/openai/v1/"}+ )+ assert cap["url"] == "https://contoso.openai.azure.com/openai/v1/models"+++def test_verify_azure_without_an_endpoint_asks_for_one_without_a_request(monkeypatch):+ cap: dict = {}+ _patch_get(monkeypatch, status=200, capture=cap)+ res = verify_provider_key("azure", api_key="az-key", fields={})+ assert res["ok"] is False and "endpoint" in res["error"].lower()+ assert "calls" not in cap+++def test_verify_azure_bad_key_and_wrong_host_read_differently(monkeypatch):+ _patch_get(monkeypatch, status=401)+ assert verify_provider_key(+ "azure", api_key="az-bad", fields={"endpoint": "https://contoso.openai.azure.com"}+ ) == {"ok": False, "error": "Invalid API key."}+ _patch_get(monkeypatch, status=404)+ res = verify_provider_key(+ "azure", api_key="az-key", fields={"endpoint": "https://example.com"}+ )+ assert res["ok"] is False and "no Azure OpenAI v1 API" in res["error"]diff --git a/tests/test_providers.py b/tests/test_providers.pyindex 6785471b..d7e87b4a 100644--- a/tests/test_providers.py+++ b/tests/test_providers.py@@ -5,6 +5,9 @@ from __future__ import annotationsimport jsonfrom types import SimpleNamespace+import pytest++from coworker.providers import (AssistantTurn,ModelCapabilities,@@ -680,3 +683,132 @@ def test_over_limit_max_tokens_is_dropped_and_retried():calls = client.chat.completions.callsassert turn.text == "ok" and len(calls) == 2assert "max_tokens" not in calls[1]+++# -- Azure OpenAI (its own card, issue #457) ---------------------------------------------+# Verified against learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle+# (read 2026-10-26): base URL = resource endpoint + `/openai/v1`, no api-version, the stock+# OpenAI client with an API key; the model id is the deployment name.+++def test_azure_descriptor_shape():+ from coworker.providers.registry import get_descriptor++ d = get_descriptor("azure")+ assert d is not None and d.needs_key and d.kind == "api_key"+ assert d.title == "Azure OpenAI"+ assert [f.key for f in d.fields] == ["endpoint", "api_key"]+ endpoint, key = d.fields+ # The endpoint is a REQUIRED plain field — keyed `endpoint`, not `base_url`, so the GUI+ # renders it as an ordinary row instead of folding it behind the custom-endpoint link.+ assert endpoint.required and not endpoint.secret+ assert key.required and key.secret+ assert d.env_key == "AZURE_OPENAI_API_KEY"+ assert d.recommended_model is None # no catalogue: ids are deployment names+ assert "deployment" in d.blurb+++ "pasted,expected",+ [+ ("https://contoso.openai.azure.com", "https://contoso.openai.azure.com/openai/v1"),+ ("https://contoso.openai.azure.com/", "https://contoso.openai.azure.com/openai/v1"),+ (" https://contoso.openai.azure.com/openai/v1/ ", "https://contoso.openai.azure.com/openai/v1"),+ ("https://contoso.openai.azure.com/openai", "https://contoso.openai.azure.com/openai/v1"),+ # Foundry and sovereign-cloud hosts are not second-guessed — any https host goes.+ ("https://contoso.services.ai.azure.com", "https://contoso.services.ai.azure.com/openai/v1"),+ ("https://contoso.openai.azure.us/", "https://contoso.openai.azure.us/openai/v1"),+ ("contoso.openai.azure.com", "https://contoso.openai.azure.com/openai/v1"),+ # A request URL copied from the portal: path and api-version query dropped.+ (+ "https://contoso.openai.azure.com/openai/deployments/gpt-5/chat/completions?api-version=2024-10-21",+ "https://contoso.openai.azure.com/openai/v1",+ ),+ ("", ""),+ (None, ""),+ ],+)+def test_azure_endpoint_normalisation(pasted, expected):+ from coworker.providers.registry import normalize_azure_endpoint++ assert normalize_azure_endpoint(pasted) == expected+++def test_azure_builder_targets_the_v1_api_with_the_profile_key():+ from coworker.providers.openai_provider import OpenAIProvider+ from coworker.providers.registry import build_provider_client++ p = build_provider_client(+ "azure", {"endpoint": "https://contoso.openai.azure.com", "api_key": "az-key"}, None+ )+ assert isinstance(p, OpenAIProvider) # Chat Completions, as the custom-endpoint path did+ assert p._base_url == "https://contoso.openai.azure.com/openai/v1"+ assert p._api_key == "az-key"+++def test_azure_builder_env_key_fallback(monkeypatch):+ from coworker.providers.registry import build_provider_client++ monkeypatch.setenv("AZURE_OPENAI_API_KEY", "az-env")+ p = build_provider_client("azure", {"endpoint": "https://contoso.openai.azure.com/openai/v1"}, None)+ assert p._api_key == "az-env"+++def test_azure_builder_never_leaks_the_openai_key(monkeypatch):+ """Same guard as the compat vendors: an OpenAI key (env or SecretStore) is never sent+ to an Azure host — a missing Azure key fails fast, naming Azure."""+ from coworker.providers.registry import build_provider_client++ class Store:+ def get(self, name):+ return {"api_key": "sk-openai-stored"} if name == "provider:openai" else None++ monkeypatch.setenv("OPENAI_API_KEY", "sk-openai-real")+ monkeypatch.delenv("AZURE_OPENAI_API_KEY", raising=False)+ with pytest.raises(RuntimeError, match="Azure OpenAI API key"):+ build_provider_client("azure", {"endpoint": "https://contoso.openai.azure.com"}, Store())+++def test_azure_builder_requires_an_endpoint(monkeypatch):+ from coworker.providers.registry import build_provider_client++ with pytest.raises(RuntimeError, match="endpoint"):+ build_provider_client("azure", {"api_key": "az-key"}, None)+++def test_azure_configured_needs_endpoint_and_key(monkeypatch):+ """An env key alone is not a working setup — there is nowhere to send it."""+ from coworker.providers.registry import descriptor_configured, get_descriptor++ d = get_descriptor("azure")+ monkeypatch.delenv("AZURE_OPENAI_API_KEY", raising=False)+ assert not descriptor_configured(d, {})+ assert not descriptor_configured(d, {"api_key": "k"})+ assert not descriptor_configured(d, {"endpoint": "https://c.openai.azure.com"})+ assert descriptor_configured(d, {"endpoint": "https://c.openai.azure.com", "api_key": "k"})+ monkeypatch.setenv("AZURE_OPENAI_API_KEY", "env")+ assert not descriptor_configured(d, {})+ assert descriptor_configured(d, {"endpoint": "https://c.openai.azure.com"})+++def test_azure_models_route_by_prefix_and_default_to_agentic_capabilities():+ from coworker.providers.capabilities import capabilities_for+ from coworker.providers.router import ProviderRouter++ router = ProviderRouter(secrets=None)+ assert router._provider_name("azure:my-gpt-deployment") == "azure"+ assert ProviderRouter._bare("azure:my-gpt-deployment") == "my-gpt-deployment"+ # An arbitrary deployment name: tools + parallel calls, no vision claimed.+ caps = capabilities_for("azure:my-gpt-deployment")+ assert caps.tools and caps.parallel_tool_calls and caps.streaming and not caps.vision+ # A deployment named after the model keeps the model's own profile.+ assert capabilities_for("azure:gpt-5.5").vision+ assert not capabilities_for("azure:o4-mini").parallel_tool_calls+++def test_openai_custom_endpoint_help_points_azure_users_at_the_card():+ from coworker.providers.registry import get_descriptor++ base = next(f for f in get_descriptor("openai").fields if f.key == "base_url")+ assert "Azure OpenAI has its own card" in base.help+ assert not base.required # the old Azure-URL-in-OpenAI setup keeps working