Codex builds the feature, writes the tests, and commits the code. Then it generates a hero image, a UI mockup, a product video. Those files exist in the sandbox — and when the sandbox ends, they're gone.
Cloud storage is the missing step. Without it, Codex can't hand off generated assets to the rest of your team, link to them from a live page, or retrieve them in the next agent session.
Here's how to add cloud storage to Codex. Three approaches, with real command examples.
Why Codex Doesn't Include Cloud Storage Natively
Codex is OpenAI's agentic coding tool. It operates in ephemeral cloud sandboxes — the environment is fresh per session, and files generated in one session don't persist to the next unless you explicitly write them somewhere durable.
Cloud storage requires authentication with an external service (S3, GCS, Azure Blob, or a purpose-built file API), upload logic, URL generation, and permission management. None of that is in Codex's native scope. The capability layer is external, and how cleanly it plugs in is the practical question.
What Codex + Cloud Storage Unlocks
When you add cloud storage to Codex, generated assets become persistent and shareable:
- Generated images and videos survive the session. Hero images, UI mockups, product demos — uploaded immediately after generation, accessible after the sandbox closes.
- Shareable links for review. Codex generates an asset, uploads it, and returns a URL your team can open in a browser — no file transfer required.
- Assets embed in published pages. Codex generates a hero image, uploads it to cloud storage, embeds the URL in the landing page it's building — all in one session.
- Cross-session continuity. Codex retrieves files from a previous session by name or path. The storage layer persists what the sandbox doesn't.
- CI and automation pipelines. Automated Codex jobs generate report assets, upload them, and share links in a Slack notification or commit comment.
Method 1: Direct Cloud Provider Integration
Codex can install and call the AWS CLI, Google Cloud SDK, or Azure CLI in its sandbox:
# AWS S3 example
pip install awscli
aws s3 cp ./generated-hero.jpg s3://your-bucket/assets/generated-hero.jpg --acl public-read
echo "https://your-bucket.s3.amazonaws.com/assets/generated-hero.jpg"
Setup required:
- Cloud provider account and bucket/container configuration
- IAM credentials or service account with upload permissions
- CLI installed and authenticated in the Codex sandbox
- Public URL or signed URL generation logic
This works but requires provider-specific setup. Different providers have different CLIs, different authentication patterns, and different URL formats. When Codex switches projects that use different storage backends, the integration scripts diverge.
Method 2: MCP Server for File Storage
MCP servers can expose file storage as a structured tool:
- AWS S3 MCP — upload and retrieve from S3 buckets
- Google Drive MCP — manage files in Google Drive
- Cloudflare R2 MCP — S3-compatible storage via Cloudflare
Configure the MCP server once. Codex calls it like any tool. Cleaner than maintaining provider-specific shell scripts.
Limitation: each MCP server is tied to one storage provider. If your team uses S3 for assets and Drive for documents, you're configuring and maintaining both.
Method 3: One CLI Across Upload, Share, and Retrieve
This is the approach where Codex handles file storage through the same CLI it uses for image generation, video generation, and web search:
# Upload files and get shareable links
anycap drive upload hero.jpg product-demo.mp4
# Upload with a custom name
anycap drive upload ./output/hero.jpg --name "landing-hero-v2.jpg"
# Retrieve a file from a previous session
anycap drive download "landing-hero-v2.jpg" -o ./assets/hero.jpg
# List stored files
anycap drive ls
One auth. One CLI. Codex doesn't maintain separate credentials for storage versus image generation versus search — it's all one tool.
Install AnyCap for Codex:
npx -y skills add anycap-ai/anycap -a codex -y
anycap login && anycap status
The Full Codex Generate → Upload → Embed Pipeline
The most powerful pattern: Codex generates an asset, uploads it immediately, and embeds the live URL in the page it's building — all in one session.
# Step 1: Generate the hero image
anycap image generate \
--prompt "developer dashboard, dark theme, neon blue accents, product photography style" \
--model seedream-5 \
-o hero.jpg
# Step 2: Upload to Drive and get the shareable URL
HERO_URL=$(anycap drive upload hero.jpg --format url)
# Step 3: Codex embeds the URL in the landing page HTML
# Codex generates/edits index.html with <img src="$HERO_URL" alt="Dashboard hero">
The image is now on a live URL that persists after the sandbox closes. Your team can review it, the page references it, and the next Codex session can retrieve it by name.
Practical Patterns for Codex + Cloud Storage
Pattern 1: Generate and Share for Review
# Generate a set of variations, upload all, return links for team review
anycap image generate --prompt "hero v1 style" --model seedream-5 -o hero-v1.jpg
anycap image generate --prompt "hero v2 style" --model seedream-5 -o hero-v2.jpg
anycap drive upload hero-v1.jpg hero-v2.jpg
# Codex returns both URLs in a review summary message
Pattern 2: Video Production Pipeline
# Full generate → animate → store pipeline
anycap image generate \
--prompt "product hero shot, dark theme, neon accents" \
--model seedream-5 \
-o hero.jpg
anycap video generate \
--prompt "interface animates in sequence, gentle camera push-in" \
--model seedance-2 \
--mode image-to-video \
--param images=./hero.jpg \
-o hero-animated.mp4
# Upload both
anycap drive upload hero.jpg hero-animated.mp4
Pattern 3: Cross-Session Asset Retrieval
# Session 1: Generate and store
anycap image generate --prompt "brand hero image" --model seedream-5 -o brand-hero.jpg
anycap drive upload brand-hero.jpg --name "brand-hero-approved.jpg"
# Session 2: Retrieve and use
anycap drive download "brand-hero-approved.jpg" -o ./assets/hero.jpg
# Codex uses ./assets/hero.jpg in the current build
Pattern 4: Automated Report with Uploaded Assets
# CI pipeline: generate chart, upload, include URL in Slack notification
anycap image generate --prompt "weekly metrics chart, bar graph style" --model nano-banana-pro -o weekly-chart.jpg
CHART_URL=$(anycap drive upload weekly-chart.jpg --format url)
# Post $CHART_URL to Slack webhook
Storage + Other Capabilities: The Full Stack
The most powerful Codex setup combines storage with the full AnyCap capability set:
| Capability | Command | Use in Codex |
|---|---|---|
| Image generation | anycap image generate |
Create visual assets |
| Video generation | anycap video generate |
Animate stills, create demos |
| Web search | anycap search |
Research before coding |
| URL crawl | anycap crawl |
Read live docs and pages |
| Cloud storage | anycap drive upload |
Persist and share all of the above |
| Web publish | anycap page publish |
Host generated content at a live URL |
One install covers all of these. The same credentials that authenticate image generation authenticate file storage. Codex doesn't maintain separate API keys for each capability.
Cross-Agent: Same Commands, Different Agents
Cloud storage commands work identically across Codex, Claude Code, and Cursor. Only the skill installation target changes:
| Agent | Install target | Unique advantage for storage |
|---|---|---|
| Codex | ~/.codex/skills/ |
CLI-native — storage commands chain with && like any shell command |
| Claude Code | ~/.claude/skills/ |
Parallel uploads — Claude Code can upload batches via subagents simultaneously |
| Cursor | ~/.cursor/skills/ |
In-IDE — generated assets upload and embed directly from within the editor |
FAQ
Does Codex have native file persistence?
Codex operates in ephemeral sandboxes. Files generated in a session don't persist automatically after the session ends unless written to an external storage service. AnyCap's drive commands provide that external persistence layer.
How long are uploaded files stored?
Files uploaded through AnyCap's drive commands are stored on AnyCap's object storage infrastructure. Storage duration is determined by your plan.
Can I retrieve files from a previous Codex session?
Yes — if you uploaded the file during that session with anycap drive upload. Use anycap drive download "filename" to retrieve it in a new session. Use anycap drive ls to list available files.
Are uploaded files public?
By default, anycap drive upload generates a shareable URL that anyone with the link can access — useful for review and embedding. Private files require explicit permission configuration.
Can I use cloud storage in automated Codex pipelines?
Yes. anycap drive upload is headless — it runs in any shell context. Set ANYCAP_API_KEY as an environment variable and call it from any Codex automation, CI job, or scheduled task.
Can Codex embed the uploaded file URL directly into code?
Yes. Use anycap drive upload filename --format url to get just the URL as output. Codex can capture this in a variable and reference it in generated HTML, CSS, or any config file.
→ Give Codex cloud storage — one install, all capabilities
📖 What to Read Next
- How to Generate Images with Codex (2026) — Generate the assets you'll store.
- How to Generate Video with Codex (2026) — Video generation companion guide.
- How to Give Codex Web Search (2026) — Add research capability alongside storage.
- AI Image-to-Video: The Complete Pipeline — The full generate → animate → store workflow in detail.
Related Articles
- What Is a Capability Runtime? — The infrastructure that bundles image, video, search, and storage into one CLI.
- Terminal Agent Showdown: Claude Code vs Codex vs Windsurf — How Codex compares to other terminal agents on capability breadth.
- How to Give Claude Code Cloud Storage — The Claude Code variant of this guide.
Written by the AnyCap team. We build the capability runtime that gives Codex cloud storage, image generation, video generation, and web search through one CLI — so your agent can generate, store, and ship without the sandbox disappearing on you.