---
title: "Coder AI"
canonical_url: "https://docs.getdx.com/connectors/coder-ai/"
md_url: "https://docs.getdx.com/connectors/coder-ai.md"
last_updated: "2026-09-11"
---

# Coder AI
Connect Coder AI to DX to import daily AI Gateway usage, estimated spend, provider and model breakdowns, and Coder users. DX links this data to your user directory so you can measure AI adoption by user and team.

> **Note**: DX imports aggregated usage and identity data. It does not import AI session, thread, prompt, tool-call, or network-call content from Coder.

## Before you begin

- **Coder version 2.36.0 or later** with [AI Gateway](https://coder.com/docs/ai-coder/ai-gateway){.new-tab} enabled and entitled.
- **AI Gateway provider configuration** that routes your supported AI tools through Coder. Refer to [Coder's client configuration](https://coder.com/docs/ai-coder/ai-gateway/clients){.new-tab}.
- **A dedicated Coder service account** with the built-in auditor role.
- **A long-lived Coder API token** created for the service account.
- **An HTTPS deployment URL** that DX can reach.

## Set up Coder AI

### Step 1: Create an auditor service account

Create a dedicated service account for DX and assign it the built-in auditor role. The auditor role gives DX read access to the deployment, organizations, users, entitlements, and AI spend export without granting workspace-management permissions.



### Coder UI

1. Sign in to Coder as an owner.
1. Go to **Deployment** -> **Users** and select **Create user**.
1. Enter `dx-connector` as the username.
1. Select **Service account** as the login type.
1. Under **Roles**, select **Auditor**.
1. Select **Save**.

### Coder CLI

Sign in to the Coder CLI as an owner, then run:

{% codeblock "bash" %}
coder users create --username dx-connector --service-account
{% endcodeblock %}

Creates a dedicated Coder service account named `dx-connector`.

{% codeblock "bash" %}
coder users edit-roles dx-connector --roles auditor --yes
{% endcodeblock %}

Assigns the built-in auditor role to the `dx-connector` service account.

Refer to the [`coder users create` reference](https://coder.com/docs/reference/cli/users_create){.new-tab .underline} for all available options.



For more information, see Coder's [service account documentation](https://coder.com/docs/admin/users/headless-auth){.new-tab}.

### Step 2: Create an API token

Create an API token for the service account with an organization-approved lifetime. The following example creates a token that lasts for one year:

{% codeblock "bash" %}
coder tokens create --user dx-connector --name dx-coder-ai --lifetime 1y
{% endcodeblock %}

Only a Coder owner can create a token for another user. Keep `--lifetime` explicit so the token's expiration is intentional and reproducible instead of inheriting the deployment's maximum token lifetime. The requested lifetime cannot exceed the deployment's [`CODER_MAX_TOKEN_LIFETIME`](https://coder.com/docs/reference/cli/server#--max-token-lifetime){.new-tab} setting, so replace `1y` with the duration approved by your organization and adjust that setting first if necessary.

Copy the token when Coder displays it, store it securely, and record its expiration date. Rotate it in DX before it expires, verify the connection with the replacement token, and then revoke the old token. See [Coder's token management documentation](https://coder.com/docs/admin/users/sessions-tokens){.new-tab} for more information.

### Step 3: Add the connection

1. Go to **DX** -> **Settings** -> **Data connectors**, then select **+ Connection**. <a href="https://app.getdx.com/admin/datacloud/connections/new" target="_blank" rel="noopener noreferrer" class="new-tab inline-flex align-middle" title="Open the new connection page in a new tab">{% svg "link-external", "size-4" %}<span class="sr-only">Open the new connection page in a new tab</span></a>
1. Choose **Coder AI** as the connector type.
1. Enter the HTTPS URL for your Coder deployment in **Deployment URL**.
1. Enter the service-account token in **Session token**.
1. Select **Add connection**.

DX verifies the Coder version, AI Gateway entitlement, organizations, users, and AI spend export before saving the connection.

## Troubleshoot the connection

- **Unsupported Coder version**: Upgrade the deployment to Coder 2.36.0 or later.
- **AI Gateway entitlement unavailable**: Enable AI Gateway and confirm that the deployment has an eligible Coder license.
- **Authentication or permission error**: Confirm that the token belongs to the service account and that the account has the auditor role.
- **No organizations returned**: Confirm that the service account can read at least one Coder organization.
- **Unexpected or malformed spend export**: Confirm that the deployment's AI spend export is available and returns the documented CSV format.

## Next steps

### Review AI cost data

Open [AI cost management](https://docs.getdx.com/reports/ai-cost-management/){.underline} to review Coder-estimated spend alongside token usage.

### Explore imported fields

Use the [schema explorer](https://docs.getdx.com/schema/){.underline} to inspect the Coder user, daily spend, daily user metric, and model breakdown fields available in DX.
---

## Sitemap

[Overview of all docs pages](/llms.txt)
