Claude clients

Connect Claude Code and Claude Desktop.

DFENS speaks Anthropic's wire format on /v1/messages (see API integration for the base curl/SDK example). Claude Code and Claude Desktop are both Anthropic clients built on top of that same API, and each has its own way of pointing at a custom endpoint. This page covers both.

Claude Code

Claude Code reads the same ANTHROPIC_BASE_URL environment variable the SDKs do. Set it, plus your DFENS auth header if your deployment requires one, before launching:

env
# DFENS Cloud — swap for your self-hosted URL if that's your path
export ANTHROPIC_BASE_URL=https://api.dfens.ai
export ANTHROPIC_API_KEY=sk-ant-...
# DFENS Cloud, or self-hosted with client authentication on:
export ANTHROPIC_CUSTOM_HEADERS="X-AI-Firewall-Key: $DFENS_API_KEY"

Every call Claude Code makes is then inspected the same way as a raw API request — same rules, same audit log, same block behaviour.

Claude Desktop in 3P mode

Claude Desktop can be configured into third-party (3P) mode to use a gateway service — see Anthropic's LLM gateway docs for the full mechanism. It's the same app from claude.com/download, not a separate build; the configuration can reach a device three ways: entered by hand on one machine, an MDM profile pushed to a fleet, or a bootstrap server devices call at sign-in. All three set the same keys.

Not a narrow toggle

Switching a device into 3P mode changes the whole app to its third-party experience, centered on Cowork — not just the inference backend. Confirm that's what you want before rolling it out to a fleet.

Try it on one machine

  1. Install the standard app from claude.com/download. Don't sign in.
  2. Help → Troubleshooting → Enable Developer Mode.
  3. Developer → Configure Third-Party Inference…, set Inference provider to Gateway.
  4. Enter the values below, then Apply locally — the app relaunches and the sign-in screen now offers to start in 3P mode with what you entered.
KeyValue
inferenceProvidergateway
inferenceGatewayBaseUrlhttps://api.dfens.ai
inferenceGatewayAuthSchemex-api-key
inferenceModelsfull model IDs, e.g. claude-opus-5

inferenceModels has to be set explicitly with full IDs — DFENS doesn't implement GET /v1/models, so the model picker's auto-discovery has nothing to query. Fleet rollout uses the same keys, delivered via an MDM profile (exported from this same window) or a bootstrap server instead of typed in by hand.

The credential helper

inferenceGatewayApiKey covers one credential — fine for self-hosted DFENS with client authentication off, the default: set it to your Anthropic key and stop there. DFENS Cloud, and self-hosted with client authentication on, both need a second header (X-AI-Firewall-Key) on every request, and that can't go through inferenceCustomHeaders — Anthropic's own configuration reference rules it out explicitly: that field is plain, distributed configuration, and does not accept credentials. The second header has to come from a credential helper instead.

credential-helper.sh
#!/usr/bin/env bash
# stdout only — no banners, no logging. Exit 0.
TOKEN=$(security find-generic-password -s anthropic-api -w)
FWKEY=$(security find-generic-password -s dfens-api -w)
printf '{"token":"%s","headers":{"X-AI-Firewall-Key":"%s"}}' "$TOKEN" "$FWKEY"

Set inferenceCredentialKind to helper-script and inferenceCredentialHelper to this script's absolute path. Its token field is sent as x-api-key, per the auth scheme above; its headers field is merged in on top of any static custom headers — that's where X-AI-Firewall-Key rides.

Next: API integration for the request/response schemas and block behaviour that apply to every request, Claude client or otherwise.