Moving from the LiteLLM Python SDK to the LiteLLM proxy

Teams that call litellm.completion and the Router in application code can move to the LiteLLM proxy without a rewrite, but the keys, budgets and routing move out of code and into shared configuration. This page explains what maps, what does not, and how to run both paths during the transition.

On this page

Why moving LiteLLM SDK code to the proxy is mostly a configuration change

If your application already calls litellm.completion and uses the Router in code, moving to the LiteLLM proxy is mostly a configuration change. The model routing logic maps well: model aliases, fallbacks, retries, cooldowns and load balancing can be expressed in a proxy config.yaml instead of Python. What changes is where credentials, budgets and limits live. Provider keys, spend limits and access rules move out of application code and into the gateway, where the platform team can issue virtual keys, set per-key, per-user and per-team budgets, and read one set of logs. Your application keeps its request shape and most of its call logic, and it starts authenticating to the gateway with a virtual key instead of holding provider secrets.

The open-source AI Gateway adds virtual keys, budgets and rate limits, spend tracking, the Admin UI, load balancing, guardrails and the MCP gateway on top of what the SDK already provides. The SDK covers the router, fallbacks, cost per call and logging callbacks in Python code. The effort therefore depends on how much control logic sits in the application: routing and fallback settings are usually quick to port, while custom callbacks, per-request metadata used for attribution, and any code that reads spend or cost values need design work. Ask your team to inventory every place the code sets an API key, a model list, a metadata or user field, or a callback, because those are the items that drive effort and risk. Confirm the gateway edition you need before design starts, since some governance features are Enterprise features.

Which SDK features map to the proxy and which stay in the application

This table compares each feature an application uses through the LiteLLM Python SDK with its counterpart on the proxy, whether that is config.yaml, a virtual key or a router setting. Read the middle column for what moves to the platform team and the last column for what the application keeps. Rows marked as not mapping cleanly need a code decision before cutover.

SDK featureProxy equivalentWhat the application keeps
litellm.completion callsCallers send OpenAI-format requests to the proxy base URL with a virtual keyRequest construction, model alias names and error handling
Router model_listmodel_list in config.yaml with model_name groups shared by callersChoice of logical model name per call path
Router fallbacks and retriesFallback and retry settings in router_settings, confirmed against the routing docs for your versionBusiness rules about which fallback is acceptable for a given request
Cooldowns after repeated failuresCooldown behavior configured at the router level; confirm the setting names for your releaseNothing beyond handling the error the caller finally receives
Cost per call and spendSpend tracked per virtual key, user and team in the databasePer-call cost is no longer computed in code for chargeback purposes
Logging callbacks written in PythonNot a direct match: built-in logging and supported integrations replace custom callbacksAny custom callback logic that depends on Python objects must be ported or dropped
Per-call metadataMetadata sent in the request body is passed through to logs, confirm which fields are keptBusiness context fields the platform team needs for attribution
Custom router code and per-call Python objectsNot a direct match: custom routing logic has no config.yaml equivalentCustom routing and response objects stay in the application or in a service it calls

Documented paths for moving code and settings onto the proxy

The proxy is reached through an OpenAI-compatible endpoint, configured through config.yaml, and governed through virtual keys, the Admin UI and the key and team APIs. The cards below cover each documented path, where the work is manual, and what to confirm against the docs for the release you deploy.

OpenAI-compatible endpoint for callers

Application code that calls litellm.completion or the Router in-process can instead send requests over HTTP to the proxy, which accepts the OpenAI request format. The change at each call site is usually the base URL and the API key, with the model name pointing at a configured alias. Check every caller for SDK features that depend on in-process objects, such as custom callbacks or Python-only parameters, because those do not travel through the HTTP endpoint unchanged. Confirm the supported parameters for your release in the current docs.

Production guide

Model list entries that mirror Router deployments

Each entry in the Router's model_list usually maps to an entry under model_list in config.yaml, with a model_name alias that callers use and litellm_params that name the provider model and its credentials. Routing settings such as retries, fallbacks and cooldowns move into the router settings block. There is no general import tool that reads Python Router code, so teams typically re-enter or convert these entries by hand and compare the resulting routes against a test list of requests. Confirm exact key names against the docs for your chosen release.

Virtual keys issued in place of provider keys

Provider API keys stay in the proxy configuration or a secret manager, and each team, service or user receives a virtual key scoped to specific models, with its own budget and rate limits. Applications switch from a provider key to a virtual key, so revoking one caller no longer requires rotating the provider credential. Virtual keys require a PostgreSQL database. Plan a key naming scheme and an owner for each key before cutover, because existing SDK code rarely records who uses which credential.

