A language model will attempt almost anything you ask of it. Add up these invoices. Convert this date to UTC. Check whether this email address is valid. Sort these records by customer. It will usually get the answer right, and it feels like magic the first time it does.

But in the immortal words of Admiral Ackbar, it's a trap. The fact that a model can do a task does not make it the right tool for the task. A growing share of what I see teams send through AI inference is work that a few lines of ordinary code would do faster, cheaper, and identically every time. Inference is a remarkable tool for problems that need judgment about language. It is a poor substitute for code on problems that have a right answer.

Two different kinds of machine

Code is deterministic. Given the same input and the same environment, a function returns the same output every time, for as long as the code stays the same. You can test it and rely on the result. When it is wrong, it is wrong in the same way each time, and you can find the line that caused it.

Inference is probabilistic. A language model produces each word by sampling from a distribution of likely next words, so the same prompt can return two different answers, and Thinking Machines Lab found that language model APIs are not deterministic in practice even with the sampling temperature at zero. The same mechanism is why models make things up: a model produces the most plausible continuation of its input, not a checked answer, and when it lacks a fact it can supply a confident invention instead. Long inputs make it worse. Chroma's research on context rot found that models grow increasingly unreliable as the input gets longer, even on simple tasks, and long-running agents summarize their earlier context to make room, dropping details they may need later.

When code is wrong, there is a line to fix. When a model is wrong, there is only the next attempt. Everything below follows from that difference.

What people ask models to do that code does better

Some of the most common uses of inference I come across are tasks with a single correct answer:

  • Arithmetic and totals. Summing a column, calculating a tax, reconciling two numbers. Code does this exactly; a model approximates it in language.
  • Dates and times. Converting time zones, counting business days, finding the last day of a quarter. These are rules, and libraries already encode them.
  • Format conversion. Turning CSV into JSON, reshaping a spreadsheet, renaming fields. A parser does this without ever inventing a value.
  • Validation. Checking that an email address, an account number, or a postal code is well formed. A pattern or a checksum gives a yes or a no.
  • Lookups and matching. Finding a customer by ID, deduplicating records, joining two lists. A database does this in a single query.
  • Sorting, filtering, and counting. Ranking by date, keeping the rows over a threshold, counting how many of each. These are one line in most languages.
  • Routing on known rules. Sending a ticket to a team based on a product code or a keyword. If the rule can be written down, it should be.

Where inference earns its place is the work code cannot do well: understanding free text, classifying messages that do not follow a pattern, summarizing, drafting, pulling facts out of messy documents, and writing the code itself.

Slower and costlier on every call

Every call to a model pays again for work that code would do once. The bill comes in three forms.

Time. A typical function that validates a field or converts a date runs in well under a millisecond on an ordinary laptop. A call to a hosted model is measured in seconds: the request travels to a data center, waits for capacity, reads the whole prompt, and generates its answer a piece at a time. An agent that plans, calls tools, and checks its own work can take minutes. For one question from a person, seconds are fine. For a pipeline that handles every order, log line, or record in a nightly batch, it is the difference between a job that finishes before anyone notices and one that runs all night.

Money. Running a function again costs a negligible amount of compute. Every model call is billed by the amount of text the model reads and writes. Fractions of a cent per call look like nothing until they are multiplied by every record, every day, with the full context resent each time.

Effort. A prompt is cheap to start, since it takes minutes to write. But a prompt that does a code-shaped job well in a demo needs a lot of work to do it reliably in production: test sets to measure how often it is right, retries for when it is not, checks on the output's format and values (usually written in code, which raises the question of why the code is not doing the job), monitoring for drift when the provider updates the model, and a plan for the day the answer is wrong in a way nobody noticed. Code needs tests too, but its behavior does not change underneath you.

Not all compute belongs in a data center

