Migrating Large Language Model APIs Across Versions: A Code Change Checklist and Three-Stage Acceptance Test
When you migrate a large language model (LLM) API from one version to the next, what actually changes is not just a model string but an entire request contract: what inputs the model accepts, how tools are exchanged, how reasoning budgets are expressed, which sampling fields are rejected, how prompt caching keys are computed, and where system instructions must sit to participate in cache reuse. This guide explains how to distinguish hard compatibility breaks from soft behavioral drift, provides a six-part checklist covering model identifiers, tool protocols, reasoning effort, sampling parameters, prompt caching, and system prompt placement, and describes a three-step acceptance process: contract verification, behavior regression, and production observation. It also covers release and rollback strategy, residual scanning, and common mistakes to avoid.
Migrating Large Language Model APIs Across Versions: A Code Change Checklist and Three-Stage Acceptance Test
When an LLM interface crosses a major version boundary, what callers really need to migrate is not a single string but an entire request contract: what the model accepts, how tools round-trip, how reasoning budgets are expressed, which sampling fields get rejected, how prompt caching keys take effect, and where system constraints must live to participate in cache reuse. A common shortcut—changing only the model name and passing everything else through unchanged—often results in some requests failing outright, or requests that appear to succeed while responses get shorter, tools stop firing, cache hit rates decline, and both latency and cost rise.
This article provides a practical checklist and a three-stage acceptance process, organized by how frequently each change is needed and how severe the failure is when it is missed. It is vendor-neutral and does not assume any particular model or provider.
First, Separate Hard Changes from Soft Changes
Hard changes are contract incompatibilities: field names, enum values, or invocation shapes change; old requests are rejected, or critical capabilities (especially tool calling) silently stop working. Soft changes are cases where requests still complete, but caching keys, instruction priority, or default reasoning depth shift, so quality, latency, and cost degrade quietly.
A migration plan should clear hard changes first to guarantee “it runs correctly,” then handle soft changes to ensure “it runs stably and affordably.” Both types must be included in regression testing—checking that HTTP responses return 200 is not enough.
Keep two concerns separate in your code: model routing and request assembly. Routing only decides which capability tier to use; the assembly layer builds requests according to the target contract and must not blindly merge optional fields from an old client into a new request. This way, an upgrade changes one assembler rather than requiring you to hunt through a dozen call sites for stray dictionaries.
Six Categories of Code Changes
1. Model Identifier
The model identifier is a routing key, and often also the boundary for billing, rate limits, context length, and tool capabilities. During a version migration, every explicit string must be updated together: configuration centers, canary/gray-release lists, evaluation scripts, and default values in asynchronous jobs.
The locations most commonly missed are not the main conversation endpoint but rather: batch processing jobs, side calls such as title/summary generation, fallbacks to an old identifier during retries, and expected model names hard-coded in test fixtures.
The impact of missing this is immediate: after the old identifier is retired, requests fail. If the old identifier remains available but has a different capability set, you get “the main path is upgraded while side paths still use old behavior,” which is very hard to reconcile in production.
In practice, use a configuration enum instead of scattered strings, and perform an existence check against the gateway or model catalog at startup; reject unknown identifiers immediately rather than letting them fail at request time.
2. Tool Calling Protocol
Many teams treat “the model can call functions” as a stable capability, but the protocol shape can change. Some interfaces put tool definitions, invocation fragments, and final answers in the same message stream; newer response-oriented interfaces separate tool definitions, invocation items, tool results, and subsequent inputs into distinct structures. If you change only the model and not the parser, the server may ignore tools and the model degrades to plain text generation. Meanwhile, your business code still looks for tool names and arguments in the old structure, resulting in silent no-ops or a false conclusion that “the model didn’t call anything.”
Three places must be updated together:
- How tool schemas are submitted;
- How invocation items in model output are read;
- How tool results are wrapped and sent back in the next turn.
Parsing must be based on explicit fields, never on guessing at some natural-language format. Multi-tool parallelism, retry-on-tool-failure, and the switch meaning “tools are not allowed this turn” all need their semantics redefined under the new protocol.
For acceptance, prepare four kinds of samples: one that should call a tool, one that should not, one with missing arguments, and one where the tool returns an error. Verify the control flow, not just the final sentence.
3. Reasoning Effort / Thinking Budget
Models with reasoning tiers typically express thinking depth with discrete levels, not by using temperature to “tune intelligence.” Old enums (for example, one representing “off” or minimal effort) may be removed or renamed in a new version; if a new integration keeps the old default, requests fail at validation time. The more insidious problem: when the default level becomes higher, simple classification and extraction tasks go through heavy reasoning, increasing latency and cost—and timeout-driven retries amplify the load.
The principle is to assign tiers per task, not to max everything globally:
- Retrieval rewriting, format validation, and short classification: low tier.
- Multi-step planning, complex code, or long tool chains: medium tier.
- High tier only when evaluation clearly demonstrates benefit.
Write the tier into per-scenario configuration and log the value actually in effect. If the interface no longer accepts an old enum, the mapping table should fail explicitly rather than silently fall back to an unknown default.
4. Sampling Parameters
Temperature, top-p, log probabilities, and similar fields are commonly used in pure generative chat to control randomness and obtain candidate scores. In newer reasoning- or tool-first contracts, they may be explicitly rejected—or silently ignored while still changing the cache key. If you don’t remove them or disable them per the new contract, the failure ranges from request errors to losing prefix cache reuse because of one extraneous field.
Use an allowlist of accepted fields, not a blacklist that removes two known parameters. Old clients often attach frequency penalties, presence penalties, log-probability switches, and similar flags; an allowlist blocks all of them at the source.
Where diversity is needed, prefer mechanisms the interface still supports (for example, candidate count or an explicit random seed strategy), and document clearly that reasoning tier and sampling cannot substitute for each other. If log probabilities are used for rejection or reranking, confirm in advance that the new model still provides an equivalent signal; otherwise switch to rule-based validation, tool callbacks, or a separate scoring call before launch, so scores don’t suddenly come back empty.
5. Prompt Caching Configuration
Caching is the soft change most likely to look fine while being broken. If an old field is ignored, requests still succeed, but the prefix is no longer reused—first-token latency and input token costs both rise. New contracts often move retention duration and cache mode into nested options rather than a single top-level field. Duration enums, units, and default policies can all change, for example from “default session caching” to “you must explicitly provide a time-to-live.”
When adapting, confirm three things:
- Whether caching is disabled by default;
- Whether the time unit is still the same order of magnitude;
- Whether the cache key includes the model identifier, tool definitions, and system prompt.
Any instability in those components (timestamps, random numbers, user nicknames embedded in the system prompt) will crush the hit rate. Log cache hits and misses and aggregate by scenario, rather than only looking at total cost. When misses spike, first compare request prefixes byte-for-byte, then check whether the config field is still in its old location.
6. System Prompt Placement
Whether system-level constraints live in a top-level instruction or in a developer message at the start of the input sequence affects two things: instruction priority, and whether that text participates in the reusable prefix. If the placement is wrong, the model still answers—but business rules get overridden by user content, or every request treats the long instruction as a new prefix and the cache hit rate collapses.
Rules of thumb:
- Put stable prefixes at the front and keep them byte-for-byte identical across requests.
- Put user data, dates, and document numbers after the prefix.
- If tool definitions participate in the cache key, version them and avoid dynamically concatenating different descriptions.
- In multi-tenant scenarios, separate tenant-invariant policy from tenant-specific material: the former goes into the cacheable prefix, the latter into the per-request input.
After migration, issue dozens of consecutive requests with the same long system prompt and compare hit rate and time-to-first-token. That is far more reliable than eyeballing whether the answers “sound fine.”
Example: What Request Assembly Should Look Like
The following describes structure only; it is not any specific provider’s interface. The old path typically puts model, sampling, tools, and system prompt on the same level. The new path should layer them according to the contract and drop unknown fields before sending:
AssembleRequest(scene):model = scene.model_id # provided centrally by configreasoning_level = scene.reasoning_level # low / medium / high; fail if mapping failstools = WrapToolsForNewProtocol(scene.toolset)input = [developer_message(stable_system_prompt), user_and_context...]cache = { ttl: scene.cache_duration } # only when the contract requires explicit configremove sampling fields, old level enums, old cache fieldsreturn a request containing only allowlisted fields
Parse responses in layers as well: first check whether there are tool invocation items; if so, execute them and append the results according to the new protocol; otherwise read the final text. Never use regex on natural-language text to “guess” tool calls.
Three-Stage Acceptance Testing
Stage 1: Contract verification. Send a minimal request to the target version: only the model plus one user message. Then add, one at a time, reasoning effort, tools, cache options, and the developer message. Record whether each addition is accepted or rejected. Turn the error codes into a “field—reason—handling” table and write it into assembler unit tests. The pass criteria for this stage: invalid enums and invalid sampling values must fail, valid minimal requests must succeed, and tool round-trips must close the loop.
Stage 2: Behavior regression. Prepare a fixed sample set covering factual Q&A, format constraints, should-call-tools, should-not-call-tools, very long system prompts, and multi-turn follow-ups. Compare structured results between old and new versions—not a vague judgment of whether the answers “look similar.” For tool scenarios, assert on tool names, argument completeness, and retry-on-failure; for format scenarios, assert that output is parseable. Writing style differences are acceptable; unowned differences in control flow are not. Run each reasoning tier, and verify the low tier hasn’t quietly become high.
Stage 3: Production observation. Gradual rollout by scenario, not a random 50/50 user split: first release traffic that is latency-insensitive and replayable. Watch four curves:
- Error rate (with validation failures broken out separately);
- Tool invocation rate;
- Cache hit rate;
- Input/output token counts per request and tail latency.
Soft-change failures often show up as declining hit rates and rising costs, not as errors. Define rollback thresholds—for example, if the tool invocation rate drops beyond an agreed proportion relative to baseline, or cache hit rate falls below the scenario floor, switch back to the old assembly. Make the observation window longer than the cache TTL, or you’ll mistake cold starts for configuration errors.
Release and Rollback
Keep both the old and new assemblies in the configuration center and switch between them with a per-scenario toggle, so you can roll back without redeploying. Roll out batch and online services separately; batch jobs can amplify both caching and cost problems. Document, for every scenario, the model identifier, reasoning tier, whether tools are allowed, cache duration, and system prompt version number. Put prompts themselves under version control: changing even one character counts as a prefix change and should be expected to temporarily reduce hit rates.
After migration, run a residual scan: no retired model identifiers, deleted tier enums, or deprecated cache field names should remain in the repository or configuration. Generate scan rules from the current allowlist so the next upgrade doesn’t depend on manual searching.
Common Mistakes
- Treating soft changes as optional and monitoring only error rates after launch—then discovering cache invalidation when the bill arrives.
- Changing only the request side of the tool protocol but not the parser; the model returns invocation items, but the business cannot read them.
- Raising the reasoning tier globally and using quality gains to mask latency regression.
- Leaving sampling fields in a shared client: some models error, others include the field in the cache key.
- Concatenating the current time into the system prompt on every request, making prefix reuse impossible.
- Acceptance samples containing only “Hello”—failing to cover tools and long prefixes.
Conclusion
Put all six changes into one list: what to change, whether the impact is failure or degradation, which assembler function owns it, and which sample validates it. Do not release if hard changes fail; do not release without hit-rate and cost baselines for soft changes either. Done this way, a version migration becomes a repeatable engineering change, not a lucky gamble with a renamed model.
