> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sazabi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex sandbox CLI

> Give the Sazabi agent the OpenAI Codex CLI (codex) in its sandbox for AI-powered coding.

[All Codex integration capabilities](https://docs.sazabi.com/catalogs/integrations/codex)

## About

This CLI connection makes OpenAI's Codex CLI (`codex`) available in the Sazabi agent's sandbox. The agent can use it for AI-powered coding tasks. The tool is already installed in the sandbox; connecting it signs the CLI in with your OpenAI API key so the agent can run it non-interactively.

Sazabi also has a separate Codex integration under [**Settings > Integrations**](https://app.sazabi.com/settings/integrations), where you sign in with ChatGPT to hand fixes off to Codex. That connection is independent of this one and does not supply the key the sandbox CLI uses.

## Prerequisites

* A Sazabi project.
* An [OpenAI API key](https://platform.openai.com/api-keys) (`OPENAI_API_KEY`). The key is required for non-interactive use, which is how the agent runs the CLI.

## Set up in the dashboard

Configure the sandbox in the dashboard under [**Settings > Sandbox CLIs**](https://app.sazabi.com/settings/sandbox-clis).

**Step 1**

### Find Codex in the catalog

In [**Settings > Sandbox CLIs**](https://app.sazabi.com/settings/sandbox-clis), find Codex under **Browse sandbox CLIs** and choose to connect it.

**Step 2**

### Provide credentials

Paste your key into **OpenAI API key** and save. Sazabi checks the key with OpenAI before saving, and a rejected key saves nothing. Once saved, the CLI is signed in whenever the agent runs.

## Set up with the CLI

You can also configure the Codex CLI connection with the [Sazabi CLI](https://docs.sazabi.com/reference/cli.md) (installed and authenticated; see [CLI reference](https://docs.sazabi.com/reference/cli/sandbox-clis.md)).

```bash theme={"system"}
sazabi sandbox-clis connect codex --env OPENAI_API_KEY=<your-openai-key>
```

`connect` tests the key first, and a failed test saves nothing. To validate the key without saving, run the same command with `test` in place of `connect` (the test command also requires the `--env` flags). To keep the key out of your shell history, pass `--env-file <path>` instead of `--env`.

## Verify

In a thread, ask the agent to run `codex exec --skip-git-repo-check "Reply with exactly: codex-ok"` and show the output. The check passes when the thread shows the reply `codex-ok` from your OpenAI account. A `401` or sign-in error means the key was not accepted; see Troubleshooting.

## Troubleshooting

**Command not found**: Confirm the Codex CLI connection is enabled for the project under [**Settings > Sandbox CLIs**](https://app.sazabi.com/settings/sandbox-clis).

**Connect or test fails**: OpenAI rejected the key, so nothing was saved. Check that you copied the full key and that it is still active on the [OpenAI API keys page](https://platform.openai.com/api-keys).

**Authentication fails after it worked before**: The key was probably rotated or revoked. Re-enter the new key under [**Settings > Sandbox CLIs**](https://app.sazabi.com/settings/sandbox-clis) or run `sazabi sandbox-clis connect codex` again.

**Signed in with ChatGPT but the CLI still fails**: The ChatGPT sign-in under [**Settings > Integrations**](https://app.sazabi.com/settings/integrations) does not authenticate the sandbox CLI. Add an OpenAI API key here.

## Further reading

> [card] [Working with the agent](https://docs.sazabi.com/ask/better-answers.md)
>
> Put the connected CLI to work in an investigation thread.

> [card] [Set up the sandbox](https://docs.sazabi.com/ask/sandbox.md)
>
> How the sandbox works and its security model.

> [card] [Sandbox CLIs](https://docs.sazabi.com/catalogs/integrations.md#sandbox-clis)
>
> Browse the catalog and connect more tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.