Virtual keys docs

Admin UI and key and team APIs

Platform teams can create teams, keys and budgets from the Admin UI or through the management API, which lets provisioning run from a script or a pipeline. The API route is the better fit when keys must be created from an approved request process rather than by hand. Check which management endpoints your release exposes and which actions need the master key, and keep the master key in a secret manager. Test the API calls in a staging proxy first, because budget and limit fields are easy to set on the wrong object.

Routing and fallback documentation

The routing documentation describes the strategies available on the proxy, including simple-shuffle, usage-based, latency-based, least-busy and cost-based routing, along with retries, cooldowns and priority ordering for failover. Use it to confirm that a strategy you chose in the SDK exists with the same name and behavior on the proxy. Some Python-only options may not have a direct equivalent in the proxy configuration, so compare the two settings line by line before retiring the in-code Router.

Routing docs

Gaps that need manual conversion

Anything the documented paths do not cover needs manual work and a written owner. Custom Python callbacks, logging hooks, budget logic written in application code and per-request overrides usually have to be redesigned as proxy settings or moved into a supported extension point. Record each SDK-only behavior in an inventory during discovery, then decide whether the proxy provides an equivalent, whether the application keeps the logic, or whether the behavior is dropped. Confirm each decision against the release you deploy.

How to run the SDK and the proxy in parallel before cutover

This sequence moves traffic from in-code SDK calls to a central LiteLLM proxy one service at a time, so keys, budgets and logs become central while callers keep working and spend can be compared between the two paths.

  1. Inventory every SDK call and router

    The application team and the platform team list every litellm.completion call, every Router instance, every callback and every place a provider key is read from the environment. Record which model names each service uses, which providers they map to, and whether streaming, tool calls or fallbacks are involved. Done means a single inventory per service that a reviewer can check against the code, with no call site left unlisted.

  2. Define model aliases and config.yaml

    Map each model name in the inventory to a stable alias that callers will use after cutover, and write those aliases into config.yaml with their provider routes, credentials referenced from a secret store rather than typed into the file, and the fallback order the Router currently applies. Keep the proxy config under version control so every change is reviewed. Done means every alias resolves in a test deployment and its provider route matches what the SDK code currently calls.

  3. Deploy the proxy with PostgreSQL and Redis

    Deploy the LiteLLM proxy with PostgreSQL as the database, which virtual keys require. If more than one proxy instance will run, add Redis 7.0 or newer for shared rate limits, router state and cache, as LiteLLM's production guidance describes. Keep the master key in a secret manager. Done means the health checks pass on every instance, the database accepts connections, and a test request through the proxy returns a valid response from each alias.

  4. Issue virtual keys per team

    Create one virtual key per team or service rather than sharing a single master key, and attach the budgets, rate limits and model restrictions that the team's workload needs. Record which key belongs to which service so spend and logs can be traced back. Done means each pilot service has its own key, a test call with that key succeeds for its allowed models, and a call to a model outside its allow list is refused.

  5. Pilot one service behind a switch

    Choose one low-risk service and point it at the proxy through a feature flag or base URL switch, keeping the original SDK path available in the same release. Keep the switch under the team's control so it can be flipped back without a redeploy of the wider system. Done means the pilot service handles real traffic through the proxy, streaming and tool calls behave as the inventory expects, and the flag can switch the service back to the SDK path.

  6. Run both paths and compare spend and logs

    Run the SDK path and the proxy path side by side for the pilot service, sending comparable traffic through each, and compare response behavior, latency, error rates, token counts and spend. Confirm that proxy spend appears under the correct virtual key and that logs contain the request metadata the team needs. Done means a written comparison signed off by the service owner and the platform team, with every difference explained or fixed.

  7. Cut over in stages

    Move the remaining services to the proxy in groups, starting with the lowest-risk ones, and keep the switch in place for each group until its logs and spend have been reviewed. Track which callers still use the SDK path so nothing is missed. Done means every service in the inventory routes through the proxy, and the platform team holds a current list of any exceptions with an owner for each.

  8. Remove SDK provider keys and dead code

    Once a service has run stably through the proxy, remove the provider keys and Router configuration from its code and environment, and delete the fallback and callback code that the proxy now handles. Confirm that no provider key remains in application configuration and that the old code paths are unreachable. Done means a scan of the application repositories and deployment configuration finds no direct provider credentials and no references to the retired SDK path.

