The Claude Code Changelog
All Episodes
Optimizing Claude API Latency with Claude Code 2.1.319

Optimizing Claude API Latency with Claude Code 2.1.319

0:00|0:00

Explore the new /claude-api latency-optimize command in Claude Code 2.1.319, which tests faster API settings against your evals to reduce latency bottlenecks.


Chapter 1

Tuning Claude API Latency with latency-optimize

Lachlan Reed

Today's episode is brought to you by Jellypod AI. And we've got a handy one from version 2.1.319, which landed November 6, 2026. It's a new command: slash claude-api latency-optimize.If your app calls the Claude API and people sit there waiting, this is for you.

James Turner

The changelog line says it finds where your Claude API code makes people wait, and tries faster settings against your eval. So it's an interactive skill. It reads the code that makes your requests, spots the bottlenecks, then runs candidate configurations against your own eval suite. That last part matters, because most teams tune latency by gut feel.

Lachlan Reed

Guilty. I've nudged a setting, watched one request feel quicker, and called it done. The thing is, latency isn't one number. There's time to first token, time to last token, and output tokens per second. A voice bot cares about the first. A job that summarises a financial document cares about the last. So you need to know which one hurts.

James Turner

Right, and each has its own levers. Prompt caching, so you're not reprocessing the same system prompt every call. Effort levels, low, medium, high. Thinking budgets, or adaptive thinking. Fast mode on supported models. And shorter outputs, like structured outputs instead of chatty prose. The command's job is checking those against your code, not guessing.

Lachlan Reed

So how do you actually use it? You open a terminal in the repo where your Anthropic SDK code lives, Python or TypeScript, and where your evals live too. Then you just run slash claude-api latency-optimize. It looks at where requests pay the first token and last token penalties. It checks whether your prompts actually hit the cache. It checks whether effort is set too high for routine tasks, and whether thinking tokens can be trimmed.

James Turner

Then it tries things. Drop effort from high to low. Try a smaller model for the easy path. Turn on fast mode. And it compares results against your eval, looking at p50, the median, and p90, the tail. That tail is what users actually complain about, so I'd read p90 first.

Lachlan Reed

Picture a fraud screening call that's set to high effort by default. If low effort passes your eval at the same quality bar, and the p90 drops, that's a free win. If it fails, you've learned that cheaply, before production did.

James Turner

Now, caveats. First, cost. Sweeping across several models and settings burns API credits. So keep your eval sample representative but bounded before you kick off a big run. Second, quality. Lowering effort or switching off thinking can hurt reasoning on edge cases. If your eval is vague, a faster config can look fine and still regress. You want rigid assertions, real oracles.

Lachlan Reed

And third, the tool tunes API levers and loop efficiency. It can't fix everything. Tool lookups, a slow gateway hop, or plain network jitter can still dominate wall clock time. So measure end to end as well.

James Turner

A few smaller things in 2.1.319 worth a mention. Slash tasks now has an Earlier in this session row listing finished subagents, so you can reopen one and message it, even after a restart. There's a new environment variable, CLAUDE_CODE_DISABLE_FEATURE_FLAGS, that stops feature flag fetching without turning off telemetry, so every flag uses its built in default.

Lachlan Reed

And the third one's a nice fix: slash commands with leading whitespace, tabs, or newlines were going to the model as plain text instead of running. That one's bitten me. So, update, run claude dash dash version to check, and point the new command at your slowest endpoint first.