---
title: Set up background tools with Agents Relay
nav: Agents Relay
summary: Keep Doubao Pro as your main Agent in mainland China, and give Claude Code or Codex a background role through an official account or Agents Relay without sharing a key in chat.
order: 64
nav_order: 37.5
---
# Set up background tools with Agents Relay

[Agents Relay](https://agentsrelay.net/) is an independent model-access service. Its plans and API keys can connect tools such as Claude Code, Codex CLI and OpenCode. It is not operated by Agent J; check pricing, model availability and service regions on its own site. Agent J does not sell its plans.

## A reliable setup in mainland China {#recommend}

For day-to-day conversation on your phone, use **the latest Doubao Pro model on Volcano Ark as Agent J's main Agent**. Give Claude Code and Codex a different job: run them **headlessly in the background for specific tasks**, whether your access comes from their official accounts or Agents Relay. This keeps your main conversation on a locally available model without giving up the tools you need for delegated work. [Set up Volcano Ark first](/docs/ark/). If you have no official Claude Code or Codex account but do have Agents Relay, leave Doubao in charge and connect the relay as a background account. This procedure does **not** switch the main Agent; [switching AI coding tools](/docs/switch-harness/) is a separate choice.

> **Keep the key off chat:** send your main Agent only the site's **safe prompt**, not the API key, terminal exports or configuration text containing it. The downloaded configuration package contains the key. Keep it on your Agent J host, never in a repository, message or upload.

## Buy a plan and create a key {#key}

1. Sign in to [Agents Relay](https://agentsrelay.net/), pick a plan for the tools and models you intend to use, and check its price and terms before paying.
2. On [API Keys](https://agentsrelay.net/keys), select **Create Key**. Enter a memorable name and leave the other options at their defaults. Under **Vendor**, choose **Claude** or **OpenAI** to match the plan you bought and the tool you want to configure. The key is associated with that plan automatically.

![Choose the vendor when creating a key; keep the other defaults](create-key.png)

## Download the package and send the safe prompt {#setup}

1. In the key list, find **Actions → Use Key**. Select your tool at the top (Claude Code, Codex CLI or OpenCode) and the host's operating system (macOS / Linux, Windows CMD or PowerShell).
2. Select **Download Configuration Package** and keep it in the host's Downloads folder. Then select **Copy Safe Prompt** and send **only that prompt** to your current Agent J main Agent. The prompt contains no API key; the package does. Do not copy the page's terminal commands or settings excerpts that contain your key.
3. Add: “Set this up only as a background headless account. Keep Doubao as my main Agent. Install and check it locally following the safe prompt; do not read out, print or upload the key or package. Tell me which settings will change before proceeding.” Let your main Agent perform the local setup and report the result.

![Tool and operating-system choices on Use Key; key-bearing snippets have been obscured](use-key-redacted.png)

The sidebar's [One-click Setup](https://agentsrelay.net/custom/onboard) also offers the package and safe prompt. Prefer that pair over the alternative that asks you to paste a key into a terminal. Download the package **on the computer hosting Agent J**: a file downloaded to your phone does not appear there automatically.

## Verify the background account {#check}

Ask your main Agent to check that configuration is present without printing or transmitting the key, then run one small, headless background task with the newly configured tool that reads no personal files. It should report the tool, success or failure and a redacted error category—never package contents, request headers or a key suffix. If it fails, check the plan status and errors below. After upgrading to 0.30.7, just tell the Agent “check relay”: it checks, read-only, which domain Claude Code and Codex connect to and sends each one shortest request.

## Hand a task to Claude Code or Codex {#dispatch}

From 0.30.29 your main Agent, whichever AI it uses, can send one task to Claude Code or Codex through your Agents Relay key. It does not use or change your own Claude Code or Codex sign-in.

1. On the phone, open Settings → Models & API keys → Agents Relay and save the key for each plan you bought: the Claude key for Claude Code, the OpenAI key for Codex. Enter it only on the encrypted key card.
2. Ask your main Agent to hand the work over, for example “give this bug to Claude Code” or “have Codex write the draft”. Development usually goes to Claude Code; writing and content go to Codex.
3. A Face ID card appears on your phone with the tool, folder, model, time limit and the whole task. Read it before you allow it: the job then runs in the background with **full permissions on your Agent J host**, without a sandbox or step-by-step confirmations, and holds the key while it runs.
4. The result comes back to your main Agent with anything that looks like a key hidden. A failed or interrupted job is not re-run automatically.

The task, the files it reads and its replies pass through Agents Relay. Keep passwords, keys, customer data, financial records and production access out of these tasks.

Commands your main Agent uses:

```bash
agentj relay status
agentj relay claude --full "<task>"
agentj relay codex --full "<task>"
```

## Return to an official account {#restore}

Pause background tasks first. Tell your main Agent: “Restore the background tool we just configured to its official sign-in without changing Doubao as my main Agent. Show me the backup and impact first.” Have it follow recovery instructions **included with the package and verified as authentic**, confirm that the official sign-in still works and test a small task. Do not delete your entire Claude Code or Codex settings directory. We will add the exact one-step restore command after it is verified and available; this page does not guess at it.

## If something fails {#errors}

| Error | First place to look |
|---|---|
| 401 Unauthorized | Check that the key is active and the plan has not expired, and that the package matches the selected Vendor. Never paste the key into chat for debugging. |
| 403 Forbidden | Check plan/account permissions and service-region restrictions; do not bypass restrictions with another region's account. |
| 404 Model or endpoint not found | Check which models the selected plan and tool support, then download a matching package again via Use Key rather than editing endpoints by hand. |
| 429 Rate or quota limit | Check the plan's usage and rate limits or balance. Wait for a reset or follow the provider's top-up instructions; avoid repeated automatic retries. |
| Subscription expired | Renew with the provider or use another account you already have. Your Doubao main Agent does not need to change. |

If your main Agent is offline, [restore your phone connection](/docs/reconnect/) before working on the background tool. For Agent J issues see the [FAQ](/docs/faq/); ask Agents Relay about its plan and billing.