What stays in the application and what moves into the gateway

Application code keeps the parts that describe what the application asks for and how it reacts to responses. The request shape stays in the code: the messages, the model name the feature wants, temperature and other sampling choices, and the tool definitions the feature depends on. Client-side behavior also stays, because timeouts, the decision to retry a failed call, how streamed chunks are rendered and how tool-call results are fed back into the conversation all live in the calling service.

  • Request shape: messages, sampling parameters and tool schemas remain in the application and are sent unchanged through the OpenAI-format interface.
  • Client-side retries: keep the retry and timeout logic the service already has, and avoid stacking it on top of gateway retries without measuring the combined effect.
  • Streaming handling: chunk parsing, partial output display and cancellation stay in the client, so test streamed responses after the switch.
  • Prompt logic: templates, few-shot examples and output parsing remain in the codebase under version control.
  • Tool calls: the application still executes tools and returns results; the gateway only passes the calls through.

Before cutover, confirm with the application team which model names the code uses, since these map to gateway aliases in the next tab's settings.

What drives the effort of a LiteLLM SDK to proxy migration

This table lists the factors that change how much work a move from in-code LiteLLM SDK usage to a central proxy takes, who does each piece, and what a quote should spell out. Read each row as a question to answer about your own codebase before asking for a fixed-scope proposal. The main takeaway is that the count of services and custom callbacks usually matters more than the count of models.

DriverWhy it changes effortWhat a quote should state
Services and Router instancesEach service that builds its own Router or calls litellm.completion needs its routing and fallback settings translated into config.yaml and its calls pointed at the proxy.Number of services, number of Router instances, and which service owners sign off on cutover.
Custom callbacks and logging hooksPython callbacks that write spend, traces or PII filters inside the app need a gateway-side replacement or a deliberate decision to drop them.List of callbacks, what each does, and whether the replacement is built, configured or retired.
Provider credentials and modelsEvery provider key moves from application environment variables into the proxy, and each model name often becomes an alias that callers must keep using.Count of provider accounts, count of model aliases, and the mapping from old model strings to new aliases.
Per-service routing and fallback tuningRouters tuned for latency, cost or failover in code must be reproduced and re-tested under the proxy's routing settings.Which routing strategy each service uses today and which settings must match after migration.
Streaming and tool-call test coverageStreaming responses and tool calls are where proxy differences tend to surface, so existing tests and new contract tests set the verification effort.Test suites in scope, whether streaming and tool calls are covered, and who writes the new contract tests.
Database and Redis buildVirtual keys need PostgreSQL, and more than one proxy instance needs Redis 7.0 or newer, so the platform build is a fixed cost before any app moves.Who provisions PostgreSQL and Redis, sizing assumptions, backup approach, and whether this is in scope.
Identity and secret manager integrationAdmin access, SSO and moving provider keys into a secret manager add integration work that the SDK model never needed.Identity provider, secret manager, SSO edition needed for the user count, and who holds admin rights.
Teams that need their own keys and budgetsEach team needs virtual keys, budgets and limits set up, and spend history must be explained to teams that previously paid directly.Number of teams, budget owners, and whether spend history migration is included or only new spend is tracked.

What usually goes wrong when SDK code moves to the proxy

Most failures in an SDK-to-proxy move come from ownership and state, not from request formats. The cards below cover the points where keys, budgets, routing, logs and shared state change hands, and what to check before each cutover step.

Provider keys left in app config

After cutover, teams often keep the old provider keys in environment variables or Secrets next to the new virtual key, so the application can still bypass the gateway. Remove provider credentials from application config once a service has moved, and keep them only in the gateway's config.yaml or a secret manager. Check that a request made with the old key fails at the provider side, or is blocked by network policy, before you call the migration complete.

Budgets without team owners

A budget set on a single virtual key looks correct until the key is rotated, shared or reassigned, and then spend lands on no team at all. Tie each key to a named team or user before setting a budget, so the owner receives the alert and the spend report. Ask the platform team to confirm who approves a budget increase, because temporary increases are easy to grant and easy to forget.

Silent router retry and cooldown changes

SDK code often sets its own num_retries, timeouts or fallback order in the Router, and those settings do not carry over automatically when the same models sit in the gateway's routing config. A model that was retried three times in code may now enter cooldown after repeated failures, or fail over to a different deployment with different pricing. Compare retry, timeout and priority settings side by side in the two places, then replay a failing provider call in staging to confirm the behavior.

