# OpenAI Codex as a fulfiller

Codex can run the agh CLI, so it can claim requests, make files and deliver them on its own.

## 1. Give Codex a sign-in

A project admin adds a tool with the fulfiller role, on the web page (**Settings › Members** → **Add member** → **Tool**, name `codex`, role `fulfiller`) or from the CLI:

```text
agh tool add codex --role fulfiller
```

It prints `AGH_CLIENT_ID` and `AGH_CLIENT_SECRET` once. Adding `codex` to another project later reuses the same sign-in.

## 2. Set up the environment

**Codex cloud:** in the environment's settings,

- add the secrets `AGH_CLIENT_ID` and `AGH_CLIENT_SECRET`;
- add the variables `AGH_SERVER=https://app.assetgoeshere.com` and `AGH_PROJECT=<project>`;
- allow internet access to `app.assetgoeshere.com`, `login.assetgoeshere.com`, `*.amazonaws.com` (file uploads and the download go straight to S3);
- install agh in the setup script:

```text
curl -fsSL -o /usr/local/bin/agh https://app.assetgoeshere.com/download/agh-linux-x64
chmod +x /usr/local/bin/agh
```

**Codex CLI on your machine:** install agh as in `agh guide getting-started`, and export the same four variables in the shell you start Codex from.

## 3. Ask Codex to fulfill

Paste this into Codex, adjusting the filter:

```text
You are a fulfiller for Asset Goes Here (agh). Run `agh guide fulfiller` and follow it.
Loop: run `agh next --kind image --format json`; stop when it prints null.
For each request, make a file that matches its brief, spec and path extension,
fixing anything its reviewNote mentions, then deliver it with
`agh fill <id> <file> --provenance ai --made-by "<model or tool you used>"`.
Don't edit the game repository. Report what you delivered at the end.
```

## Making the files

- **Text and strings:** Codex writes these itself, translations included (`agh next --locale fr`; see `agh guide translations`). Use `--made-by "Codex"`.
- **Images:** Codex needs an image generator. If `OPENAI_API_KEY` is set and `api.openai.com` is allowed, it can run `agh openai --count 10`, which claims, generates and delivers in one step (see `agh guide openai`). Without a generator it can still make SVG or procedural placeholder art.
- **Audio:** needs a speech or music generator that Codex can call; otherwise leave audio to another fulfiller.

## Checking the work

Deliveries appear under **Review** on the web page. Accept or reject each one there, then press **Publish accepted assets** under **Publish**.
