> For the complete documentation index, see [llms.txt](https://docs.revenium.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revenium.io/track-and-control-costs/analyze-ai-tooling-spend/setup-claude-code.md).

# Setup Claude Code

Claude Code supports centrally-managed configuration through the Claude admin console. An administrator defines the settings once; Anthropic delivers them to every authenticated user on next startup. No per-developer install is required.

This is different for individual developer onboarding and does not cover historical backfill - please refer to [this document](/track-and-control-costs/analyze-ai-tooling-spend.md#setup-paths-enterprise-vs-per-user) for details on how to do that or go direct to <https://github.com/revenium/revenium-cli-node>

**Requirements:**

* Claude for Teams or Claude for Enterprise plan
* Claude Code version that supports managed settings
* Administrator role of **Primary Owner** or **Owner** in the Claude admin console
* Direct connection to `api.anthropic.com` to receive server-managed settings — configuration delivery only; telemetry does not transit Anthropic
* Direct connection to `api.revenium.ai` on port 443 from each developer machine for telemetry egress

{% hint style="info" %}
**Claude Code evolves quickly.** Anthropic updates environment variables, managed-settings fields, and admin console paths frequently. If something does not match what you see in the Claude admin console, cross-reference Anthropic's Claude Code monitoring and server-managed settings docs. The Revenium-specific values below, including the endpoint URL, API key header, and resource attributes, are the values to keep consistent.
{% endhint %}

#### Network Path: Configuration Delivery vs. Telemetry Egress

Configuration delivery and telemetry egress are two independent network paths. Telemetry does **not** transit Anthropic.

```
Configuration delivery (inbound)          Telemetry egress (outbound)

 Claude admin console (Anthropic)          Claude Code process
   |  server-managed settings                |  OTLP / HTTP-JSON, ~5s batches
   |  delivered at sign-in                   |
   v                                         v
 Developer machine ----------------------> api.revenium.ai:443
   ^                                       (direct TLS connection)
   |  ...or MDM / OS policy / settings file
   |  (never contacts Anthropic)
```

* **Configuration delivery** — how the `env` block below reaches the machine. With server-managed settings, Anthropic's servers deliver it at sign-in, which is why `api.anthropic.com` appears in the requirements above. With MDM, OS policy, or a managed settings file, Anthropic is not involved at all.
* **Telemetry egress** — Claude Code embeds the OpenTelemetry SDK and is itself the OTLP exporter. It opens a direct TLS connection from the developer's machine to the host in `OTEL_EXPORTER_OTLP_ENDPOINT` and POSTs batches to `/v1/logs`. Anthropic does not receive, proxy, buffer, or store this telemetry.

Practical consequences:

* **Firewall and proxy rules must name `api.revenium.ai` explicitly.** An allowlist entry for `api.anthropic.com` does not cover telemetry egress; they are separate destinations.
* **If the Revenium endpoint is unreachable, export fails locally.** Claude Code continues to work normally, and nothing is queued at Anthropic for later delivery, so telemetry for that period is not recoverable.
* **Prompt and response content is redacted by default.** The configuration below sends session, identity, model, token, and cost metadata; message bodies are exported as `<REDACTED>` unless an administrator explicitly opts in using Anthropic's content-logging variables.

**Steps:**

1. Sign in to [Claude.ai](https://claude.ai) as Primary Owner or Owner.
2. Navigate to the Managed settings screen. Depending on plan and admin console version, this appears under **Admin Settings → Claude Code → Managed settings** or **Organization settings → Claude Code → Managed settings**.
3. Paste the following JSON, substituting your Revenium metering key.

Use a Revenium metering key (`rev_mk_*`) for Claude Code OTLP telemetry. Do **not** use an Anthropic/OpenAI provider key here; provider keys authenticate model calls, while the Revenium key authenticates telemetry ingest.

```json
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://api.revenium.ai/meter/v2/otlp",
    "OTEL_EXPORTER_OTLP_HEADERS": "x-api-key=rev_mk_your_tenant_yourkey",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_METRICS_EXPORTER": "none",
    "OTEL_LOGS_EXPORT_INTERVAL": "5000",
    "OTEL_RESOURCE_ATTRIBUTES": "revenium.middleware.source=managed-settings"
  }
}
```

4. Click **Add settings** or save the managed settings.
5. Ask developers to fully quit and relaunch Claude Code after the config push.

On first launch after the settings are picked up, each developer may see a one-time security approval dialog listing the managed environment variables. They should approve the administrator-delivered configuration.

#### Verifying Your Configuration

Ask a developer to run a brief Claude Code session. Usage should appear in Revenium after the next telemetry flush. Your Revenium tenant is identified by the metering key, and Claude Code attaches the developer identity it knows for the session. If your organization uses direct API keys, Bedrock, Vertex, Microsoft Foundry, or a custom `ANTHROPIC_BASE_URL`, attach identity yourself with `OTEL_RESOURCE_ATTRIBUTES`.

If no sessions appear after configuring the settings, check:

* The Revenium metering key is active in your Revenium account
* The OTLP endpoint matches your Revenium environment
* The developer fully quit and relaunched Claude Code after the config push

{% hint style="info" %}
**Field reference**

* **`OTEL_EXPORTER_OTLP_ENDPOINT`** — Revenium's OTLP endpoint. For most customers this is `https://api.revenium.ai/meter/v2/otlp`.
* **`OTEL_EXPORTER_OTLP_HEADERS`** — Your Revenium metering key, prefixed with `x-api-key=`.
* **`OTEL_EXPORTER_OTLP_PROTOCOL`** — Must be `http/json`.
* **`OTEL_LOGS_EXPORTER`** — Must be `otlp`. This enables log export, which is how Revenium receives per-call telemetry.
* **`OTEL_METRICS_EXPORTER`** — Must be `none`. Revenium bills from log events only; leaving metrics enabled is unnecessary and increases HTTP traffic without adding data.
* **`OTEL_LOGS_EXPORT_INTERVAL`** — Milliseconds between log-batch flushes. `5000` matches Claude Code's documented/default flush interval.
* **`OTEL_RESOURCE_ATTRIBUTES`** — OTEL resource attributes attached to every event from this deployment. The required value `revenium.middleware.source=managed-settings` tags telemetry as originating from a centrally-managed settings deployment. Per-developer CLI installs are automatically tagged `revenium-cli`, so the two deployment channels are separable in Revenium reporting. If you add your own attribution labels, append them comma-separated to this value (see [Optional Internal Attribution](#optional-internal-attribution) below).
  {% endhint %}

#### Optional Internal Attribution

The required configuration above is enough for correct metering and dashboard attribution. If you want to sub-segment your own Claude Code usage within your Revenium tenant — for example to compare spend across business units, teams, or internal product lines — extend the existing `OTEL_RESOURCE_ATTRIBUTES` value by appending your labels comma-separated after `revenium.middleware.source=managed-settings`:

```json
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://api.revenium.ai/meter/v2/otlp",
    "OTEL_EXPORTER_OTLP_HEADERS": "x-api-key=rev_mk_your_tenant_yourkey",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_METRICS_EXPORTER": "none",
    "OTEL_LOGS_EXPORT_INTERVAL": "5000",
    "OTEL_RESOURCE_ATTRIBUTES": "revenium.middleware.source=managed-settings,organization.name=Engineering,product.name=internal-claude-code"
  }
}
```

Keep `revenium.middleware.source=managed-settings` as the first entry — do not remove it. The additional labels are yours to define. They are not matched against any existing list in Revenium. Choose labels that make sense for your internal reporting.

* `organization.name` — a business unit, department, or cost center, such as `Engineering`, `DataPlatform`, or `Marketing`
* `product.name` — the application or use case, such as `internal-claude-code`

{% hint style="warning" %}
**`OTEL_RESOURCE_ATTRIBUTES` formatting constraints:**

* **No spaces in values.** Use underscores, camelCase, or percent-encoding (`%20`) instead, for example `organization.name=Data_Platform` or `organization.name=DataPlatform`, not `organization.name=Data Platform`.
* **Values are case-sensitive.** `Engineering` and `engineering` are treated as separate labels. Pick a canonical form and use it consistently across all configuration and integrations.
  {% endhint %}

{% hint style="info" %}
**Third-party provider compatibility.** [Server-managed settings](https://code.claude.com/docs/en/server-managed-settings) are delivered from Anthropic's servers and require a direct connection to `api.anthropic.com`. They are not delivered when Claude Code is routed through Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry, Claude Platform on AWS, or custom API endpoints via `ANTHROPIC_BASE_URL` or third-party LLM gateways. If your organization uses one of these providers, use endpoint-managed settings or the per-developer CLI setup instead.

Endpoint-managed settings are deployed to each device through native OS policies — macOS managed preferences or the Windows registry — or through a managed settings file, typically using the mobile device management (MDM) or endpoint-management tool your organization already runs. Behind a gateway, this is the delivery channel by design: it enforces the configuration without asking users to change their shells, and the settings file can be protected from user modification at the OS level.
{% endhint %}

{% hint style="info" %}
**Managed settings override user-level configuration.** Values defined in the managed settings `env` block take precedence over shell-exported environment variables on each user's machine, including values the Revenium CLI may have previously set.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.revenium.io/track-and-control-costs/analyze-ai-tooling-spend/setup-claude-code.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
