The cover image of my last post was generated by Claude, from the same session that wrote the pull request. So was the one at the top of this page.

The part I care about is a small moment in the middle. Claude asked for the image on my own GPU, which is free. My machine wasn’t set up for it that morning, and the answer it got back ended with this sentence:

To run it in the cloud instead (paid), retry with run_on: ‘cloud’.

Claude didn’t switch to the cloud on its own. It told me, and stopped. I typed “use the cloud”, and got one image for 5 credits. Half a cent.

Half a cent is not the point. The point is that at no moment did an agent decide, on my behalf, that my money was a reasonable fallback. That sentence in the error message is there on purpose, and most of this post is about why.

The rule everything else comes from

Imference MCP is the open-source server that lets an agent (Claude Code, Claude Desktop, Cursor, anything that speaks MCP) generate images and videos through Imference. Since v0.5.0 it can also drive Imference Desktop, which means the agent generates on your own GPU, for free, with the models you already downloaded.

Free local, paid cloud, and a default mode called auto that picks between them. You can see the trap from here. The helpful thing to do when local fails is to try the cloud. It is also exactly how you end up with a bill for forty images you thought were free, because your GPU driver had a bad day and your agent was in a loop.

So the rule is: a local failure is an error, never a paid retry. The agent gets the failure, the reason, and the sentence above telling it what the paid option is. A human decides.

The same idea shows up everywhere else in the design:

  • The agent never downloads a model. Models are several GB. If the one it wants isn’t on disk, it gets model_not_cached and has to ask you. An agent that fills your drive to be helpful isn’t being helpful.
  • Spending is off by default. Desktop can lend its account to the agent for cloud runs, behind a switch called Let AI agents spend my credits. It ships off.
  • The key stays in Desktop. The MCP server asks Desktop for it before each call. It is never written into the agent’s config file, and flipping the switch off takes effect at once.
  • Every result says where it ran. Your GPU and free, or the cloud and paid, with the credits spent. The tool description asks the agent to tell you.

One honest nuance: the small editing tools (upscale, remove background and friends) do retry in the cloud under auto, for three specific failures like running out of VRAM, and the result says so in plain words. A one-credit crop is a different risk than a batch of generations. Where exactly that line belongs is a judgment call.

The 60-second wall

MCP clients like Claude Desktop give up on a tool call after about 60 seconds. The call doesn’t fail on your side. The client just stops listening. Meanwhile your GPU is happily finishing an image nobody will ever collect.

My default wait was 120 seconds. So a generation that took between one and two minutes could look, from the agent’s side, like the tool had crashed. And what does a reasonable agent do when a tool crashes? It calls it again.

The default is now 50 seconds. A run that is still going at that point returns pending with an id, and check_status picks up the same run. It is never started twice. This applies to local runs and cloud ones.

My cover image went through exactly this path: pending after 50 seconds, a few polls, then done. It works with every client that exists today, and the agent never has to guess whether its image is lost.

The tool description is the UI

When a person uses an app, you guide them with layout, disabled buttons and confirmation dialogs. An agent sees none of that. It reads a paragraph of text per tool and a list of parameters, and that’s your entire interface.

A few things I ended up doing because of it:

No width and height. The agent picks a format_code such as landscape-wide, and the API turns it into dimensions. The format carries the price multiplier, so there is no way to invent a resolution that costs ten times what the user expected.

LoRAs are opt-in, in writing. A LoRA can completely change an image, and some are deliberately lo-fi. Left alone, an agent adds one to “improve” things. The description now says, in capitals, to omit them unless the user asked, and to suggest rather than apply. It reads like a note taped to a fridge. It works.

The agent sees its own output. Finished images are embedded in the tool result, so the model can look at what it made and fix its prompt. Without that, it’s describing a picture it has never seen.

Wrong parameters fail before anything is paid. Values are validated locally with the same rules as the engine. A typo costs nothing.

When the agent holds an actual wallet

There is a second way to pay: per generation, in USDC, signed from a wallet with x402. No account, no key. Which also means a process with signing power over real money, taking instructions from a language model.

The client is deliberately narrow-minded. It signs exact USDC on Base mainnet and nothing else. Another network, another token, an amount above the catalog price of the request plus one cent of headroom: refused before anything is signed. There is a hard cap per payment, enforced by the server process itself whatever the model asks for. I would rather explain a refused payment than an unexpected one.

And one bug I’m glad I caught. For a while there was a tool to top up credits from the wallet. When the key came from Desktop instead of the config, that tool didn’t top up your account. It quietly created a brand new one and put the money there. I fixed it, and removed the tool entirely the same day, because credit packs moved to card and crypto checkout on the site. The fix lived for less than a day. I still think it was worth writing the test.

What I’d keep from all this

Giving an agent a tool that costs money is not mainly a protocol problem. Most of the work was answering one question over and over: when something goes wrong, who finds out, and who decides what happens next?

Every time the answer was “the agent decides, quietly”, I ended up changing it.

To try it: claude mcp add imference -- npx -y imference-mcp, or let Imference Desktop set it up from Settings › AI agents.