Cheaper AI coding with OpenCode, DeepSeek and GLM

A practical guide for Claude Code users: install OpenCode, connect DeepSeek V4.1 Flash or GLM 5.3 Flash through OpenRouter, and spend less on AI coding.

If you’re using Claude Code, you already know how useful it is. You open your project, ask for a change, and it gets on with reading files, editing code and running commands. Once you get used to working that way, it’s hard to go back.

But the cost can add up. And if you’re hitting usage limits, paying for a bigger plan might feel like the obvious next step.

I’d suggest trying OpenCode first. You get a similar way of working, with the freedom to choose which model you use. I’ll walk you through setting it up with DeepSeek V4.1 Flash and GLM 5.3 Flash through OpenRouter. I’ll also cover the other ways you can get access to them.

I’m focusing on these two because they’re cheap and popular right now. OpenRouter’s discovery page shows roughly 18 trillion tokens of usage for each in its weekly snapshot. You don’t have to stick with them, though. Being able to change models is a big part of the appeal.

The prices below are in USD, checked on 27 September 2026. They’ll change, so I’ve linked the pricing pages as we go.

Where OpenCode and OpenRouter fit in↗

The names can get confusing at first. Here’s what each one does:

PieceWhat it doesWhat we’ll use
Coding agentWorks in your project and gives the model toolsOpenCode
ModelReasons about the task and decides what to doDeepSeek V4.1 Flash or GLM 5.3 Flash
ProviderServes the model and bills for usageOpenRouter

OpenCode itself is free and open source. You choose how to pay for the model you connect to it. It supports dozens of providers, custom compatible endpoints and even local models, so you can use whichever supported model suits you. That includes Claude. For coding, you’ll want one that’s good at using tools to work with your files and run commands. The model docs explain the options.

OpenRouter lets you access models from different companies through one account and API key. You add credit, then spend it on whichever models you use. So you can try both DeepSeek and GLM without opening separate billing accounts. There’s more detail in OpenRouter’s billing FAQ.

This is the option I personally prefer. I add a small amount of credit and use it as I need it. These two models use so little of the balance that a small top-up lasts me a long time.

How much cheaper can this be?↗

In my own work, I’ve found that a task I’d expect to cost around $200 in Claude Code can cost just $5 to $10 with these models through OpenRouter. That’s the kind of difference that made me want to write this post. It’s my experience with my own tasks, so I wouldn’t promise the same savings for everyone.

It’s also worth separating that comparison from subscription pricing. Claude Pro costs $20 a month when billed monthly, and Max has $100 and $200 tiers. Those plans cover an allowance of usage across tasks, along with other Claude features. If you’re getting a lot out of your subscription, it might still make sense to keep it.

OpenRouter charges by the token. Think of tokens as the pieces of text the model reads and generates. Your code, instructions and conversation history count as input. Its responses and any billable reasoning count as output. A task usually involves several requests as the agent reads files and works through changes.

Here are the advertised OpenRouter prices per million tokens:

ModelInputOutputOpenRouter model ID
DeepSeek V4.1 Flash$0.035$0.29deepseek/deepseek-v4.1-flash
GLM 5.3 Flash$0.045$0.14z-ai/glm-5.3-flash

At those rates, 10 million uncached input tokens and 1 million output tokens would cost $0.64 with DeepSeek or $0.59 with GLM, before fees and taxes. That’s an example to show the scale of the pricing, rather than an estimate of your monthly bill.

The actual price depends on which provider serves your requests and any promotions running at the time. GLM’s listed rate is currently discounted. OpenRouter also charges a fee when you buy credits. Long conversations and repeated attempts use more tokens, while caching can bring the cost down. Check the linked model pages for the rates you’ll be paying.

I’d try both on a few tasks you know well. Did the change work? How much did you have to fix? What did it cost? Those answers will tell you more than the price table alone.

1. Install OpenCode↗

On macOS or Linux, run:

curl -fsSL https://opencode.ai/install | bash

Or, if you already have Node.js and npm installed, use:

npm install -g opencode-ai

You only need one of those commands. If you’re on Windows, OpenCode recommends WSL. Run the Linux command in your WSL terminal, or check the installation docs for native Windows options.

Once it’s installed, go to your project folder and start OpenCode:

cd /path/to/your/project
opencode

Use your own project path there. If you get a command-not-found error, try reopening your terminal so it picks up the updated PATH.

2. Add OpenRouter credit and connect it↗

Head over to OpenRouter and create an account. Add a small balance on the credits page, then create a key on the API keys page.

I’d name the key opencode and give it a spending limit. Leave automatic top-ups off for now, so you can see how far your first balance takes you.

Inside OpenCode, type:

/connect

Search for OpenRouter, select it and paste your key when it asks. Keep that key private. Anyone with it can use your account’s credit, so don’t put it in your code or paste it into a chat.

Then type:

/models

Pick DeepSeek V4.1 Flash or GLM 5.3 Flash under OpenRouter. Check that you’re choosing the OpenRouter version, because the same model can appear under different providers with separate billing.

You type both of those slash commands into OpenCode itself. If you want to follow along with the official instructions, here’s OpenRouter’s OpenCode guide.

3. Save your preferred model↗

You can skip this step if you’re happy choosing from the model picker. But if you want OpenCode to start with your preferred model, add an opencode.json file to your project root.

