Skip to main content

Write a Folder Backup Script with Codex CLI on Free Sign-Up Credit

Updated 2 min readMarkdown

A practical first Codex task: a bash script that zips a folder into a dated backup file. Run it on a relay's free sign-up credit.

1. Pick a relay that works with Codex

On the AI Relay list, AgentRouter's card says Claude Code and Codex both work: $100 free sign-up credit at 1x, GitHub account from before 2026. Create a token after you log in.

2. ~/.codex/config.toml

model = "<model name copied from the relay's list>"
model_provider = "relay"

[model_providers.relay]
name = "relay"
base_url = "https://<relay address>/v1"
env_key = "RELAY_API_KEY"
wire_api = "chat"

3. Export the key and start

export RELAY_API_KEY="<your relay key>"
mkdir backup-tool && cd backup-tool
codex

4. The prompt

Write backup.sh. Take a folder path as the first argument,
zip it to ~/backups/<foldername>-YYYY-MM-DD.zip,
create ~/backups if missing, and print the output path.
Exit with an error message if the folder doesn't exist.

5. Test it on something harmless

chmod +x backup.sh
mkdir -p /tmp/demo && echo hi > /tmp/demo/a.txt
./backup.sh /tmp/demo

Read the script before you point it at real folders.

Next small asks

  • "Keep only the 7 newest backups."

  • "Add a --dry-run flag."

If Codex errors

  • 404: base_url is missing /v1

  • 401: key not exported, incomplete, or credit used up

  • 429: rate limit. Wait or switch relays.

Card details and config notes: jliushi.github.io/ai-relay

No comments yet. Be the first to comment.

More from this blog