Moving an LLM application to a new provider is more than replacing an API key. This guide provides a reusable LLM API migration checklist for comparing capabilities, preserving prompt behavior, testing structured outputs and tool calls, managing operational settings, and completing a controlled production cutover with a rollback plan.
Overview
An LLM API migration can affect every layer of an AI application: request construction, authentication, model selection, context handling, streaming, safety controls, observability, billing, and the user experience. A provider may support the same broad features as the current service while exposing them through different parameter names, message formats, SDK abstractions, or failure modes.
Start by treating the migration as a behavior-preservation project rather than a simple integration change. The goal is not necessarily to make every request identical. The goal is to preserve the outcomes your application depends on while documenting intentional differences.
Keep a written migration inventory with four columns: current behavior, target behavior, compatibility risk, and verification method. This makes hidden dependencies visible before they become production defects.
Migration inventory worksheet
- Application paths: List every feature that calls an LLM, including background jobs, admin tools, internal scripts, and fallback routes.
- Models: Record the current model identifier, intended replacement, context assumptions, output limits, and any model-specific prompt instructions.
- Request formats: Capture system, developer, user, and assistant messages; multimodal inputs; metadata; temperature or sampling controls; stop conditions; and response-format settings.
- Response dependencies: Document plain text, JSON, citations, tool calls, finish reasons, usage fields, streaming events, and error objects consumed by your code.
- Operational requirements: Record timeout values, retry behavior, rate-limit handling, concurrency limits, logging, redaction, data residency assumptions, and budget controls.
- User-visible behavior: Note latency expectations, formatting, refusal handling, partial responses, conversation memory, and how errors are presented.
For related implementation details, use the production LLM API integration checklist alongside this migration plan.
Checklist by scenario
Scenario 1: Switching providers while keeping the same application behavior
- Create a provider adapter instead of scattering target-provider changes throughout business logic. Expose application-level methods such as
generateText,generateStructured, andrunToolLoop. - Move credentials, base URLs, model identifiers, and provider-specific defaults into configuration. Do not hard-code them in prompt or feature code.
- Translate requests at the adapter boundary. Keep your canonical internal representation separate from any provider-specific message or tool schema.
- Normalize responses into a stable internal format containing text, structured data, tool calls, finish status, usage where available, request ID, and error category.
- Run the same test corpus against both providers and compare task success, schema validity, refusals, latency bands, token usage, and user-visible formatting.
- Launch behind a feature flag or traffic split. Keep the original provider available until the target has passed production verification.
Scenario 2: Replacing a model within the same provider
A model replacement may look simpler, but it can still change instruction following, context tolerance, output style, tool selection, and cost behavior. Re-run prompt and application tests rather than assuming provider compatibility guarantees behavioral equivalence.
- Check whether the replacement supports every input and output mode your application uses.
- Review context and output-limit assumptions in code, prompts, and truncation logic.
- Test long conversations and retrieved context, not only short examples.
- Revisit few-shot examples, system instructions, and formatting constraints if the new model responds differently.
- Compare quality on difficult and ambiguous cases, not just average or obvious requests.
If prompts are shared across features, maintain them as versioned templates. The prompt template library for developers offers useful patterns for separating reusable instructions from application data.
Scenario 3: Migrating structured output and JSON workflows
- Define the canonical schema independently of the provider. Include required fields, allowed values, null behavior, and validation rules.
- Determine how the target handles schema declaration, constrained output, malformed JSON, extra properties, and empty responses.
- Validate every response at the application boundary. Never treat a successful HTTP response as proof that the payload is usable.
- Use bounded repair or retry logic only when it is safe and observable. Preserve the original response for debugging without exposing sensitive content in logs.
- Test missing fields, wrong types, invalid enum values, nested objects, Unicode, long strings, and provider refusals.
See Structured Output With LLMs for a deeper approach to schemas, validation, retries, and error handling.
Scenario 4: Migrating streaming responses
- Map the target provider's event sequence into your application's internal stream events.
- Test text deltas, empty events, final messages, usage events, tool-call fragments, cancellation, and connection loss.
- Ensure the client can distinguish an incomplete stream from a complete response.
- Decide whether partial output should be displayed, stored, retried, or discarded after an interruption.
- Verify that moderation, redaction, and logging do not behave differently when content arrives incrementally.
Scenario 5: Migrating tool calls or agent workflows
Tool calling combines model behavior with application execution, so small format differences can have large effects. Compare tool names, argument schemas, parallel-call support, call identifiers, ordering, and how tool results are returned to the model.
- Validate tool arguments before execution.
- Apply authorization and idempotency checks outside the model.
- Test duplicate calls, invalid arguments, missing tools, tool timeouts, and partial agent runs.
- Record the model decision, selected tool, validated arguments, execution result, and final response as separate observability events.
For more complex sequences, compare the migration against the patterns in Prompt Chaining vs. Single Prompts.
What to double-check
Feature-compatibility comparison
| Capability | Questions to answer before cutover | Verification |
|---|---|---|
| Authentication | How are credentials supplied, rotated, scoped, and selected by environment? | Test startup, rotation, invalid credentials, and secret redaction. |
| Messages | Are roles, content parts, images, files, and metadata represented equivalently? | Replay representative single-turn and multi-turn requests. |
| Context | What assumptions does the application make about input and output limits? | Test near-limit prompts, truncation, and retrieved documents. |
| Structured output | Can the target enforce or reliably produce the required schema? | Validate both normal and deliberately malformed cases. |
| Tool calls | Are tool schemas, arguments, parallel calls, and results mapped correctly? | Run success, refusal, timeout, duplicate, and invalid-argument tests. |
| Streaming | How are deltas, final events, errors, and cancellation represented? | Test slow connections, disconnects, and incomplete output. |
| Usage | Which usage fields are available and how will they map to internal accounting? | Compare recorded usage with request-level logs where available. |
| Errors | Can rate limits, timeouts, validation errors, and provider failures be classified? | Inject representative failures and verify retry decisions. |
Request and response test matrix
Build a matrix that crosses application scenarios with technical conditions. At minimum, include a normal request, a long request, an empty or ambiguous request, a refusal-sensitive request, malformed structured output, a tool failure, a timeout, a rate-limit response, a stream interruption, and a provider-unavailable condition.
For each test, record whether the request was accepted, whether the output met the contract, whether the application recovered safely, and whether the user-visible result remained acceptable. A prompt testing framework should evaluate more than wording quality: include factuality where relevant, schema validity, safety, consistency, latency, and cost signals. The prompt testing framework guide provides a practical evaluation structure.
Configuration and operations
- Use separate credentials and configuration for development, staging, and production.
- Set explicit connect, read, and total request timeouts.
- Define retry rules by error category. Avoid retrying validation failures or non-idempotent tool actions without safeguards.
- Preserve correlation IDs across your application, provider adapter, tool execution, and user request.
- Redact prompts, responses, credentials, and retrieved content according to your data-handling requirements.
- Update dashboards and alerts so they distinguish provider failures from application failures.
- Recalculate budget thresholds and routing rules using the target provider's observed usage rather than assumptions.
Review the LLM API cost optimization guide when changing token accounting, caching, routing, or budget controls.
Common mistakes
- Changing the provider and prompt at the same time: This makes regressions difficult to attribute. First preserve the prompt where practical, then make intentional prompt improvements as a separate change.
- Testing only successful text responses: Production workflows also depend on streaming, errors, structured data, tools, retries, and cancellation.
- Trusting identical parameter names: Similar names may have different meanings, defaults, limits, or supported values. Verify behavior rather than copying settings blindly.
- Letting provider-specific objects leak into business logic: This increases future migration cost. Normalize requests and responses at one boundary.
- Ignoring fallback behavior: Decide what happens when the target is unavailable, slow, over quota, or returns an unusable response.
- Comparing outputs manually only: Human review is valuable, but repeatable test cases, validators, logs, and acceptance thresholds are needed for ongoing confidence.
- Cutting over without a rollback path: Keep the previous configuration deployable, preserve compatible data contracts, and define who can reverse the change.
When to revisit
Revisit this checklist before each provider migration, model replacement, contract renegotiation, regional deployment, or major prompt change. It is also worth reviewing before seasonal planning cycles when traffic, staffing, or budget assumptions may change.
Update the compatibility table and test matrix when either provider changes model names, authentication methods, context limits, output controls, streaming events, tool support, usage reporting, SDK behavior, or deprecation guidance. Do not rely on an old migration document if the application has gained new features such as RAG, multimodal input, agent loops, or background automation.
Production cutover sequence
- Freeze and version the current configuration, prompts, schemas, adapters, and test corpus.
- Run the full request and response matrix against the current and target paths.
- Resolve blocking differences and document accepted behavioral changes.
- Deploy the target path dark or behind a feature flag if your architecture permits it.
- Compare operational signals and user-visible outcomes during a limited rollout.
- Increase traffic in deliberate stages while monitoring failures, latency, usage, validation errors, and support feedback.
- Keep the previous provider configuration available until the agreed observation period is complete.
- After stabilization, remove obsolete code only after exporting records, updating runbooks, and confirming rollback constraints.
The safest way to switch LLM providers is to make the change observable, reversible, and testable. A provider adapter, a versioned prompt and schema set, a scenario-based test matrix, and a staged rollout turn an uncertain API migration into a repeatable AI development workflow. For broader workflow design, consult the AI Workflow Automation Blueprint and review your complete integration checklist before the next release.