How to Configure Microsoft Foundry / Azure OpenAI with the OpenClaude VS Code Extension

The OpenClaude VS Code extension provides a built-in configuration wizard that stores your Azure OpenAI endpoint, deployment, and API version in workspace settings while securing the API key in VS Code Secret Storage, then automatically injects the required environment variables when launching the terminal.

The OpenClaude extension bridges Claude Code with Azure OpenAI Service (including Microsoft Foundry-hosted models) through a dedicated configuration system. By leveraging settings defined in vscode-extension/openclaude-vscode/package.json and secure credential storage, the extension translates VS Code preferences into OpenAI-compatible environment variables at runtime. This guide explains how to configure Microsoft Foundry / Azure OpenAI with the OpenClaude VS Code extension using both the interactive wizard and manual configuration methods.

How the Azure OpenAI Integration Works

The extension implements a multi-layer architecture that separates user configuration from runtime environment injection. According to the Gitlawb/openclaude source code, the system relies on four core components working in sequence:

Settings Storage: User-defined parameters live under the openclaude.azure.* namespace in vscode-extension/openclaude-vscode/package.json, including endpoint, apiVersion, deployment, and the optional forceAzureUrlStyle boolean.

Secret Management: The setAzureApiKey and clearAzureApiKey commands in src/extension.js handle API keys through VS Code's Secret Storage API, ensuring credentials never appear in plaintext configuration files.

Configuration Wizard: The configureAzureChat function in extension.js interactively prompts users for endpoint details and writes validated values to workspace settings while toggling the Azure enabled flag.

Environment Builder: At launch time, buildLaunchAzureEnv resolves stored settings and the secret key, constructing variables including OPENAI_BASE_URL, OPENAI_MODEL, AZURE_OPENAI_API_VERSION, OPENAI_API_KEY, and conditionally OPENAI_AZURE_STYLE.

When you execute OpenClaude: Launch in Terminal, the extension merges these variables into the process environment and spawns the OpenClaude CLI with Azure-compatible configuration.

Step-by-Step Configuration Guide

Run the Configuration Wizard

The fastest method to configure Microsoft Foundry / Azure OpenAI uses the built-in wizard accessible from the Command Palette:


# Open the Command Palette (Ctrl/Cmd+Shift+P) and run:

OpenClaude: Configure Azure / Foundry Chat (wizard)

The wizard prompts for four required fields:

  • Azure endpoint: Your Azure OpenAI resource URL (e.g., https://your-resource.openai.azure.com)
  • API version: The Azure API version string (e.g., 2024-12-01-preview)
  • Deployment / model: Your deployed model name (e.g., gpt-4o)
  • API key: Entered securely into VS Code Secret Storage

Upon completion, the wizard writes to workspace settings and enables Azure support automatically.

Configure Settings Manually

Advanced users can bypass the wizard by editing .vscode/settings.json directly:

{
  "openclaude.azure.endpoint": "https://your-resource.openai.azure.com",
  "openclaude.azure.apiVersion": "2024-12-01-preview",
  "openclaude.azure.deployment": "gpt-4o",
  "openclaude.azure.forceAzureUrlStyle": true
}

Important: Never paste your API key into settings.json. Use the dedicated Secret Storage command to maintain security.

Store Your API Key Securely

To store credentials safely outside of version-controlled configuration files:


# Command Palette:

OpenClaude: Set Azure / Foundry API Key (Secret Storage)

The extension invokes setAzureApiKey from src/extension.js, encrypts the value using VS Code's Secret Storage, and confirms successful storage. To remove the key later, use the corresponding Clear Azure / Foundry API Key command.

Launching OpenClaude with Azure Environment Variables

When launching through the extension, the buildLaunchAzureEnv function constructs the exact environment variables required by the OpenAI-compatible shim:


# These variables are injected automatically when running:

# Command Palette → OpenClaude: Launch in Terminal

export CLAUDE_CODE_USE_OPENAI=1
export OPENAI_BASE_URL=https://your-resource.openai.azure.com
export OPENAI_MODEL=gpt-4o
export AZURE_OPENAI_API_VERSION=2024-12-01-preview
export OPENAI_API_KEY=••••••••••••••••••
export OPENAI_AZURE_STYLE=1   # Only when forceAzureUrlStyle is enabled

The extension handles this injection transparently. You do not need to manually export these variables or modify your shell configuration.

Forcing Azure-Style Routing for Non-Standard Hosts

Some Microsoft Foundry deployments use non-standard hostnames that the OpenAI shim might not recognize as Azure endpoints. To force Azure-specific request formatting (adding the api-version query parameter and api-key header), enable the force flag:

Via Wizard: Toggle "Force Azure URL style" during configuration.

Via Settings:

{
  "openclaude.azure.forceAzureUrlStyle": true
}

This sets OPENAI_AZURE_STYLE=1 in the launch environment, ensuring the shim applies Azure-specific request transformations regardless of endpoint URL patterns.

Summary

  • The OpenClaude VS Code extension stores Azure OpenAI configuration in the openclaude.azure.* settings namespace defined in package.json.
  • API keys are encrypted using VS Code Secret Storage via the setAzureApiKey command in src/extension.js.
  • The configureAzureChat wizard simplifies setup by validating and writing endpoint, API version, and deployment names.
  • At launch, buildLaunchAzureEnv constructs environment variables including OPENAI_BASE_URL, AZURE_OPENAI_API_VERSION, and OPENAI_API_KEY.
  • Enable openclaude.azure.forceAzureUrlStyle for non-standard Azure deployments to ensure proper request formatting.

Frequently Asked Questions

Where does the OpenClaude extension store my Azure OpenAI API key?

The extension stores your API key in VS Code's Secret Storage using the setAzureApiKey function in src/extension.js. This keeps credentials encrypted and separate from workspace settings files, preventing accidental commits of sensitive data to version control.

Can I use Microsoft Foundry models with OpenClaude, or only Azure OpenAI Service?

Yes, Microsoft Foundry-hosted models are fully supported. The configuration wizard and manual settings accept any OpenAI-compatible endpoint URL. Enable openclaude.azure.forceAzureUrlStyle if your Foundry deployment requires Azure-specific request signatures.

What environment variables does the extension set when launching the terminal?

The buildLaunchAzureEnv function sets CLAUDE_CODE_USE_OPENAI=1, OPENAI_BASE_URL, OPENAI_MODEL, AZURE_OPENAI_API_VERSION, OPENAI_API_KEY, and conditionally OPENAI_AZURE_STYLE. These variables enable the OpenAI shim to translate requests into the Azure OpenAI API format.

How do I switch back to standard Claude Code after configuring Azure?

Clear your Azure API key using the OpenClaude: Clear Azure / Foundry API Key command and disable Azure mode by setting openclaude.azure.enabled to false in your settings. Alternatively, remove the openclaude.azure.* configuration entries entirely to default to standard Claude Code behavior.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →