agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

feat(providers): add Azure OpenAI provider

Open nagarjunr opened this issue 7 months ago • 4 comments

Summary

Adds support for Azure OpenAI Service as an LLM provider for compression, summarization, and graph extraction.

Changes

  • src/providers/azure-openai.ts (new) — AzureOpenAIProvider class. Constructs the Azure-style URL (/openai/deployments/{name}/chat/completions?api-version=...), uses api-key header instead of Authorization: Bearer, otherwise follows the same OpenAI-compatible request/response shape as the existing OpenRouterProvider.

  • src/types.ts — adds "azure-openai" to the ProviderType union.

  • src/config.ts — detects all three required Azure env vars and returns provider: "azure-openai" config; updates detectLlmProviderKind() to return "llm" when Azure vars are set; updates the "no key found" error message.

  • src/providers/index.ts — wires the case "azure-openai" branch into createBaseProvider.

  • src/viewer/index.html — updates the "No LLM provider key set" flag banner to show both Anthropic and Azure setup instructions.

Usage

Add to ~/.agentmemory/.env:

AZURE_OPENAI_API_KEY=<your-azure-api-key>
AZURE_OPENAI_ENDPOINT=https://<resource-name>.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=<deployment-name>

# Optional — defaults to 2024-08-01-preview
AZURE_OPENAI_API_VERSION=2024-08-01-preview

Then restart: npx @agentmemory/agentmemory

Test plan

  • [ ] Server starts without error when all three Azure env vars are set
  • [ ] provider shows as azure-openai in health endpoint response
  • [ ] Compression runs successfully against an Azure-hosted deployment
  • [ ] Missing AZURE_OPENAI_ENDPOINT or AZURE_OPENAI_DEPLOYMENT falls through to noop (no partial config accepted)
  • [ ] Viewer flag banner shows Azure setup instructions when provider is noop

Summary by CodeRabbit

  • New Features

    • Added Azure OpenAI as a supported LLM provider option
  • Documentation

    • Updated configuration guidance to include Azure OpenAI environment variables as a valid setup alternative

nagarjunr avatar Apr 30 '26 16:04 nagarjunr

Someone is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 30 '26 16:04 vercel[bot]

📝 Walkthrough

Walkthrough

Adds Azure OpenAI provider support to the system. Updates configuration detection to recognize Azure OpenAI environment variables, implements a new AzureOpenAIProvider class for making API calls, integrates the provider into the factory function, extends the ProviderType union, and updates the UI warning banner to mention Azure OpenAI as a configuration option.

Changes

Cohort / File(s) Summary
Type definitions and configuration
src/types.ts, src/config.ts
Added "azure-openai" to ProviderType union. Updated detectProvider to recognize Azure OpenAI environment variables (AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT) and create corresponding provider config. Updated detectLlmProviderKind to identify Azure OpenAI env vars as evidence of an available LLM provider.
Provider implementation
src/providers/azure-openai.ts, src/providers/index.ts
Added new AzureOpenAIProvider class implementing MemoryProvider, handling Azure OpenAI API authentication and chat completions requests. Updated createBaseProvider to instantiate AzureOpenAIProvider when provider type is "azure-openai".
UI updates
src/viewer/index.html
Updated "No LLM provider key set" warning banner to advertise both Anthropic and Azure OpenAI as valid configuration options, including setup instructions for Azure OpenAI environment variables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #154 — Shares related modifications to provider detection and startup warning logic in src/config.ts and provider setup in src/providers/index.ts.
  • #188 — Also modifies detectProvider logic in src/config.ts to adjust provider configuration resolution patterns.
  • #103 — Similar pattern of extending provider type support across config detection, type definitions, and provider factory registration.

Poem

🐰✨ Azure skies now open wide, A new provider hops inside! Config detection, API calls flow— Another LLM's ready to go! 🌈

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Azure OpenAI as a new LLM provider across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 6/8 reviews remaining, refill in 11 minutes and 27 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 30 '26 17:04 coderabbitai[bot]

Hi, The viewer’s "No LLM provider key set" banner now suggests only Anthropic or Azure keys, but the backend also supports Gemini, OpenRouter, and MiniMax; this can misdirect users configuring those providers.

Severity: informational | Category: maintainability

How to fix: List all supported key options

Agent prompt to fix - you can give this to your LLM of choice:

Issue description

The viewer banner shown when cfg.provider === 'noop' now labels keys as ANTHROPIC_API_KEY / AZURE_OPENAI_API_KEY and only provides enable instructions for Anthropic/Azure. This conflicts with supported providers (Gemini/OpenRouter/MiniMax) and can confuse users.

Fix Focus Areas

  • src/viewer/index.html[3318-3326]

Suggested direction

Update keyLabel and the enable snippet to include Gemini/OpenRouter/MiniMax options (or make the label generic and link to docs).


Found by Qodo code review

Qodo-Free-For-OSS avatar May 02 '26 10:05 Qodo-Free-For-OSS

Thanks @nagarjunr — Azure as a first-class provider is overdue, and the auto-detect via the three env triplet is the right shape.

Question on consolidation: you opened #220 right after this with the same Azure provider plus AI Foundry (Anthropic) endpoint support and corporate-proxy tunneling. That looks like a strict superset of this PR.

Would you like to:

Option A — close this in favor of #220 (cleanest, single Azure provider PR with all three capabilities).

Option B — keep this scoped to just standard Azure OpenAI (what's here today), and rebase #220 to be a follow-up that adds the AI Foundry + proxy bits on top. Either works, but bundling makes the review and the CHANGELOG entry simpler.

Let me know which and I'll prioritize whichever stays open. Either way the underlying work lands with your attribution.

rohitg00 avatar May 08 '26 17:05 rohitg00