Some of the loudest voices in AI describe a one-way future, in which software as we know it gives way to models and agents, and more and more of the world's computing runs as inference in large data centers. Microsoft's chief executive, Satya Nadella, has suggested that the "notion that business applications exist" could "collapse" in the age of AI agents, with agents taking over the business logic. It is an attractive pitch for the companies that sell inference. As a plan for everyone else, it does not add up, because inference depends on resources that are already scarce.

Power. Inference runs on accelerators in data centers, and data centers already draw a growing share of the grid. The U.S. Department of Energy reports that data centers used about 4.4% of U.S. electricity in 2023 and expects that share to reach 6.7 to 12% by 2028. Moving work that a phone could do in microseconds onto that grid adds load and buys nothing.

Water and land. Many large data centers use water for cooling, and every new campus needs land, transmission lines, and a community willing to host it. That willingness has limits: Data Center Watch found $64 billion of U.S. data center projects blocked or delayed by local opposition from both political parties. Its later reports put the figure well over $100 billion: $156 billion in 2025 alone, and about $130 billion in the first three months of 2026.

Chips. The accelerators that run large models come from a small number of designers and an even smaller number of advanced chip plants, and demand for them has outrun supply. Every task that occupies one of those chips without needing to takes capacity from work that does.

Commodity hardware. None of these constraints applies to code. It runs on the servers a company already owns, on a laptop, on the phone in your pocket, and a phone can validate, sort, convert, and calculate faster than a request can reach a data center and come back. Scaling a deterministic function means adding ordinary computers, not competing for the most contested hardware in the world. Even for the tasks that need a model, smaller models now run on ordinary laptops and phones.

Running locally. Work that runs where the data already is has no network round trip, no queue for shared capacity, no bill for each call, and no outage when the connection or the provider goes down.

Privacy and security. Sending a customer record, a contract, or a codebase to a hosted model means sending it to a third party: it crosses the network, it is processed on someone else's infrastructure under their retention terms, and it widens both your attack surface and the scope of your compliance obligations. Work that runs on your own hardware keeps that data inside the controls you already have. And a deterministic function does not take instructions from the data it processes, so there is no prompt for an attacker to inject.

The easy part is writing the code

The usual case for sending a task to a model is that it saves someone writing code. That argument is out of date. Writing the code is now the easy part, because the model can write it.

Ask a model to convert this spreadsheet, and it converts this spreadsheet, and you pay again for the next one, and the one after that. Ask it to write a function that converts spreadsheets like this one, and you pay once. The function then runs on every spreadsheet that follows, in milliseconds, on hardware you already have, for practically nothing, and gives the same answer each time.

That turns the economics around. The inference cost is spent once, at design time, where it buys something that lasts: code you can read, test, keep under version control, and review. The model's understanding of the problem stays in the system, captured in the code instead of being rebuilt, and billed, on every call. Generated code can also be read before it ever runs, and a test suite can confirm it does what you meant on every input you care about. A prompt running in production can only be checked after the fact, one answer at a time.

The same holds for agents. An agent that carries out a routine task step by step every day can instead write the script that carries it out, and hand the job to the script. Spend inference on the decisions that need judgment, including deciding what the code should do, and let code do the repetition.

Choosing the right tool

Before sending a task to a model, I ask a few questions:

  • Is there a single right answer? If yes, write code.
  • Can the rule be written down? If a person could follow it as a checklist, a program can too.
  • Will it run more than a handful of times? Then the cost and speed of each run matter more than the cost of writing it.
  • What happens when it is wrong? If a wrong answer is expensive or hard to detect, prefer the tool that is wrong in the same way every time.
  • Does the data need to leave your systems? If not, run the work locally, in code or with a model on your own hardware.

If the task needs judgment about language, inference is the right tool, and it is a good one. If it does not, the model's best contribution is helping you write the code. Just because a model can do the work does not mean it should.

This is the kind of design question our prototype to production work deals with every day. Talk to us if you are deciding where AI belongs in a product or a process.