For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Microsoft Intune
Manage LLM clients with Microsoft Intune and keep them configured for agentgateway
Use Microsoft Intune to install supported LLM clients, configure them to use agentgateway, and repair configuration drift. The endpoint-management workflow applies to both Kubernetes and standalone deployments. This guide uses Codex and Claude Desktop for complete examples and describes the management options for the other supported clients.
Intune manages the client endpoint. Agentgateway remains the enforcement point for authentication, authorization, rate limits, guardrails, and observability.
Before you begin
- Install the
agentgatewaybinary. - Configure the LLM provider that your managed clients use.
- Expose the Gateway through a stable HTTPS hostname that Intune-managed
devices can resolve, such as
https://llm.example.com. - Enroll your test devices in Intune by following the Windows enrollment guide or the macOS enrollment guide.
- Review the configuration guide for each supported LLM client that you plan to manage.
For standalone, terminate TLS on agentgateway by following the HTTPS listener configuration. Use a certificate whose subject alternative name matches the managed hostname and whose issuer is trusted by the client devices.
Warning
Do not use a port-forward, localhost address, or temporary load balancer address in a managed configuration. Never include an upstream LLM provider key in an Intune profile or remediation script. A static agentgateway client key is acceptable only for a limited pilot because an administrator of the managed device can recover it.
Plan the Intune policy
Use four controls for each managed client.
- Required application: Deploy the client as a required Intune application. Use a Win32 app on Windows. On macOS, use a DMG app when the vendor image contains the application bundle, or an unmanaged PKG app when the vendor supplies a PKG or the installation requires scripts or custom packaging. For either macOS app type, set Ignore app version to Yes for a self-updating client so that Intune detects the bundle instead of reinstalling an older uploaded version. To enforce an exact version, set it to No, control the client’s auto-update behavior when supported, and upload each approved replacement package.
- Managed configuration: See Choose a management method to identify the supported mechanism for each client. When the client supports native managed policy, deploy that policy through Intune. Otherwise, use a platform script or remediation to manage only the gateway-related settings without overwriting unrelated user configuration.
- Drift enforcement: Prefer native managed policy, such as managed preferences on macOS. For a macOS client without native managed policy, deploy a recurring Intune shell script to detect and restore the approved configuration. On supported Windows devices, Intune Remediations can run on an hourly schedule. Intune Remediations are not available for macOS.
- Compliance and access: On enrolled macOS, Linux, and supported Windows devices, optionally use an Intune custom compliance discovery script to report whether the approved gateway configuration is effective. Custom compliance reports drift but does not repair it. Protect agentgateway separately, and optionally use the device compliance result with Microsoft Entra Conditional Access.
A recurring shell script or Windows remediation is periodic, not continuous. A user can change an ordinary user configuration between evaluations. Native managed policy is stronger, but network and gateway policies are still required if users must not bypass agentgateway with another executable or SDK. These macOS controls apply to an enrolled BYOD Mac, but the user can unenroll a personally owned device. Use compliance and Conditional Access policies when access must require continued enrollment.
Note
Do not use Discovered apps to verify configuration delivery. On a personally owned macOS device, Intune reports only apps that Intune manages. An independently installed Codex or Claude Desktop app might not appear. The Discovered apps report also normally refreshes every seven days from the device’s enrollment date. Use Device configuration, the effective managed preference, and agentgateway request logs to verify this workflow. For more information, see Intune Discovered Apps.
Choose a management method
The supported clients expose different configuration and enforcement mechanisms. This guide provides end-to-end application deployment, managed configuration, drift enforcement, compliance, and verification examples for Codex and Claude Desktop. The other clients receive configuration-specific guidance. Start with clients that provide native managed policy.
| Client | Configuration used by the agentgateway guide | Recommended Intune method | Enforcement level |
|---|---|---|---|
| Codex | model_provider and model_providers.agentgateway | Deploy Codex managed configuration. Use a macOS preference profile or a Windows remediation. | Strong managed startup configuration. |
| Claude Code | ANTHROPIC_BASE_URL | Deploy native Claude Code managed settings through a macOS preference profile, Windows registry policy, or managed-settings.json. | Strong native managed policy. |
| Claude Desktop | Gateway connection, a gateway-key or subscription credential helper, Entra sign-in, workspace restrictions, and managed MCP servers | Build and test the configuration in Claude Desktop, export the native .mobileconfig or ADMX policy, and deploy it with Intune. | Strong native managed policy. Managed settings override local configuration. |
| Cursor | Override OpenAI Base URL in Cursor settings | Seed and audit the user setting only after validating its on-disk schema for the deployed Cursor version. | Remediation-based. |
| Devin Desktop | http.proxy in the editor settings | Merge the setting into the user’s editor configuration and remediate only that key. | Remediation-based. |
| VS Code Continue | The model entry in ~/.continue/config.json | Deploy the configuration file or merge the agentgateway model entry with a user-context script. | Remediation-based. |
| GitHub Copilot | github.copilot.advanced.debug.overrideProxyUrl in VS Code settings | Merge the setting into VS Code user settings. Preserve unrelated settings when remediating the JSON file. | Remediation-based; requires Copilot Business or Enterprise. |
| OpenAI SDK | base_url or baseURL in application code | Deploy an organization-owned wrapper, environment file, or application configuration. | Not enforceable by managing the SDK package alone. |
| curl | Request URL | Deploy an organization-owned wrapper command for convenience. | Not an application-policy boundary. |
For clients with an ordinary user settings file, detect and update only the gateway-related keys. Replacing the entire file can delete a user’s unrelated editor, model, or accessibility settings.
Configure a gateway client key for the pilot
Use one revocable agentgateway client key for the Codex and Claude Desktop pilot examples in this guide. Protect the OpenAI and Anthropic routes with the same virtual key, and keep the provider credentials separate.
| Credential | Purpose | Send to managed clients? |
|---|---|---|
| Gateway client key | Authenticates Codex and Claude Desktop to agentgateway | Yes, for the pilot |
| OpenAI provider key | Authenticates agentgateway to OpenAI | No |
| Anthropic provider key | Authenticates agentgateway to Anthropic | No |
For the pilot, you do not need a different gateway client key or client-key store for each application. In Kubernetes, configure the API key policies on both client HTTPRoutes to use the same virtual-key source. Do not apply the policy to a shared Gateway listener if another route must accept a different credential.
For production, use separate gateway client keys for each application or security boundary. Separate keys provide per-client attribution and let you rotate, revoke, and apply policy to one client without affecting the others. Claude Desktop’s Entra ID mode does not use a gateway client key because agentgateway validates the signed-in user’s JWT instead.
Store the raw pilot key in a password manager while you build the client
policies. The examples refer to it as AGENTGATEWAY_API_KEY. Before a broad
production assignment, replace the shared static key with per-user,
per-device, or identity-based credentials so that you can revoke access and
attribute usage independently.
Manage Codex
Codex supports managed
configuration
in the Codex CLI, IDE extension, and Codex in the ChatGPT desktop app. Managed
configuration overrides the user’s config.toml and CLI --config values
when the client starts.
Choose a Codex authentication option
Choose one authentication method for the custom agentgateway provider.
| Method | When to use | Managed TOML |
|---|---|---|
| Gateway client key from an environment variable | Initial pilot and the complete example in this guide | Set env_key = "AGENTGATEWAY_API_KEY". Provision the variable with the pilot gateway client key. |
| Command-backed bearer token | Production extension point | Configure model_providers.agentgateway.auth to invoke an organization-owned credential helper that prints a short-lived or device-specific bearer token. |
| OpenAI authentication | Advanced, separately tested deployments | Set requires_openai_auth = true. Codex uses its ChatGPT or OpenAI API-key login with the proxy. Agentgateway must be configured and tested to accept that credential. |
| No client authentication | Only when another trusted access control protects agentgateway | Omit env_key, auth, and requires_openai_auth. Do not expose an unauthenticated route publicly. |
This guide uses the environment-variable method. The variable must be available to the process that launches Codex. Setting it only in an interactive shell does not make it available to a Codex desktop application launched from the macOS Finder or Windows Start menu. Use your organization’s secret delivery mechanism to provision the value in the intended user context. Do not place the raw value in the managed TOML.
The Codex verification and compliance scripts in this guide validate this complete environment-variable example. Adapt and test the scripts before you use them to enforce a different Codex authentication method.
For production, a command-backed authentication helper can retrieve a
short-lived or device-specific credential from Keychain, Credential Manager,
or an internal secret broker. Do not combine auth with env_key, experimental_bearer_token, or requires_openai_auth. For the supported
fields, see the Codex configuration
reference.
Note
Codex does not provide Claude Desktop’s native custom-provider fields for an
arbitrary OIDC issuer, client ID, or browser-versus-broker flow. A direct Entra
ID integration requires an organization-owned command-backed helper that
acquires and refreshes the Entra bearer token. Signing in to an Entra-backed
ChatGPT workspace with requires_openai_auth is OpenAI authentication through
the organization’s SSO; it is not a direct Entra-issued token that
agentgateway can validate with the Claude Desktop JWT policy.
For the distinction between these methods, see Codex custom-provider authentication.
Create the following approved configuration. Replace the example hostname with
the stable HTTPS address that exposes agentgateway. Keep the /v1 suffix
because Codex sends Responses API requests to /v1/responses.
model_provider = "agentgateway"
[model_providers.agentgateway]
name = "OpenAI via agentgateway"
base_url = "https://llm.example.com/v1"
wire_api = "responses"
env_key = "AGENTGATEWAY_API_KEY"Warning
Do not distribute a plain HTTP gateway URL. It sends prompts, responses, and credentials without transport encryption. Use a publicly trusted or organization-trusted certificate on the HTTPS listener before assigning the managed Codex configuration.
For more information about the client behavior, see Codex.
macOS
Codex reads managed preferences from the com.openai.codex domain. Deploy the
TOML as a base64-encoded config_toml_base64 value.
Save the approved configuration as
managed_config.toml.Encode the file without line wrapping.
base64 < managed_config.toml | tr -d '\n'Save the following Intune preference-file content as
codex-managed-preferences.xml. ReplaceBASE64_ENCODED_TOMLwith the output from the previous step.<key>config_toml_base64</key> <string>BASE64_ENCODED_TOML</string>Warning
The Intune Preference file template accepts a
.plistor.xmlfile, but the uploaded file must contain only the key-value pairs. Do not add an XML declaration,DOCTYPE,<plist>, or<dict>wrapper. Those elements cause Intune to reject or incorrectly process this preference-file payload.In the Intune admin center, go to Devices > Manage devices > Configuration > Create > New policy.
Select macOS and Templates > Preference file.
Use
com.openai.codexas the preference domain, uploadcodex-managed-preferences.xml, and assign the policy to your pilot device group.Restart Codex.
For more information about the Intune workflow, see Add preference file settings to macOS devices.
You can also deploy requirements_toml_base64 in the same preference domain
to enforce supported Codex security requirements. Provider and base URL fields
are managed defaults, not supported requirements.toml constraints.
Verify Codex on macOS
In the Intune admin center, open Devices > All devices, select the Mac, and open Device configuration. Confirm that the Codex preference policy reports Succeeded.
On the Mac, open Company Portal, select the device, and select Check status to request the latest assigned configuration.
Configure the macOS verification script with Codex enabled, and then follow Deploy the verification script on macOS. Confirm that Intune reports success for the installation, effective managed configuration, and network checks. The script reports only check results and does not return the decoded TOML.
From the intended user context, verify the gateway key independently. The environment variable must contain the gateway client key, not the OpenAI provider key.
curl --fail-with-body \ --header "Authorization: Bearer $AGENTGATEWAY_API_KEY" \ "https://llm.example.com/v1/models?client_version=intune-verification"Fully quit Codex. On macOS, use Command-Q instead of only closing the window. Reopen Codex so that it loads the managed defaults, and start a new local task. A cloud task does not run through the local managed provider.
Start the agentgateway log stream as described in Verify the deployment, and then send a harmless prompt from the new task.
Reply exactly: AGW-CODEX-VERIFY. Do not use tools.To test the Codex CLI on the same managed Mac, you can instead run the following command.
codex exec 'Reply exactly: AGW-CODEX-VERIFY. Do not use tools.'Correlate the request by its time. Codex might first send
GET /v1/models. The decisive entry is a successfulPOST /v1/responseswith the configured gateway hostname, the expected route, andhttp.status=200. The access log does not need to contain the prompt text.If no entry appears, check that the task is local, Codex was fully restarted, DNS resolves the managed hostname, the HTTPS listener serves a trusted certificate for that hostname, and the managed URL uses
https. If the authenticatedcurlrequest succeeds but Codex returns HTTP 401, confirm thatAGENTGATEWAY_API_KEYis available to the Codex process and restart the application. If both requests return HTTP 401, confirm that the supplied value matches the virtual key configured on the route.Add a conflicting provider or base URL to the user’s
config.toml, or start Codex with a conflicting--configvalue. Restart Codex and confirm that it starts with the managed agentgateway values.
Managed defaults apply when Codex starts. A user can change a supported setting
during a running session, but Codex reapplies the managed value at the next
launch. Use requirements.toml for supported security constraints and use
gateway or network policy when a control must not depend on a client restart.
Windows
Codex reads managed defaults from ~/.codex/managed_config.toml on Windows.
Use an Intune Remediation script package to detect and restore the file. Run
both scripts with the logged-on user’s credentials so that USERPROFILE
resolves to the intended Codex user.
Create the detection script.
$path = Join-Path $env:USERPROFILE ".codex\managed_config.toml"
$expected = @'
model_provider = "agentgateway"
[model_providers.agentgateway]
name = "OpenAI via agentgateway"
base_url = "https://llm.example.com/v1"
wire_api = "responses"
env_key = "AGENTGATEWAY_API_KEY"
'@
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
Write-Output "Codex managed configuration is missing."
exit 1
}
$actual = [IO.File]::ReadAllText($path).Replace("`r`n", "`n").TrimEnd()
if ($actual -ne $expected.Replace("`r`n", "`n").TrimEnd()) {
Write-Output "Codex managed configuration differs from policy."
exit 1
}
Write-Output "Codex managed configuration matches policy."
exit 0Create the remediation script with the same approved TOML.
$directory = Join-Path $env:USERPROFILE ".codex"
$path = Join-Path $directory "managed_config.toml"
$expected = @'
model_provider = "agentgateway"
[model_providers.agentgateway]
name = "OpenAI via agentgateway"
base_url = "https://llm.example.com/v1"
wire_api = "responses"
env_key = "AGENTGATEWAY_API_KEY"
'@
New-Item -ItemType Directory -Path $directory -Force | Out-Null
$encoding = New-Object Text.UTF8Encoding($false)
[IO.File]::WriteAllText($path, $expected.TrimEnd() + "`n", $encoding)
Write-Output "Restored the Codex managed configuration."In the Intune admin center, go to Devices > Manage devices > Scripts and remediations and create a script package with these settings.
- Upload the detection and remediation scripts.
- Set Run this script using the logged-on credentials to Yes.
- Set Run script in 64-bit PowerShell to Yes.
- Sign the scripts and enable signature enforcement if your organization has a code-signing process.
- Assign the package to a pilot group and select an hourly schedule.
Change managed_config.toml on a pilot device. At the next evaluation, the
detection script exits with code 1 and Intune runs the remediation script to
restore the approved content.
Note
Intune Remediations restore the file on their configured schedule. Codex reads managed defaults at startup, so restart the client after remediation when you validate a policy change.
Manage Claude Code
Claude Code provides native endpoint-managed
settings that users
and projects cannot normally override. Set ANTHROPIC_BASE_URL in the managed env object.
{
"env": {
"ANTHROPIC_BASE_URL": "https://llm.example.com"
}
}Deploy the JSON through one of these Intune-compatible policy locations.
- macOS managed preference domain:
com.anthropic.claudecode. - Windows machine policy: the
Settingsstring value underHKLM\SOFTWARE\Policies\ClaudeCode. - Managed file:
/Library/Application Support/ClaudeCode/managed-settings.jsonon macOS orC:\Program Files\ClaudeCode\managed-settings.jsonon Windows.
Use the machine policy or managed file instead of ~/.claude/settings.json.
The managed source has higher precedence and is designed for endpoint
management.
Manage Claude Desktop
Use Microsoft Intune to deploy a managed Claude Desktop configuration that routes inference through agentgateway. The workflow applies to agentgateway running in Kubernetes or standalone mode and supports three credential models: an agentgateway API key, Microsoft Entra ID, or an advanced per-user Claude subscription passthrough configuration.
Intune installs the application and enforces its endpoint configuration. The credential model determines whether agentgateway validates a gateway key or an Entra identity before adding a centrally managed Anthropic credential, or passes each user’s Claude subscription token upstream.
Prepare the rollout
- Complete the Claude Desktop guide for your agentgateway mode and chosen credential model.
- Expose agentgateway through a stable HTTPS hostname that the managed devices
can resolve. Claude Desktop rejects plain HTTP for non-loopback addresses
with
baseUrl: must use https (or http on loopback). - Enroll your Windows devices or macOS devices in Intune.
- Install a supported Claude Desktop release on an unmanaged administrator workstation so that you can build and test the configuration before export.
- Create an Intune pilot device group. For Entra mode, also create an Entra ID pilot user group. Do not begin with a tenant-wide assignment.
Warning
The gateway API key and Entra workflows use a centrally managed Anthropic provider credential. They do not establish per-user Anthropic subscription or seat attribution. Never put the Anthropic provider key or a subscription token in an Intune profile. A static agentgateway client key is acceptable for a limited pilot, but the exported policy contains that key. Do not reuse one static key across a production fleet.
Choose one authentication model
Choose exactly one of the following models before you build the managed profile. The credential settings are mutually exclusive.
| Authentication model | When to use | Upstream credential | Billing |
|---|---|---|---|
| Gateway API key | Static key for an initial pilot; credential helper for production | Centrally managed Anthropic API key | Anthropic API account |
| Claude subscription passthrough | Advanced option for preserving per-user seat usage | Per-user Claude subscription token | User’s Claude subscription |
| Microsoft Entra ID | Recommended enterprise identity and Conditional Access model | Centrally managed Anthropic API key | Anthropic API account |
Important
Complete only one authentication option. Do not combine the gateway-key, subscription-token, and Entra credential settings in the same Claude Desktop profile. After completing one option, continue with Build and test the managed configuration.
Important
The JSON blocks below are reference examples, not files to create or upload to
Intune. Enter the equivalent values in Developer > Configure Third-Party
Inference. Claude Desktop creates its local <id>.json file when you save
the configuration. Use Export to create the .mobileconfig or Windows
policy artifact that you deploy with Intune.
Replace https://claude.example.com with the stable HTTPS
hostname that exposes agentgateway. Use only the origin
when the route matches /. Include a path such as /claude only when the
route matches that prefix and rewrites it to /. Replace each example helper
path with the fixed absolute path where Intune deploys your helper executable.
Note
Find the locally saved configuration
macOS: In Finder, select Go > Go to Folder, enter
~/Library/Application Support/Claude-3p/configLibrary/, and open the applicable<id>.jsonfile.Windows: Press Windows+R, enter
%LOCALAPPDATA%\Claude-3p\configLibrary\, and open the applicable<id>.jsonfile.
_meta.json identifies the currently applied configuration. Use these files
for inspection only; they might contain static credentials. Use Claude
Desktop’s Export action to create the Intune deployment artifact. For
details, see the Claude Desktop configuration
reference.
Option 1: Use a gateway API key
Gateway API key mode is the recommended starting point. Claude Desktop sends a client key that agentgateway validates, and agentgateway replaces it with a separately managed Anthropic API key for the upstream request. Complete the Claude Desktop gateway API key setup for your agentgateway mode before you build the Intune profile.
For an initial pilot, select Static API key and use the revocable gateway
client key from Configure a gateway client key for the
pilot. This is the same client
key that the Codex example reads from AGENTGATEWAY_API_KEY; you do not need a
Claude-specific client-key store. Do not use the Anthropic provider key. A
static client key is stored in the local Claude Desktop configuration and in
the exported Intune policy, where device administrators can recover it. Limit
the assignment to the pilot group and rotate or revoke the key after testing.
Enter and test the following gateway API key settings in Claude Desktop.
{
"inferenceProvider": "gateway",
"inferenceGatewayBaseUrl": "https://claude.example.com",
"inferenceCredentialKind": "static",
"inferenceGatewayApiKey": "REPLACE_WITH_SHARED_PILOT_GATEWAY_KEY",
"inferenceGatewayAuthScheme": "bearer",
"modelDiscoveryEnabled": false,
"inferenceModels": [
{
"name": "claude-opus-5",
"anthropicFamilyTier": "opus"
}
]
}Before a broad production assignment, replace the static key with an organization-owned credential helper:
{
"inferenceCredentialKind": "helper-script",
"inferenceCredentialHelper": "/absolute/path/to/agentgateway-key-helper"
}A helper is an executable that Claude Desktop runs with no arguments. It retrieves the assigned key from Keychain, Credential Manager, or an internal secret broker and writes only the credential to standard output. For the output, error, caching, and refresh contract, see Write a credential helper.
From Claude Desktop, confirm that Test connection succeeds, normal
inference returns HTTP 200 in the agentgateway request log, and a request
without the gateway key returns HTTP 401. When testing a helper, also run it as
the intended user with CLAUDE_HELPER_CONTEXT=setup-test. Then continue with Build and test the
managed configuration.
Option 2: Use Claude subscription passthrough
Claude subscription passthrough is an advanced option that preserves each
user’s Claude seat and usage attribution. The user authenticates to Anthropic
with a bearer token from claude setup-token; agentgateway passes that token upstream instead of
injecting a centrally managed Anthropic API key. Complete the Claude
subscription setup
for your agentgateway mode before you build the Intune profile.
Intune can enforce the gateway address, Bearer auth scheme, model list, and model-discovery setting, but do not put the user’s token in the profile. A managed profile is readable by device administrators and cannot safely hold a per-user subscription credential. Instead, deploy an organization-owned credential helper that retrieves the token from per-user secure storage such as Keychain or Credential Manager. Each user obtains and stores their own token. The helper follows the same credential-helper contract and returns that user’s token instead of a gateway key.
Enter and test the following subscription-passthrough settings in Claude Desktop. Add at least one full model ID under Models and turn off model discovery.
{
"inferenceProvider": "gateway",
"inferenceGatewayBaseUrl": "https://claude.example.com",
"inferenceCredentialKind": "helper-script",
"inferenceCredentialHelper": "/absolute/path/to/claude-subscription-helper",
"inferenceGatewayAuthScheme": "bearer",
"modelDiscoveryEnabled": false,
"inferenceModels": [
{
"name": "claude-opus-5",
"anthropicFamilyTier": "opus"
}
]
}Claude Desktop appends /v1/models and /v1/messages to the configured base
URL.
Test the helper under the intended user account and for noninteractive helper
contexts before deployment. In particular, the connection test invokes the
helper with CLAUDE_HELPER_CONTEXT=setup-test, and background refreshes must
not stop for an interactive prompt. Then continue with Build and test the
managed configuration.
Note
With subscription passthrough, Test connection might return HTTP 429 with rate_limit_error even when normal Cowork inference works. Apply the
configuration, send a harmless prompt, and inspect the agentgateway request
log. If the real /v1/messages request returns HTTP 200, treat the connection
test as a false negative and use actual inference as the final validation.
Option 3: Use Microsoft Entra ID
Complete the Claude Desktop Entra setup for your agentgateway mode before you build the Intune profile.
Replace any strict gateway API key policy on the Claude Desktop route with the JWT policy. Do not require both authentication methods on the route. Leave the Anthropic provider credential on the backend, and leave authentication policies for other clients attached to their own routes.
Choose the Entra sign-in flow
Claude Desktop supports two Entra sign-in flows for a Gateway connection.
| Flow | User experience | When to use |
|---|---|---|
| Browser | Claude Desktop opens the system browser and receives the result on a loopback callback. | Initial testing or environments that do not require a device claim during sign-in. |
| Broker | Claude Desktop uses Web Account Manager on Windows or Company Portal and the Microsoft Enterprise SSO plug-in on macOS. | Production deployments that use Conditional Access to require a managed or compliant device. |
The broker is the recommended production choice for Intune-managed devices. A browser presents device identity only when the browser and operating system are configured to provide it. The broker provides the device identity directly and does not require a loopback callback.
Register Claude Desktop in Entra ID
In the Microsoft Entra admin center, go to Entra ID > App registrations > New registration.
Create a single-tenant registration, such as
Claude Desktop gateway.On the application Overview page, record the Application (client) ID and Directory (tenant) ID. The client ID configures Claude Desktop and becomes the expected token audience on agentgateway. The tenant ID forms the Entra issuer and JWKS URLs.
Go to Authentication, add the Mobile and desktop applications platform, and configure the redirect URIs for your sign-in flow.
Flow and platform Redirect URI Browser on Windows or macOS http://127.0.0.1/callbackBroker on Windows ms-appx-web://Microsoft.AAD.BrokerPlugin/CLIENT_IDBroker on macOS msauth.com.anthropic.claudefordesktop://authReplace
CLIENT_IDin the Windows broker URI with the Application (client) ID. When you support both flows during a pilot, register all applicable redirect URIs. These are Claude Desktop callback URIs. Do not substitute the HTTPS agentgateway hostname, which is configured separately as the Gateway base URL.Leave Allow public client flows disabled. Claude Desktop’s browser and broker authorization-code flows do not require this legacy toggle.
In Enterprise applications, open the service principal that corresponds to the registration. Set Assignment required? to Yes, and assign the Entra pilot user group. This prevents unassigned tenant users from signing in to the client registration.
The client is public and must not have a client secret. For more information, see Register an application in Microsoft Entra ID.
Prepare managed devices for broker sign-in
On Windows, Web Account Manager is part of the operating system. The device must be registered, joined, or hybrid joined to Entra ID. It must also report the required compliance state to Intune before a compliant-device Conditional Access policy can grant access.
On macOS, deploy the current Intune Company Portal application and configure the Microsoft Enterprise SSO plug-in. Microsoft recommends Platform SSO for strong device registration. For the prerequisites and Intune settings, see Configure Platform SSO for macOS devices. Use one SSO policy on each device. When you deploy Platform SSO, do not also assign a separate Enterprise SSO plug-in policy to that device.
Do not enable a Conditional Access requirement until broker sign-in succeeds on both pilot platforms.
Transition a browser pilot to broker sign-in
- Confirm that browser sign-in, a full Claude Desktop restart, and a real prompt work through agentgateway.
- Add the broker redirect URI for each pilot platform to the existing Entra
app registration. Keep
http://127.0.0.1/callbackduring the pilot so that you can roll back. - Install and sign in to Company Portal on macOS, or confirm that the Windows device is registered with Entra ID. Assign the SSO and device compliance policies to the pilot group and sync the device.
- On an administrator workstation without an assigned Claude Desktop managed profile, change only the sign-in flow from Browser to Broker. Keep Interactive sign-in, issuer, client ID, scopes, and ID-token selection unchanged. Test the connection and export the updated artifact.
- Update the existing Claude Desktop Intune profile. Do not assign separate browser and broker profiles to the same user or device.
- Sync the pilot device, verify the effective managed settings, fully quit and
reopen Claude Desktop, and complete broker sign-in. Send a real prompt and
confirm an HTTP 200
POST /v1/messagesentry withjwt.subin the agentgateway log.
The agentgateway JWT policy does not change when the client moves from browser to broker. After the broker pilot is stable, remove the browser redirect URI if your organization no longer needs it for rollback.
Build and test the managed configuration
After you complete exactly one authentication option, build a profile that contains only that option’s credential settings plus the common settings in this section.
Use an administrator workstation that does not already have a Claude Desktop managed profile.
Warning
Managed settings take precedence over the values entered in Claude Desktop. A local connection test can succeed, but an older Intune profile can restore static API key settings after restart. Temporarily exclude the administrator workstation from the old profile or use an unmanaged workstation for authoring. Update the existing profile rather than assigning both versions.
In Claude Desktop, enable developer mode from Help > Troubleshooting > Enable Developer Mode.
Go to Developer > Configure Third-Party Inference > Connection.
Configure the values shared by all three authentication models.
Setting Value Inference provider Gateway Gateway base URL The HTTPS agentgateway URL. Include /claudeonly when the route matches and rewrites that prefix.Model discovery Off when you deploy a fixed model list Models One or more full model IDs, such as claude-opus-5; the first entry is the defaultConfigure credentials for only the authentication model that you selected.
Authentication model Credential kind Required settings Gateway API key Static API key for a pilot; Helper script for production For a pilot, enter the shared gateway client key and select Bearer. For production, set the absolute credential-helper path instead. Claude subscription passthrough Helper script Set the absolute credential-helper path and Bearer auth scheme. The helper returns the current user’s Claude subscription token. Microsoft Entra ID Interactive sign-in Set the issuer to https://login.microsoftonline.com/TENANT_ID/v2.0, the Entra Application (client) ID, ID token, scopesopenid profile email offline_access, and Broker or Browser sign-in flow.For Entra ID, agentgateway must validate the token signature, exact issuer, and application audience. Keep the issuer and client ID in the managed profile aligned with the issuer and audience configured on agentgateway. Use the issuer base URL, not the OpenID discovery-document URL that ends in
/.well-known/openid-configuration.Review the remaining Configure Third-Party Inference settings and apply them according to your organization’s requirements. These optional settings are not required to route inference through agentgateway. See the Claude Desktop configuration reference and MDM deployment guide for additional details.
Ensure that managed devices can reach the agentgateway hostname. If users must not access LLM providers directly, enforce that requirement with separate network controls. A Claude Desktop or Intune configuration cannot prevent another application from bypassing agentgateway.
Apply the configuration locally and test model selection and inference. If you configured managed MCP servers, test them separately. If you intentionally use discovery instead of a fixed list, also test
GET /v1/models.Verify the result for the selected model. In all modes, confirm that the agentgateway log records the real
/v1/messagesrequest with HTTP 200 and does not expose credentials.- For a gateway API key, also confirm that a request without the key returns HTTP 401.
- For subscription passthrough, use a real prompt as the final validation if Test connection returns the documented false-negative HTTP 429.
- For Entra ID, confirm that the log records the authenticated identity and that an invalid issuer, audience, expired token, or missing token is rejected.
Export the configuration
After every connection and policy test succeeds, use Export in Claude Desktop.
Warning
When Static API key is selected, the exported macOS profile or Windows policy contains the agentgateway client key. Assign it only to the pilot group. Before production rollout, switch to Helper script so that the managed policy contains a helper path instead of the credential.
- Export
.mobileconfigfor macOS. The profile contains the complete managed configuration in thecom.anthropic.claudefordesktoppreference domain. - Export the ADMX package for Windows. The package supplies the schema that
Intune uses to create a policy; enter the validated values in the Intune
profile. Export
.regas a reference when you need to compare the resulting registry values.
Prefer the application-generated artifacts over hand-written profiles. Nested objects such as the OIDC and MCP settings are encoded as JSON strings in macOS preferences and Windows registry policy. A native property-list dictionary, registry subkey, or incorrectly escaped string does not apply.
For all supported settings and their precedence, see Claude Desktop managed configuration and Deploy with MDM.
Deploy the configuration on macOS
- In the Intune admin center, go to Devices > Manage devices > Configuration > Create > New policy.
- Select macOS and Templates > Custom.
- Upload the exported
.mobileconfigfile. - Assign the profile to the pilot group and monitor its deployment status.
- Fully quit and reopen Claude Desktop. The application reads managed configuration at launch.
For more information, see Add custom settings to Apple devices in Microsoft Intune.
Deploy the configuration on Windows
- Extract the exported ADMX package.
- In the Intune admin center, go to Devices > Manage devices >
Configuration > Import ADMX and import the ADMX and
en-USADML files. - Create a Windows 10 and later > Templates > Imported Administrative templates profile.
- Enter the complete validated Claude Desktop configuration and assign it to the pilot group.
- Confirm that the policy writes string values directly under
HKLM\SOFTWARE\Policies\Claude. Do not split the configuration acrossHKLMandHKCU, and do not put values in registry subkeys. - Fully quit and reopen Claude Desktop.
Machine policy is recommended. When any supported machine-policy value is present, Claude Desktop ignores the entire user-policy hive. For more information about importing the templates, see Import custom ADMX and ADML administrative templates into Microsoft Intune.
If imported ADMX templates do not meet your deployment requirements, use an organization-owned Intune PowerShell script to write the exported values to the machine-policy key. Never include a provider credential in the script.
Optional: Add Conditional Access for Entra ID
Complete this section only when you selected Microsoft Entra ID. After broker sign-in works on the pilot devices, create a Conditional Access policy that targets the Claude Desktop Entra enterprise application and pilot users.
- Start the policy in Report-only mode.
- Require multifactor authentication as appropriate for your organization.
- Require the device to be marked compliant.
- Exclude emergency access accounts.
- Review the Entra sign-in logs for the expected user, application, device, and grant-control results.
- Enable the policy for the pilot group before expanding the assignment.
Avoid targeting all users and all resources while developing the policy. A misconfigured compliant-device requirement can also block the administrators who need to repair it. For deployment guidance, see Device compliance policies in Microsoft Intune.
Verify Claude Desktop enforcement
Test the following cases on Windows and macOS before expanding the rollout.
If Intune deploys Claude Desktop, confirm its installation under Managed apps or the app installation report. An independently installed copy on a personally owned Mac does not need to appear under Discovered apps.
In the Intune admin center, open the device’s Device configuration page and confirm that the Claude Desktop profile reports Succeeded. On macOS, use Company Portal Check status to request the latest configuration.
Deploy the platform-appropriate script from Automate verification with Intune with Claude Desktop enabled. Configure its expected credential kind and, for Entra ID, its expected flow, issuer, and client ID. Confirm that Intune reports success for the installation, effective managed gateway URL, authentication settings, and network checks. The script does not return credentials, managed preference contents, or registry contents. It does not verify the model list; confirm the managed model settings in the read-only Claude Desktop configuration window.
On macOS, inspect only the non-secret authentication fields in the effective per-user profile. Replace
USERNAMEwith the signed-in user’s short name.CLAUDE_PLIST="/Library/Managed Preferences/USERNAME/com.anthropic.claudefordesktop.plist" plutil -extract inferenceCredentialKind raw "$CLAUDE_PLIST" plutil -extract inferenceGatewayOidcAuthFlow raw "$CLAUDE_PLIST" plutil -extract inferenceGatewayOidc raw "$CLAUDE_PLIST" if plutil -extract inferenceGatewayApiKey raw "$CLAUDE_PLIST" >/dev/null 2>&1; then echo "Unexpected static gateway credential" else echo "Static gateway credential is absent" fiFor an Entra broker profile, expect
interactive,broker, the approved issuer and client ID, and noinferenceGatewayApiKeyvalue. Do not print an API key while troubleshooting.Fully quit and reopen Claude Desktop instead of only closing its window. On macOS, use Command-Q. Open the third-party inference configuration and confirm that it is marked as organization-managed, read-only, and points to agentgateway.
Start the agentgateway log stream as described in Verify the deployment. Authenticate with the authentication model that you selected, start a new third-party inference conversation, and send a harmless prompt.
Reply exactly: AGW-CLAUDE-VERIFY. Do not use tools.Then test model discovery and each managed MCP server.
Correlate the inference request by its time. Confirm a successful
POST /v1/messagesentry with the expected managed hostname, route, upstream provider, andhttp.status=200. For Entra ID, also confirm the authenticated identity. The access log does not need to contain the prompt text and must not contain the client or upstream credential. If no entry appears, check the full restart, managed HTTPS URL, DNS, and network path.Test the negative case for the selected model.
- For a gateway API key, confirm that a missing or invalid key receives an unauthorized response from agentgateway.
- For Entra ID, confirm that an invalid issuer, audience, expired token, and missing token each receive an unauthorized response from agentgateway.
- For subscription passthrough, confirm that an invalid subscription token is rejected by Anthropic. Agentgateway does not independently authenticate the caller in this mode.
Try to save a local gateway URL or local third-party configuration. Fully restart Claude Desktop and confirm that the managed configuration remains effective.
Confirm that only approved MCP servers are available and that each tool uses the configured approval policy.
If you selected Entra broker mode, mark a pilot device noncompliant and confirm that Conditional Access blocks a new sign-in.
If you selected Entra ID, remove a pilot user from the assigned group and revoke the user’s sessions. Confirm that a new sign-in is blocked. A JWT that agentgateway already accepted remains valid until its expiration unless you add a separate token-revocation mechanism, so choose an appropriate token and session lifetime.
Confirm that endpoint network controls block direct inference traffic to unapproved providers.
Update or remove the Claude Desktop policy
Use a new pilot assignment for every client or configuration update. Claude Desktop reads managed settings once at launch, so users must fully quit and reopen it after a profile change.
To return a device to local configuration, remove the managed Intune profile and restart Claude Desktop. Do not leave a partial machine policy on Windows: any recognized value in the machine-policy hive causes Claude Desktop to ignore user policy.
Manage other clients
The Codex and Claude Desktop sections provide complete rollout examples. The Claude Code section provides native managed-settings guidance, and the remaining clients below provide configuration-specific guidance. Pin and test a client version before you depend on its settings-file format, and update only the keys that route traffic through agentgateway.
Cursor
Follow the Cursor guide to enable Override OpenAI Base URL. Seed and audit that setting only after you confirm its on-disk schema for the Cursor version that Intune deploys. Preserve all unrelated user settings when a remediation changes the value.
Devin Desktop
Follow the Devin Desktop guide and manage the http.proxy
value in the editor settings. Use a user-context script that merges only this
key, because replacing the file can remove unrelated editor settings.
VS Code Continue
Follow the VS Code Continue guide and deploy or merge the
agentgateway model entry in ~/.continue/config.json. If users can define
other models, identify the managed entry by a stable name and leave the other
array entries unchanged.
GitHub Copilot
Follow the GitHub Copilot guide and manage github.copilot.advanced.debug.overrideProxyUrl in the VS Code user settings.
This workflow requires Copilot Business or Enterprise. Merge the property into
the JSON file instead of replacing the user’s complete VS Code configuration.
OpenAI SDK
Follow the OpenAI SDK guide and set base_url for
Python or baseURL for JavaScript in organization-owned application
configuration. Intune can deploy a wrapper, environment file, or managed
application, but managing the SDK package alone cannot force application code
to use agentgateway.
curl
Follow the curl guide and deploy an organization-owned wrapper command when users need a convenient request template. The curl executable accepts any URL, so this is not an enforcement boundary. Use gateway authentication and endpoint network controls when direct provider access must be blocked.
Manage MCP server policy
You can use the same endpoint-management channels to control Model Context Protocol (MCP) servers in supported clients.
- For Codex, deploy
requirements.tomlwith anmcp_serversallowlist. On macOS, encode it in therequirements_toml_base64managed preference. - For Claude Code, deploy
allowedMcpServers,deniedMcpServers, andallowManagedMcpServersOnlythrough the native managed settings. Deploy amanaged-mcp.jsonfile when you also need to define the approved servers. - For Claude Desktop, deploy
managedMcpServersand set per-tooltoolPolicyvalues. SetisLocalDevMcpEnabledtofalsewhen users must not add local MCP servers, and setmcpPersistentAlwaysAllowEnabledtofalsewhen tool approvals must not persist across sessions.
MCP policy controls which tool servers the client can load. It is separate from the model-provider configuration that routes LLM requests through agentgateway.
Automate verification with Intune
The complete Codex and Claude Desktop workflows use the example verification scripts in the agentgateway repository so administrators can check both clients without asking users to run local commands.
Before you upload a script, edit its configuration block. Set the approved
Codex URL including /v1, and set the approved Claude Desktop URL to match its
route layout. Include a prefix such as /claude only when the route matches
and rewrites it. Enable only the clients required for the target group. The
optional installation check recognizes the common paths listed in the script.
Add your organization’s package path or disable that check and use the Intune
managed-app report when the approved package uses a different path. Never add
a gateway client key, provider key, bearer token, or another secret.
For Claude Desktop, also set the expected credential kind. The examples
default to static. For Entra ID, set it to interactive and populate the
expected OIDC flow (browser or broker), issuer, and client ID. The scripts
then reject a leftover static key without returning its value.
The scripts perform these checks for every enabled client.
- Confirm that the application is installed in a recognized location when the installation check is enabled.
- Read the effective managed preference, file, or registry policy and confirm the approved agentgateway URL. For Codex, also confirm that the TOML names the approved credential environment variable. For Claude Desktop, confirm the expected credential kind and, in Entra mode, the OIDC flow, issuer, client ID, ID-token setting, and absence of a static key. The scripts do not inspect secret values or print the configuration.
- Connect to the approved URL and confirm that it returns an HTTP response. A
401or403response passes this connectivity check because it proves that DNS, transport, and the protected Gateway listener are reachable.
Deploy the verification script on macOS
Download
verify-agentgateway-clients-macos.sh.Edit the configuration block at the beginning of the script. For a Codex-only assignment, set the approved URL and credential-variable name, enable Codex, and disable Claude Desktop.
EXPECTED_CODEX_BASE_URL="https://llm.example.com/v1" EXPECTED_CODEX_ENV_KEY="AGENTGATEWAY_API_KEY" VERIFY_CODEX=true VERIFY_CLAUDE_DESKTOP=false VERIFY_INSTALLATION=true VERIFY_NETWORK=trueReplace
https://llm.example.com/v1with the managed Codexbase_url. Do not add the gateway key or another secret to the script. To verify both clients in one assignment, leave both client flags enabled and configure the expected Claude Desktop values too.Test the edited script locally from the intended user context. Resolve any failed check before uploading it.
In the Intune admin center, go to Devices > By platform > macOS > Manage devices > Scripts > Add, provide a name, and upload the edited script.
Set Run script as signed-in user to Yes. The effective Codex and Claude Desktop settings are user-scoped. Enable signature enforcement only when your organization signs the uploaded script.
Select an execution frequency and retry behavior appropriate for the pilot.
Assign the script to the same pilot group as the client configuration, and create it.
On the Mac, open Company Portal, select the device, and select Check status. Script retrieval depends on the Intune management agent check-in, which is separate from the normal MDM configuration sync.
In Intune, reopen the script and review Device status or User status. Exit code
0reports success; a nonzero exit code reports one or more failed checks. Use Verify delivery and execution to interpret pending or failed results and collect the sanitized log.
The Mac must have the Microsoft Intune management agent. For prerequisites, scheduling, and reporting behavior, see Use shell scripts on macOS devices in Intune.
Deploy the verification script on Windows
- In the Intune admin center, go to Devices > Manage devices > Scripts and remediations and create a script package.
- Upload the PowerShell script as the detection script. A remediation script is optional when the managed client policy already restores configuration.
- Set Run this script using the logged-on credentials and Run script in 64-bit PowerShell to Yes.
- Assign a schedule and the pilot group, and then monitor Device status.
You can instead upload the PowerShell file as a Windows platform script for a one-time check. For recurring checks, review the enrollment, Windows edition, and licensing requirements for Intune Remediations.
Note
These operational scripts are not custom compliance discovery scripts. Custom compliance requires platform-specific discovery output and a matching JSON rule definition. Use the dedicated artifacts described in Add compliance reporting.
The network check does not send an LLM prompt and cannot prove that an interactive client request used agentgateway. After the script passes, complete the interactive test in Verify the deployment and correlate the request with the agentgateway access log.
Add compliance reporting
Use custom compliance when access decisions must include the state of a client configuration. Custom compliance supports enrolled and managed macOS devices, including a BYOD Mac enrolled through Company Portal. It does not cover an unenrolled or MAM-only device. On macOS, a Bash discovery script can report a client-specific Boolean after checking the effective file or managed preference.
The agentgateway examples include independently assignable compliance artifacts for Codex and Claude Desktop.
| Client | macOS discovery | Windows discovery | Rule JSON | Reported setting |
|---|---|---|---|---|
| Codex | Bash script | PowerShell script | Rules | CodexGatewayConfigured |
| Claude Desktop | Bash script | PowerShell script | Rules | ClaudeDesktopGatewayConfigured |
These scripts apply the same managed-configuration intent as the operational
verifiers but implement the custom-compliance contract. They return only the
discovered state and never return configuration contents, tokens, prompts, or
credentials. A missing or mismatched configuration is a valid discovered false value and uses exit code 0. A nonzero exit code is reserved for a
script execution error.
The discovery scripts do not test Gateway reachability. A temporary Gateway or network outage must not make every managed device noncompliant or unexpectedly affect Conditional Access.
Before uploading a script, replace its example URL with the approved address.
Include /v1 for Codex and keep EXPECTED_CODEX_ENV_KEY aligned with the
managed TOML. For Claude Desktop, include a route prefix such as /claude only
when the HTTPRoute matches and rewrites it; use only the origin for a
dedicated hostname that matches /. Keep the expected values aligned with the
corresponding managed configuration policy. For Entra ID, set the expected
Claude credential kind to interactive and populate the expected OIDC flow,
issuer, and client ID.
Use separate compliance policies and assignments for the two clients. This prevents a device that requires only one client from being marked noncompliant because the other client is not configured.
Add client compliance on macOS
- Download the macOS discovery script and rule JSON for the required client.
- In the Intune admin center, go to Endpoint security > Device compliance > Scripts > Add > macOS and upload the script.
- The script resolves the signed-in console user and reads both per-user and machine managed preferences, so it supports either the default system context or logged-in-user context. If Intune displays an execution-context setting, either context is supported. Enable signature enforcement when your organization signs scripts.
- Create a macOS compliance policy, add Custom Compliance, select the discovery script, and upload the custom-compliance rule JSON.
- Assign the policy to the same pilot group as the client application and managed preference policies.
Each macOS discovery script returns one JSON object on a single line. For example:
{"CodexGatewayConfigured":true}{"ClaudeDesktopGatewayConfigured":true}The setting name is case-sensitive and must match the corresponding SettingName in the rule JSON. The value is a JSON Boolean, not a quoted
string. Each script returns exit code 0 for either discovered value. A
nonzero exit code is reserved for a script execution error.
Add client compliance on Windows
- Download the Windows discovery script and rule JSON for the required client.
- In the Intune admin center, go to Endpoint security > Device compliance > Scripts > Add > Windows and upload the script.
- Set Run this script using the logged on credentials and Run script in 64-bit PowerShell Host to Yes. Enable signature enforcement when your organization signs scripts.
- Create a Windows compliance policy, add Custom Compliance, select the discovery script, and upload the custom-compliance rule JSON.
- Assign the policy to the same pilot group as the client application and managed configuration policies.
Each Windows discovery script returns one compressed JSON object. For example:
{"CodexGatewayConfigured":true}{"ClaudeDesktopGatewayConfigured":true}Use a grace period during the pilot so that application installation and first policy evaluation can complete. If access to agentgateway uses an Entra enterprise application, optionally use the resulting device compliance state in a Conditional Access policy after the pilot reports the expected results.
Compliance reporting does not repair configuration. Keep the native managed policy, recurring macOS shell script, or Windows remediation assigned when you add compliance reporting. A corrected custom setting can take up to eight hours to appear compliant. On macOS, a user can open Company Portal, select the device, and select Check Status to request an evaluation.
Verify the deployment
Test each policy on a pilot device before broad assignment. The automated script verifies the local prerequisites and network path; retain this final interactive test to prove that the client actually sends inference traffic through agentgateway.
If Intune deploys the client, confirm its installation under Managed apps or the app installation report. On a personally owned device, do not expect an independently installed application under Discovered apps.
Start the client and send a request.
Check that the request appears in the agentgateway proxy logs.
Review the terminal output from the
agentgatewayprocess or the logs from the service that runs agentgateway. Confirm that the request uses the expected listener, route, and model.Start the log stream before sending the client request so that unrelated traffic is easier to distinguish. Correlate the request by time; access logs do not need to include prompt text. Confirm the managed hostname, expected route and API path, upstream provider, and a successful status. No matching entry indicates a client, DNS, listener, or network problem. An unauthorized response indicates an authentication problem.
For a client managed by a recurring macOS shell script or Windows remediation, change the gateway setting, wait for the next script run, and confirm that Intune restores the approved value.
For a client with native managed policy, test a user-level setting and any supported command-line override. Restart the client and confirm that the managed value remains effective.
Review the applicable Intune device configuration, managed app, macOS shell script, or Windows remediation status for failures.
Limitations
- Intune manages enrolled endpoints. It does not manage cloud-hosted agents, continuous integration runners, or unmanaged personal devices.
- A recurring macOS shell-script or Windows remediation interval creates a window in which an ordinary user setting can differ from policy.
- Custom compliance is periodic reporting, not continuous enforcement. A corrected setting can take up to eight hours to appear compliant.
- A personally owned Mac must remain enrolled and managed for its custom compliance policy to run. A user who unenrolls the Mac removes this Intune control.
- Local administrators can subvert many endpoint controls. Use agentgateway authentication and authorization, and consider network controls that block direct access to LLM providers.
- Client configuration formats and supported enterprise settings can change. Pin and test an approved client version before updating the Intune package.
Next steps
Review the client guides that underpin the two complete Intune examples, then apply the Gateway security controls appropriate for your deployment.