Claude Code with Azure OpenAI Setup

Written by Michael Lip · Solo founder of Zovo · $400K+ on Upwork · 100% JSS Join 50+ builders · More at zovo.one

Using Claude Code in projects that also rely on Azure OpenAI requires careful configuration of API keys, endpoints, and model routing. This guide covers how to set up Claude Code alongside Azure OpenAI services, manage multiple AI providers, and build workflows that leverage both platforms effectively.

The Problem

Many enterprise teams use Azure OpenAI for production inference (GPT-4, embeddings, completions) while wanting Claude Code for development assistance. Managing two sets of API credentials, keeping model references consistent, and avoiding accidental cross-contamination of keys creates friction. Developers need a clean separation between their coding assistant and their application’s AI backend.

Quick Solution

  1. Set up Azure OpenAI credentials as environment variables for your application:
export AZURE_OPENAI_API_KEY="your-azure-openai-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT="gpt-4"
export AZURE_OPENAI_API_VERSION="2024-10-21"
  1. Keep Claude Code’s Anthropic API key separate:
export ANTHROPIC_API_KEY="your-anthropic-key"
  1. Create a .env file for your application (not for Claude Code):
# .env - Application AI config (Azure OpenAI)
AZURE_OPENAI_API_KEY=your-azure-openai-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_DEPLOYMENT=gpt-4
AZURE_OPENAI_API_VERSION=2024-10-21
  1. Add .env to your .gitignore to prevent credential leaks:
echo ".env" >> .gitignore
  1. Document the dual-provider setup in CLAUDE.md so Claude Code understands the architecture.

How It Works

Claude Code uses the Anthropic API for its own operation and has no direct interaction with Azure OpenAI. The separation is architectural: Claude Code is your development tool, while Azure OpenAI is your application’s AI backend.

When Claude Code reads your codebase, it sees Azure OpenAI SDK calls, endpoint configurations, and deployment names. By documenting these in CLAUDE.md, Claude Code understands the distinction and can help you write, debug, and optimize your Azure OpenAI integration code without confusing its own API context.

For teams using Claude Code with an Anthropic API key alongside Azure OpenAI in production, the key insight is environment isolation. Your application reads from .env or Azure Key Vault. Claude Code reads from its own configuration. The two never overlap.

Common Issues

API key confusion: Claude Code may suggest using OPENAI_API_KEY when your setup uses AZURE_OPENAI_API_KEY. Add explicit notes in CLAUDE.md about which environment variable names your project uses.

SDK version mismatch: Azure OpenAI SDK versions change frequently. If Claude Code suggests API calls that fail, specify the exact SDK version in your CLAUDE.md so it generates compatible code.

Endpoint format errors: Azure OpenAI endpoints follow the pattern https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version={version}. Claude Code may default to the standard OpenAI format. Document the exact URL pattern.

Example CLAUDE.md Section

# AI Provider Architecture

## Development Tool (Claude Code)
- Uses Anthropic API via ANTHROPIC_API_KEY
- Not part of the application runtime

## Application AI Backend (Azure OpenAI)
- Endpoint: https://acme-ai.openai.azure.com
- Deployment: gpt-4-turbo (model: gpt-4-1106-preview)
- Embedding deployment: text-embedding-3-large
- API Version: 2024-10-21
- SDK: @azure/openai v2.1.0

## Code Patterns
- All Azure OpenAI calls go through src/lib/ai-client.ts
- Use AzureOpenAI class, NOT OpenAI class
- Always pass deployment name, not model name
- Retry with exponential backoff on 429 errors
- Token counting uses tiktoken with cl100k_base encoding

Best Practices



I'm a solo developer in Vietnam. 50K Chrome extension users. $500K+ on Upwork. 5 Claude Max subscriptions running agent fleets in parallel. These are my actual CLAUDE.md templates, orchestration configs, and prompts. Not a course. Not theory. The files I copy into every project before I write a line of code. **[See what's inside →](https://zovo.one/lifetime?utm_source=ccg&utm_medium=cta-default&utm_campaign=claude-code-azure-openai)** $99 once. Free forever. 47/500 founding spots left.

Related Reading

Built by theluckystrike. More at zovo.one