Skip to content

Add Azure OpenAI and Claude in Foundry presets with the resource and deployment asked at sign-in - #175

Merged
Zezi Zeng (ClarenceStark) merged 3 commits into
mainfrom
feat/azure-preset
Dec 5, 2026
Merged

Zezi Zeng (ClarenceStark) merged 3 commits into
mainfrom
feat/azure-preset

Conversation

@ClarenceStark

Copy link
Copy Markdown
Collaborator

Linked issue

Follows #173 (Amazon Bedrock), which this builds on: the base is feat/bedrock-preset, so the diff shows only the
Azure change. Once #173 is merged this will be rebased onto main. No prior issue: Azure was asked for alongside
Bedrock.

What changed (Before / After)

  • Before: reaching Azure OpenAI or Claude in Microsoft Foundry meant hand-configuring a custom connection.
  • After: two presets, each with an API key under the variable its vendor's own SDK reads:
    • freehand login azure: Azure OpenAI through the v1 Responses API
      (https://{resource}.openai.azure.com/openai/v1, the address Microsoft's v1 docs give for the OpenAI SDK),
      key AZURE_OPENAI_API_KEY.
    • freehand login azure-claude: Claude in Microsoft Foundry through Anthropic Messages
      (https://{resource}.services.ai.azure.com/anthropic, the base URL the Anthropic SDK's Foundry client uses),
      key ANTHROPIC_FOUNDRY_API_KEY.
  • Azure calls a model by the name of the person's deployment, so sign-in asks for the resource and the deployment
    (--resource, --deployment, the terminal sign-in, the browser's Models settings). The preset's model is only the
    name offered first.
  • The places an address leaves open are now one mechanism (session.PLACES: {region} from Add Amazon Bedrock service presets with a region asked at sign-in #173 and
    {resource}), each with a pattern that keeps the address on the service's host. Without a resource nothing is
    saved, and the browser refuses an address left open.
  • No provider code changed: the Responses provider already sends the key as a bearer token (which the OpenAI SDK does
    against Azure's v1 API) and uses WebSocket mode only on api.openai.com; Foundry's Messages endpoint authenticates
    with x-api-key, as the Anthropic provider sends it.

Out of scope: Microsoft Entra ID sign-in, other Foundry models (DeepSeek, Grok) as presets.

Visual proof (UI / TUI / Web / Desktop / export changes)

Browser, Settings → Models (clean temporary FREEHAND_HOME): "Azure OpenAI" and "Azure Foundry Claude" tiles; the
form asks for Resource, Deployment (prefilled with the default model) and API key. CLI:

$ echo "$KEY" | freehand login azure
Enter a resource name like my-resource. Pass --resource.
$ echo "$KEY" | freehand login azure --resource contoso-ai --deployment prod-gpt
New sessions use Azure OpenAI.

How you verified it

  • New tests/test_azure.py: CLI login for both presets, malformed or missing resources save nothing, service
    recognition (and OpenAI's own address is still OpenAI), the browser presets and the open-address guard, the legacy
    key endpoint refuses before writing, and against fake servers the request path, auth header and deployment name.
  • TUI: first start → another service → Azure OpenAI → resource → deployment → key (tests/test_terminal.py).
  • Browser (Chrome over CDP): add Azure OpenAI, a missing resource is refused, then saved (tests/test_web_e2e.py).
  • pyflakes and the affected test files locally (264 passed).
  • Not run against the live Azure API: no Azure account was available.

AI disclosure & checklist

  • AI disclosure: AI-assisted (personally tested and verified)
  • uv run pyflakes src tests .github/scripts prints nothing and relevant tests pass locally (full suite runs in CI)
  • Left CHANGELOG.md untouched: added an "Added" line under Unreleased, as AGENTS.md asks
  • No change to what the model sees (prompt, tool descriptions, status line, notes), or benchmark evidence attached
  • src/freehand/runtime/ still uses only the standard library and imports on Python 3.9 (untouched)

freehand login bedrock reaches Claude through Bedrock's Anthropic Messages
endpoint and freehand login bedrock-openai its OpenAI-compatible Chat
Completions endpoint, both with one Bedrock API key saved under
AWS_BEARER_TOKEN_BEDROCK. A preset's address may name {region}: the CLI
(--region, AWS_REGION), the terminal sign-in and the browser's Models
settings ask for it, and connections in any region are recognized as the
service. Refs #98.
…deployment asked at sign-in

freehand login azure reaches Azure OpenAI's v1 Responses API and
freehand login azure-claude Claude in Microsoft Foundry, each with an
API key under the variable its vendor's SDK reads. The places a preset's
address leaves open ({region}, {resource}) are now one mechanism, each
with a pattern that keeps the address on the service's host; Azure
presets also ask for the deployment the model is called by, in the CLI
(--resource, --deployment), the terminal sign-in and the browser.
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Thanks for the pull request! A few friendly reminders based on the files changed:

  • CHANGELOG.md: Ordinary PRs should leave CHANGELOG.md untouched to avoid merge conflicts; maintainers update it at release time.

(This comment updates automatically when you edit the PR description or push new commits.)

@ClarenceStark
Zezi Zeng (ClarenceStark) merged commit 2859e7c into main Dec 5, 2026
32 of 34 checks passed
@ClarenceStark
Zezi Zeng (ClarenceStark) deleted the feat/azure-preset branch December 5, 2026 16:26
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