Callbacks that log differently

Logging callbacks registered in Python code, such as cost-per-call hooks or custom success handlers, may not run in the same way once the call passes through the proxy. Log fields, request IDs and token counts can differ, and dashboards built on the old output can show gaps or double counts. Inventory every callback in the application, decide which ones the gateway replaces, and compare a sample of log records from both paths before retiring the SDK logger.

Redis missing for a second instance

A single proxy instance can run without shared state, but a second replica needs Redis for shared rate limits, router state and cache. Teams that scale out during cutover without Redis see inconsistent TPM and RPM enforcement and router decisions that differ between pods. LiteLLM's production guide requires Redis 7.0 or newer once more than one proxy instance runs, so confirm the Redis version and connectivity before the first replica starts.

Spend history split across sources

During the transition, spend is recorded in the provider console, in application logs and in the gateway database, and the three totals rarely match. Finance then asks which number is correct, and no one can answer. Pick the gateway database as the system of record for migrated traffic, record the cutover date for each service, and reconcile monthly totals against provider invoices for the overlap period.

Questions buyers ask before moving SDK code to the proxy

How much effort does moving SDK code to the proxy take?

The effort depends mainly on how many services call litellm.completion or the Router, how much provider-specific behavior those calls rely on, and how many teams own them. Each service needs its client pointed at the gateway, its provider keys replaced with virtual keys, and its model names mapped to aliases defined in the proxy configuration. Services that use the Router for retries, fallbacks or load balancing need those settings re-expressed in the proxy, and the available routing strategies differ. Test coverage is the other driver, because streaming, tool calls and error handling are where moves usually need the most verification. Ask for a written inventory of call sites before agreeing a scope, since the inventory turns a rough sense of effort into a quote you can compare.

How long does moving SDK code to the proxy take?

No single duration applies, because the length depends on the number of services, the test coverage each one has and the change approvals your organization requires. Platform work runs alongside application work: a PostgreSQL database for virtual keys, budgets and spend, Redis 7.0 or newer once more than one proxy instance runs, and a secret manager holding LITELLM_MASTER_KEY, which must start with sk-. Teams that already have these in place can start sooner. Application cutover is usually staged service by service, so the calendar follows how many services move and in what order. Ask for milestones for each service cutover in the written scope, and confirm approval steps with your change board before the schedule is fixed. Most DeployOpen engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

Can our in-house team move SDK code to the proxy without a partner?

Often yes, if the team already runs the SDK in production and can operate the supporting services, but you need to confirm the skills first. The application changes are Python work that the owning teams already know. The gaps tend to be platform skills: running PostgreSQL with backups, operating Redis, handling secrets in a secret manager, and deploying the proxy on Kubernetes if you use it. Security review of provider key handling and admin access adds further work. Enterprise features are a separate decision: from v1.76.0, SSO is free for up to 5 users according to the LiteLLM Enterprise documentation, and an Enterprise license is needed beyond that. Run a short internal skills check, then decide whether your team builds the platform itself, hands the whole move to a partner, or hands over only the parts you cannot staff.

What does our platform team need to provide for the proxy?

Three groups need to commit people and access before the build starts:

  • Platform team: PostgreSQL as the primary supported database, Redis 7.0 or newer once more than one instance runs, and a runtime for the proxy. LiteLLM recommends one Uvicorn worker per pod on Kubernetes and horizontal scaling, and its production guide suggests 1 vCPU and 4 GiB memory per worker as a starting point.
  • Security team: the secret manager that holds LITELLM_MASTER_KEY, decisions on who may hold provider keys, and review of admin access and network exposure.
  • Application owners: the call-site inventory, test environments, alias names for each model and sign-off on cutover dates.

Confirm capacity, network paths and access for each group in your own environment before scheduling work, since the proxy cannot serve traffic until the database and secrets are in place.

Can the SDK and the proxy run side by side during the transition?

Yes, in most cases, as long as each service has one clear path at any given time. Both can exist in one environment while services move one at a time, with the proxy serving services that have cut over and the SDK serving the rest. The main risk is drift: a service that calls the SDK with one set of fallbacks while the proxy applies different routing will behave differently under failure. Keep model aliases and routing rules aligned in the proxy configuration before each cutover. Keep provider keys for the SDK path separate from virtual keys until each team's key and budget are in place, so two paths never draw on the same budget without anyone noticing. Confirm that both paths can reach the providers during the overlap window, and set a date to retire the SDK path for each service.

What happens to our existing spend history after the switch?

