Field Notes · AI Tutorials

Ollama Codex CLI: How to Save Your Astra Tokens

Ollama Codex CLI setup lets you offload grunt work to free or cheap models and save premium Astra tokens for the hard problems.

Mark Kashef6 min readWatch the video
Ollama Codex CLI model picker thumbnail showing Mark Kashef switching between cloud and local models

Ollama Codex CLI setup lets you swap Codex's default OpenAI models for free local ones or cheaper cloud ones, so you stop burning premium Astra tokens on grunt work. Install Ollama, add it to Codex as a model provider, then tell Codex to configure a local or cloud-based open model that fits your machine. Mark ran this on his own YouTube pipeline, keeping Astra for planning and routing filming guides and research to GLM 5.3 and a local Gemma model instead.

TL;DR

  • GLM 5.3 runs 10 to 20 times cheaper than GPT-6 Astra for the same request, since Astra charges $10 per million input tokens and $50 per million output tokens.
  • A $20 Ollama Cloud credit pack is worth about $60 of usage, and running a cheap model like Flash through it stretches roughly as far as another $100 to $200 spent on your Codex plan.
  • Setup takes one click in Ollama's settings for cloud models, plus a single prompt telling Codex to inspect your hardware and wire in a local, tool-capable model like Gemma 3.
  • Mark ran a three-agent workflow (Astra planning, GLM research, local Gemma shortlisting) that finished a hardware comparison task in about 10 minutes without spending a single Astra token on the grunt work.

How Ollama Codex CLI Setup Works

Ollama Codex CLI setup starts with the cloud models, which take exactly one click once Ollama is installed. Go to ollama.com, download the app, open Settings, scroll to Apps, and click "Add to Codex." Every cloud-based model in Ollama's picker shows up inside Codex right away, ready to swap in for any task.

Local models take one extra step, since Codex has to know what your hardware can handle. Give it a prompt like: "Inspect my computer's memory, GPU, and free disk space. Choose a tool-capable local model that fits comfortably, reuse one if I already have it, connect it through Ollama, and preserve my current cloud models and defaults." Codex downloads or reuses a matching model and wires it in. Restart the app and test it with a couple of throwaway chats before trusting it with real work.

Join Early AI-dopters, 1,300 people mastering Claude Code and Codex. Mark walks through his full model-routing setup inside the community.

Does Ollama Work With Codex CLI for Local Models?

Yes, but local models don't get the same one-click setup cloud models do. The "Add to Codex" plugin only wires in Ollama's cloud-hosted models out of the box. Running a model locally takes the hardware-inspection prompt above, since not every open-weight model can reliably call tools inside the Codex harness.

Once connected, nothing else about your workflow changes. You still invoke your existing slash commands and hold a normal conversation, just on a model that costs nothing per token instead of a metered one.

How Much Money Does Switching Models in Codex Actually Save?

Switching from Astra to a cheaper model for routine tasks can cut per-request cost by 10 to 20 times. GPT-6 Astra runs $10 per million input tokens and $50 per million output, while GLM 5.3 and its Flash variant run a fraction of that for comparable results.

GPT-6 AstraGLM 5.3 (cloud)Local model (Gemma, gpt-oss)
Input cost$10 / million tokens10 to 20x cheaper$0
Output cost$50 / million tokens10 to 20x cheaper$0
Best forNovel, deep agentic codingMid-tier SOP execution, filming guidesFree grunt work if hardware allows
SetupBuilt into CodexOne click in Ollama settingsOne prompt, needs local specs

That math extends to the cloud credits themselves. A $20 Ollama Cloud pack buys about $60 of usage, and running it through a fast, cheap model can stretch as far as another $100 to $200 spent staying on your normal Codex plan. As models like GLM 5.6 and DeepSeek 5 close the gap with frontier models, Mark expects open models to handle 80% of day-to-day knowledge work within a couple of months, as long as your agentic OS has the infrastructure to support it.

Building a Multi-Model Workflow in Codex

The real payoff shows up once you stop thinking "one model per project" and start routing tasks by tier. Mark's test case: research the best current hardware for running local models, like a Mac Studio or Mac Mini, and recommend a pick. He told Astra to spin up two threads, one on GLM to fetch the latest specs, one on a local Gemma 3 model to take those findings and build a shortlist.

Ten minutes later, GLM had pulled the Mac Studio and Mac Mini specs and handed them to the Gemma thread, which built a shortlist and passed it back to Astra, which turned it into a diagram explaining the recommendation. Only planning and final synthesis touched Astra. Everything in between ran on models that cost a fraction as much or nothing at all. This is the same layered thinking behind a good local AI setup: let the frontier model plan and finish, and push the middle steps down the cost ladder.

Final Thoughts from Mark

This isn't about ditching Astra, it's about being deliberate with where you spend it. Plan and finish with your best model, and let cheaper or free models carry the steps in between. Give it a month or two, and this routing habit will be worth even more than it is today.

Ollama Codex CLI FAQs

What is Ollama and how does it work with Codex CLI?

Ollama is a free app that runs open-weight models on your own computer or through its own cloud credits. Codex added it as a one-click provider under Settings, Apps, Add to Codex, so cloud-based Ollama models show up in the model picker immediately.

Do I need a powerful computer to run local models in Codex?

No, but the model has to fit your hardware and support tool calling. Tell Codex to inspect your memory, GPU, and free disk space, and it will pick or download a tool-capable model like Gemma 3 that fits comfortably.

Will switching models in Codex lose my conversation context?

No. Codex passes the same transcript and context window to whichever model you pick, so switching from Astra to GLM or a local model mid-project loses nothing.

Is Ollama Cloud free to use with Codex?

Local models on your own hardware run at no cost. Ollama Cloud's hosted models like GLM 5.3 are paid but cheap, with $20 of credit buying roughly $60 worth of usage.

Which local model should I use for tool calling in Codex?

Mark uses Gemma 3, but the right pick depends on your machine's specs. Ask Codex to inspect your hardware and choose a tool-capable model that leaves headroom for your other apps.

More detail lives in Ollama's own Codex integration guide, the official Ollama docs for Codex, and OpenAI's Codex documentation. If your team wants a full model-routing setup built for you, that's the kind of project we take on in enterprise AI consulting.

By Mark Kashef

All field notes