This sets DeepSeek as your default. You can still switch to other models with /models. If you already have the file, merge these settings into it:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "openrouter/deepseek/deepseek-v4.1-flash"
}

To default to GLM, change the model value to:

"openrouter/z-ai/glm-5.3-flash"

The first openrouter/ tells OpenCode which provider to use. Everything after it is the model’s ID on OpenRouter.

Want the same default in all your projects? Put it in ~/.config/opencode/opencode.json instead. A project’s own settings take priority where they overlap. Your API key stays separate, stored through /connect.

Restart OpenCode and check /models once you’ve saved the file. The config docs and OpenRouter guide cover this in more detail.

4. Give it a real coding task↗

Now give it something small to do. Pick a part of your project you understand, so you can tell whether it’s doing a good job. For example:

Find the code responsible for validating the signup form. Explain how it
works and propose a change that rejects whitespace-only names. Don't edit
anything yet.

Press Tab to choose Plan mode before sending that prompt. Talk through the approach, then switch to Build mode when you’re happy with it. You could follow up with:

Implement the whitespace-only name check using the existing validation
pattern. Add an appropriate regression test, run the relevant checks,
and explain the changes.

Then check the diff and the test results, just as you would with Claude Code. You can point it at particular files using @ too. The getting-started guide explains how that works.

If your project already has a CLAUDE.md, you can keep using it. OpenCode reads it when there’s no AGENTS.md. If you have both, it uses AGENTS.md. And if you have neither, /init can create an AGENTS.md for you to review. Other Claude Code settings and integrations may need separate setup, but you don’t have to rewrite your project instructions just to try this. Here’s the documentation on project rules.

After a few tasks, open OpenRouter Activity and see what you’ve spent. Then use /models to try the other model on a similar task. You might prefer one, or find that each works better for different jobs.

Other ways to connect these models↗

I prefer OpenRouter, but you have other options. You can connect directly to the companies making these models, or use OpenCode’s own services. You still work in OpenCode either way.

Directly through DeepSeek↗

Create an API account and key at the DeepSeek console, fund the account, then use /connect and choose DeepSeek. Select its Flash model through /models.

There’s one naming detail to watch here. DeepSeek calls V4.1 Flash deepseek-flash on its own API. OpenRouter calls it deepseek/deepseek-v4.1-flash, so don’t copy that ID across unchanged.

DeepSeek also charges different rates for cached input and for peak and off-peak hours. Check its model and pricing table when you’re comparing costs.

Directly through Z.ai↗

For GLM, create a key through Z.ai and select Z.AI in /connect for standard API access. If you’ve bought a GLM Coding Plan, select Z.AI Coding Plan instead, then use /models to choose an included model.

Make sure you choose the connection that matches what you’ve paid for. The Coding Plan and the regular API balance are separate products. Before subscribing, check that the plan includes GLM 5.3 Flash and that its usage limits suit you. Z.ai has its own OpenCode setup guide.

OpenCode Go and Zen↗

If you’d rather have a subscription, OpenCode Go currently costs $10 a month and includes both DeepSeek V4.1 Flash and GLM 5.3 Flash. Subscribe through your OpenCode account, copy your key and choose OpenCode Go in /connect. Then pick a model with /models.

Go has five-hour, weekly and monthly limits, and the allowance depends on the model. You can also enable a setting that spends your Zen balance once your allowance runs out. Check the Go plan and limits so you know what you’re getting.

Zen is OpenCode’s pay-as-you-go option. You fund a balance, choose OpenCode Zen in /connect and enter its key. The Zen docs list the available models and prices. Both services are optional. You can use OpenCode without paying OpenCode for model access.

You can connect other hosts, such as Together AI and Deep Infra, or a local model server as well. The provider directory is the place to look. For local models, what you can run will depend on your hardware.

If the first connection doesn’t work↗

SymptomWhat to check
Authentication errorRun /connect again and use the key from the selected provider. An OpenRouter key won’t authenticate directly with DeepSeek.
Model missing from the pickerRestart OpenCode. If it’s still missing, use the fallback below.
Model not foundCopy the exact model ID from its provider page. The top-level OpenCode model setting also needs the provider prefix.
Credit or quota errorCheck the balance, key spending limit or subscription allowance for the provider you selected.
Repeated rate limitsCheck provider status and retry later, or select another connected provider.

If either model is missing from the picker, merge this extra block into your opencode.json, then restart OpenCode. It adds the entries alongside the existing catalogue, so your other models stay available:

{
  "provider": {
    "openrouter": {
      "models": {
        "deepseek/deepseek-v4.1-flash": {},
        "z-ai/glm-5.3-flash": {}
      }
    }
  }
}

There’s more help with connection and model-list issues in the OpenRouter setup guide.

I’d start small. Add a little credit, pick a model and try it on something you were going to ask Claude Code to do. If you’re happy with the result, try a few more tasks. You can work out where it fits without changing everything at once.

And whichever model you end up using, whether it’s Claude, DeepSeek or GLM, the model is only part of it. How you set up your coding agent matters a lot. People often call that setup the harness. Giving it useful project instructions, the right context and tools, and a way to check its own changes can make a big difference to what you get back.

I’ll cover more of that in upcoming posts. Follow Not Just Coding on our social media pages for more practical ways to get better results from AI coding.