How to Use xAI in Codex
To use xAI in Codex, connect Spiral to Codex once, then ask for what you want in plain words. Codex can then reach all 3 xAI tools on Spiral, priced per run from one balance.
Prompts to try with xAI in Codex
Copy an example into Codex, or ask in your own words.
Estimate, then generate a 5-second 9:16 clip with xAI: a paper boat drifting down a rainy street. Save the result in ./assets.
Make a 10-second product teaser with xAI for a smartwatch, slow orbit shot, studio lighting.
Generate three 5-second b-roll clips of a busy coffee shop with xAI and list what each cost.
Make a 6-second 16:9 drone shot over a misty pine forest at sunrise with xAI.
Write three video ideas for our launch, then make the best one with xAI and show me the cost first.
How to set up xAI in Codex
Pick the way that suits you. Each takes about two minutes.
Use Spiral's MCP server
- Add the hosted server
codex mcp add spiral --url https://api.spiral.ai/mcp
- Sign in
Codex opens the browser: sign in to Spiral and click Authorize. No API key. codex mcp list then shows Spiral.
codex mcp login spiral
Use the Spiral skill
- Send Codex this message
Your agent reads Spiral's skill and sets itself up.
set up https://spiral.ai/SKILL.md
- Sign in or paste a key
Approve Spiral in the browser, or give the agent a key from the console.
Use the Spiral CLI
- Install and sign in
Installs the Spiral CLI, signs you in and adds its skill to your coding agents.
npx -y spiral-cli@latest init
Call the Spiral API
- Create an API key
In the console, under API keys.
- Run xAI
One request; the result comes back by polling or a webhook.
curl https://api.spiral.ai/v1/runs \ -H "Authorization: Bearer $SPIRAL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "provider": "xai", "model": "grok-imagine-video-1.5", "input": { "image": {} } }'
Then paste one of the prompts above: Codex finds xAI on Spiral, shows the price and runs it.
xAI tools you can run in Codex
2Ready to run from Codex: today's price, with every fee included.
$0.104 per second at 480p ($0.182 at 720p, $0.325 at 1080p). Input image: $0.013. Each reference image: $0.013.
$0.052 per image at 1K ($0.065 at 1.5K, $0.078 at 2K); medium quality $0.078 at 1K ($0.091 at 1.5K, $0.104 at 2K).
What can you do with xAI in Codex?
Codex can generate video from text with xAI right in your repository and save the results where you need them: as files in your project, in a script or in your build. One sign-in covers every tool, so your code stays free of provider SDKs and keys.
Ads and social clips
Short vertical or square clips from a written brief.
B-roll
Fill gaps in an edit with generated shots that match the scene.
Storyboards that move
Turn a script's scenes into rough cuts to review.
Product teasers
Short launch clips without a shoot.
Explainer scenes
Visualize a concept in a few seconds of video.
Concept testing
Try several directions before paying for production.
More on xAI and Codex
Overview
xAI in other agents
Questions about xAI in Codex
Can Codex use xAI?
Yes. Add Spiral to Codex as an MCP server, and Codex can find and run xAI like any built-in tool.
How much does xAI cost in Codex?
Each tool has its own price, for example Grok Imagine Video 1.5 Video Generation: $0.104 per second at 480p ($0.182 at 720p, $0.325 at 1080p). Input image: $0.013. Each reference image: $0.013; Grok Imagine Image 2.0 Text to Image: $0.052 per image at 1K ($0.065 at 1.5K, $0.078 at 2K); medium quality $0.078 at 1K ($0.091 at 1.5K, $0.104 at 2K). You pay per run from one Spiral balance, and failed runs are free.
Do I need a xAI account to use xAI in Codex?
No. Spiral runs xAI on its own xAI account. You sign in to Spiral once and never paste a key.
How long does it take to set up xAI in Codex?
About two minutes: add the hosted server, then sign in.
Does Codex wait while xAI runs?
xAI runs in the background. Codex starts the run, checks on it and gives you the video when it's ready.
Which xAI tools can Codex use?
Codex can reach all 3 xAI tools on Spiral, covering image and video. Popular ones include Grok Imagine Video 1.5 · Video Generation and Grok Imagine Image 2.0 · Text to Image. Ask for one by name, or describe the task and Codex picks a fitting tool.
Can Codex compare xAI tools?
Yes. Ask Codex to run the same request on two xAI tools and show both results with what each cost. Each run is priced and billed on its own.
What happens if a xAI run fails in Codex?
It is not charged. Spiral holds the estimated price when the run starts and returns it to your balance if the run fails on Spiral's side or the provider's. Codex gets the error and can retry or try another tool.
Is there a xAI subscription or plan?
No. Spiral is pay as you go from one prepaid balance, with no plans or minimums, and credits never expire. Auto top-up keeps Codex from stopping when the balance runs low.
Start using xAI in Codex
One Spiral account for every tool your agent needs. No subscription; you pay per run.
Paste this into Codex:
set up https://spiral.ai/SKILL.md