Spend history stays where it was recorded and does not move into the proxy by default, so you need a plan for it before cutover. Requests sent directly through the SDK were tracked by whatever logging callbacks or invoices you already had, while the proxy records spend per virtual key, team and user from the point traffic passes through it. Keep the old records and provider invoices for the periods before the switch, export them, and record the cutover date so reports can join the two periods. Reconcile the proxy's spend totals against provider bills for the first billing cycle, since differences in token counts or pricing show up there. Ask for the export format and reconciliation steps in the written scope, and confirm your finance team's chargeback needs before deciding how far back reports must reach.

Which Router settings move into config.yaml and which stay in code?

Routing behavior such as the strategy, retries, cooldowns, failover priority and session affinity moves into the proxy configuration, while calling logic and per-request values stay in the application. The LiteLLM routing documentation lists simple-shuffle, usage-based, latency-based, least-busy and cost-based strategies, with simple-shuffle recommended, so the first step is choosing one strategy per model group and writing it down. Application code keeps the model alias it requests, timeouts that reflect its own user experience, and request metadata such as user or team identifiers that the proxy uses for tracking. Move one setting at a time and test the failure path, since a cooldown or retry that differs from the SDK's behavior changes how errors reach users. Confirm each setting against the routing documentation for the version you run.

How requests flow during the parallel run

Traffic starts in two places: applications still calling the LiteLLM Python SDK directly from their own processes, and applications already switched to the proxy endpoint with virtual keys. Both paths reach the same model providers, but only the proxy path passes through the gateway, where keys, budgets and logs are enforced. The trust boundary sits between the company network and provider APIs, so check that only the proxy holds provider credentials and that PostgreSQL and Redis are reachable only from inside the network.

Two call paths during the transition, meeting at the trust boundary to providers.

How DeployOpen scopes the SDK to proxy move

DeployOpen starts the move with a written inventory, not with configuration. Before any proxy is built, the team lists every place the application calls litellm.completion, litellm.acompletion or a Router instance, and records the settings that live beside those calls: model names, api_key sources, fallbacks, num_retries, timeout, routing strategy, and any logging callbacks wired into the code. The inventory also notes which services run in which environment and who owns each one. That list decides what moves into config.yaml and what stays in the application, and it exposes the calls that depend on settings the proxy will not reproduce exactly. The output is a written scope document that the client reviews and signs before work begins, with deliverables and timelines agreed in advance.

Once the scope is fixed, DeployOpen implements the move in the client's own infrastructure. The work covers configuring the proxy with its model list and routing, issuing virtual keys with per-key or per-team budgets and model restrictions, and setting up request logs so platform teams can see spend by key. The engineers also test streaming and tool-call behavior against each migrated route, because these are the paths where SDK and proxy responses are most likely to differ. Cutover is staged by service, and the team supports both the cutover and the later decommissioning of direct provider keys and old SDK settings. Ongoing support, upgrades and continuous testing are available as a retainer once the gateway is in production. Clients should ask the proposal to name the owner of each inventory item and the test evidence required before each cutover.

How DeployOpen delivers LiteLLM migrations

DeployOpen plans, builds and hands over the move from direct LiteLLM SDK calls to a self-hosted LiteLLM proxy inside your own infrastructure. We start from how your application calls the SDK today, then agree in writing what moves into the gateway configuration and what stays in the code.

How we scope

  • We inventory every litellm.completion call, Router instance and callback in the application code.
  • The written scope lists which models, routes, teams and keys move to the proxy in each phase.
  • We confirm the database, Redis and secret manager targets that your environment must provide before work starts.
  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work begins.

How we build

  • We write the config.yaml model list and router settings to match the routing the code already expects.
  • We design virtual keys, budgets and model restrictions per team, then test them against real calls.
  • We run the SDK and proxy paths side by side and compare responses, retries, fallbacks and logged spend.
  • We verify streaming, tool calling and error handling in each application before any traffic moves.

How we hand over

  • You receive the gateway configuration, the code changes and a record of what was tested and why.
  • Runbooks cover the cutover steps, the rollback path and how to add a new model or team key.
  • We document which settings stay in application code, so developers know where to change behavior.
  • Your engineers walk through the deployment and retest the migration with us before we close the work.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • A retainer can cover LiteLLM version upgrades on the supported release line and review of new model routes.
  • Retest cycles confirm that budgets, key scopes and logging still behave after configuration changes.
  • Support scope and response expectations are written into the retainer agreement, not assumed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.