# Use your own subscription

Source: https://agenta.ai/docs/self-host/use-your-own-subscription

By default, Agenta runs agents with a model API key it resolves for each run. You can instead run
agents with your own harness subscription: a Pi login, a Claude Code login, or a ChatGPT/Codex
login.

A subscription authenticates the harness through a directory mounted into the runner container, so
it works only with [local runs](https://agenta.ai/docs/self-host/agent-execution/run-agents-locally.md). Agenta never
uploads the login to a Daytona sandbox, and a Daytona run cannot use one.

This tutorial mounts your login into the runner container and runs an agent that uses it.

:::tip Claude Pro or Max: paste a token instead
For Claude, the simpler option is to paste a token from `claude setup-token` in
`Settings > AI providers`. It needs no mount, works with local and Daytona runs, and works on
Agenta Cloud too. See [Connect a Claude subscription](https://agenta.ai/docs/guides/connect-a-claude-subscription.md).
:::

:::warning This is for a single trusted operator
One personal subscription serves one operator, not every user of a shared deployment. Every local
run can read the files mounted into the runner container, including this login. Use this only on a
deployment you run for yourself. See
[Sandbox isolation and security](https://agenta.ai/docs/self-host/agent-execution/sandbox-isolation-and-security.md).
:::

## Before you start

- A running local OSS stack. See the [Quick start](https://agenta.ai/docs/self-host/quick-start.md).
- A harness you have logged into on your own machine:
  - **Pi** stores its login at `~/.pi/agent/auth.json`. Log in with `pi`, then `/login`.
  - **Claude Code** stores its login at `~/.claude/.credentials.json`. Log in with `claude` and
    pick the subscription login.
  - **Codex** stores its login at `~/.codex/auth.json`. Log in with `codex login` and pick the
    ChatGPT sign-in.

  To reach ChatGPT/Codex models through the **Pi** harness instead of the native Codex harness, use
  the Pi login above and pick the ChatGPT sign-in at `pi`'s `/login`; it writes the same
  `~/.pi/agent/auth.json` file.

## 1. Confirm the login on your machine

Check that the login file exists before you mount it:

```bash
# Pi (and ChatGPT/Codex models through the Pi harness)
ls ~/.pi/agent/auth.json

# Claude Code
ls ~/.claude/.credentials.json

# Codex
ls ~/.codex/auth.json
```

## 2. Check that the runner can read it

The runner container runs as uid 1000. A harness login file is mode `0600` and owned by you, so the
container can read it through a bind mount only when your own uid is 1000.

```bash
id -u
```

If that prints `1000`, mount your login directly in step 3.

If it prints anything else, the container cannot read the `0600` file, and the run fails as though
you had never logged in. In step 3 you run the container as your own user by adding two lines. This
mounts your real login directly, so a refreshed token stays in sync between the container and your
own machine.

## 3. Mount the login into the runner

Edit the `runner` service in your Compose file
(`hosting/docker-compose/oss/docker-compose.gh.yml`). Add a read-write volume for your login and
point the harness at it.

For **Pi** (this also serves ChatGPT/Codex models reached through the Pi harness):

```yaml
runner:
  volumes:
    - ~/.pi/agent:/agenta/harness/pi:rw
  environment:
    PI_CODING_AGENT_DIR: /agenta/harness/pi
```

For **Claude Code**:

```yaml
runner:
  volumes:
    - ~/.claude:/agenta/harness/claude:rw
  environment:
    CLAUDE_CONFIG_DIR: /agenta/harness/claude
```

For the **Codex** harness:

```yaml
runner:
  volumes:
    - ~/.codex:/agenta/harness/codex:rw
  environment:
    CODEX_HOME: /agenta/harness/codex
```

Codex reads its login from `CODEX_HOME`. The runner mounts the directory read-write and links only
its `auth.json` into each run, so a refreshed token lands back in your login while your personal
`config.toml` and plugins stay out of the run.

If your uid is not 1000 (step 2), also run the container as your own user so it can read the mounted
login. Add `user:` with your `id -u`:`id -g`, and set `HOME` to a writable path. For Claude Code:

```yaml
runner:
  user: "1001:1001" # your id -u:id -g
  volumes:
    - ~/.claude:/agenta/harness/claude:rw
  environment:
    HOME: /tmp
    CLAUDE_CONFIG_DIR: /agenta/harness/claude
```

`HOME: /tmp` is required here. Running as a non-default user sets the container's home directory to a
path the harness cannot write, and the harness writes working files under it.

:::warning Do not set a provider API key on the runner
A self-managed run inherits the provider keys present in the runner's environment (for example
`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`), and the harness then authenticates with the key instead of
your login. The bundled Compose files set none of them on the `runner` service. Leave it that way.
:::

The mount is read-write, and the harness runs directly out of it. These are OAuth logins: the
harness refreshes its access token during a run and writes the new one back. Because the mount is
writable, the refreshed token lands in your login on the host, so runs keep working after the
provider rotates a token and you never log in again by hand.

The harness writes other things there too. A run that carries skills or a system prompt installs
them into the same directory, and concurrent local runs share it, the same way two `pi` or `claude`
sessions on your laptop do.

Recreate the runner so it picks up the change:

```bash
docker compose -f hosting/docker-compose/oss/docker-compose.gh.yml \
  --env-file hosting/docker-compose/oss/.env.oss.gh up -d --remove-orphans runner
```

## 4. Run a self-managed agent

In the studio, run an agent and choose the self-managed credential option (use your own login)
for the matching harness. The run authenticates with your mounted subscription instead of a
managed key.

When you select the subscription option, the credential card checks the runner and reports what it
finds for the selected harness:

| Message | Meaning |
| --- | --- |
| `Subscription login found` | The mount is set and the login file looks usable. |
| `Runner found. Subscription folder is not configured.` | The runner has no mount variable for this harness. Recheck step 3. |
| `Runner found. Login file is missing.` | The mount variable is set, but the expected file is not there. Recheck steps 1 and 3. |
| `Runner found. Login file cannot be used.` | The file exists but is empty or unreadable. Recheck step 2 (file ownership). |
| `Runner is not connected.` | Agenta cannot reach the runner container. |
| `Update the runner to check subscription status.` | The runner predates this check. |

The check reads only the local login location. It does not contact the provider, so
`Subscription login found` means the file is in place, not that the subscription is active. A
successful run remains the proof. Use **Check again** after you change a mount or sign in again;
the card also refreshes itself every few seconds while open.

If the run fails because the harness has no login, the mount is missing, the runner cannot read it
(step 2), or `PI_CODING_AGENT_DIR` / `CLAUDE_CONFIG_DIR` / `CODEX_HOME` does not point at it. Recheck
steps 2 and 3.

## Next

- [Run agents locally](https://agenta.ai/docs/self-host/agent-execution/run-agents-locally.md) configures the provider these
  runs use.
- [Sandbox isolation and security](https://agenta.ai/docs/self-host/agent-execution/sandbox-isolation-and-security.md) covers
  what else can read the mounted login.
