Moving applications from the OpenAI SDK to the LiteLLM proxy

Moving OpenAI SDK services to a self-hosted LiteLLM proxy is mostly a base_url, key and model-name change, but streaming, tool calls and spend history need deliberate testing. This page explains what maps cleanly, what does not, and how to cut over in stages.

On this page

How hard is it to move OpenAI SDK applications to the LiteLLM proxy?

Most services that call OpenAI directly keep their provider keys in environment variables, config files and secret stores spread across several repositories. The client change itself is small: the LiteLLM proxy accepts the OpenAI request format, so an application built on the OpenAI SDK usually moves by pointing base_url at the proxy and swapping the key for a LiteLLM virtual key. The effort concentrates elsewhere: issuing virtual keys per team, mapping model names to aliases, testing streaming and tool calls against the proxy, and cutting traffic over in stages so one service failing does not stop the rest.

The total effort depends mostly on how many services, repositories and teams call OpenAI today, and on how many of them rely on model names, streaming behavior or tool-calling features that differ between providers. A small set of services with one owner can move in a short sprint. Many services owned by several teams need a shared alias scheme, a key issuance process and a list of callers each team has signed off. Before you size the work, inventory every call site, the model strings it sends, whether it streams, and which secret it reads. The proxy also needs a PostgreSQL database before virtual keys work, so confirm early that your platform team can provision and back up one, because that is a prerequisite rather than a later task.

Ask any partner quoting this work to break the effort into the inventory, the key and alias design, the per-service code changes, the streaming and tool-call test plan, and the staged cutover with rollback steps. Confirm whether the quote covers the PostgreSQL setup and the secret migration or only the application edits. For the client example, the documented pattern is to construct the OpenAI client with the proxy address and a LiteLLM key, as in client = OpenAI(api_key=..., base_url="). Your own environment will use a real host name and a key from your secret manager, and the LiteLLM OpenAI-compatible endpoints documentation describes the request format the proxy accepts.

Which OpenAI SDK features map to the LiteLLM proxy and which need rework

This table compares what your services use from the OpenAI SDK today with the matching LiteLLM proxy mechanism, and notes what each row asks you to confirm in your own environment. Read it before changing any code: rows marked as needing confirmation are where callers most often break after cutover. The main takeaway is that chat completions, streaming and most tool calls usually keep working with a base_url change, while Assistants, Responses-only features and provider-specific parameters need a test in your stack first.

CapabilityToday (direct OpenAI SDK)LiteLLM proxy equivalentWhat to confirm in your environment
Client connectionOpenAI client with api_key and the default OpenAI base URLSame client with base_url pointing at the proxy and api_key set to a LiteLLM virtual keyConfirm every service reads base_url from configuration, not a hard-coded default
Model namesCallers send OpenAI model IDs such as gpt-4oCallers send a model_name alias defined in the proxy config, mapped to one or more provider deploymentsList every model string in the code and map each to an alias owned by the platform team
Chat completionsPOST chat/completions through the SDKOpenAI-format chat completions passed through the proxy to the mapped providerTest one request per alias and compare response shape with what callers parse
StreamingServer-sent event streams consumed by the SDKStreaming supported in OpenAI format through the proxyTest long streams through every load balancer, ingress and proxy hop, including timeouts and client disconnects
Tool and function callsTool definitions and tool_calls in responsesTool calls passed through in OpenAI format where the target provider supports themConfirm each target model supports tools, and test parallel tool calls and tool result round trips per alias
Per-project keysOne OpenAI key per project or service, managed in the provider consoleVirtual keys per team or service, with model restrictions, budgets and rate limits set in the proxyDecide key ownership, rotation and where provider keys are stored before issuing any virtual key
Usage reportingUsage fields in responses and spend views in the provider consoleSpend and request logs recorded in the proxy database, with per-key and per-team budgetsCompare proxy spend totals with the provider bill for a test period before relying on proxy numbers for chargeback
OpenAI-specific endpointsAssistants, files, fine-tuning, batch or Responses API callsSupport depends on the endpoint and the proxy version, so these are not assumed to pass throughInventory these calls, check them against the LiteLLM docs for your release, and plan rework or a direct path where unsupported
Provider-specific parametersParameters tied to OpenAI features, such as response format or reasoning optionsSome parameters are forwarded, some are dropped or translated by the provider adapterTest each parameter used by the service against the target provider behind the alias

Documented paths for moving OpenAI SDK clients to the proxy

The documented route for an OpenAI SDK application is small: point the client at the proxy, swap the key, and map model names in configuration. The cards below cover each step and the checks that matter before a service sends production traffic through the gateway.

Changing base_url and api_key

The client change is usually two lines: set base_url to the proxy address and set api_key to a LiteLLM key instead of the provider key. Application code keeps the OpenAI request format, so the rest of the call usually stays as written. Check every place the service builds its client, including background jobs, scripts and test fixtures, because a missed instance keeps calling the provider directly and bypasses budgets and logs.

OpenAI-compatible endpoints

OpenAI-compatible endpoint documentation

The OpenAI-compatible endpoint page defines which routes and request shapes the proxy accepts from OpenAI clients. Read it against the exact LiteLLM version you deploy, not a version you remember. Confirm which chat, embedding and other endpoints your service uses, and test each one, because support can differ by route and by provider behind it.

Compatible endpoints docs

Creating virtual keys per team

Each team or service gets its own virtual key in place of the shared provider credential. Keys carry budgets, rate limits and a list of allowed models, so a single service can be capped without affecting others. Decide the key owner, rotation process and budget before cutover, and record which key each service uses so spend can be traced back to a team.

Virtual keys docs

Mapping model names in proxy config

Applications usually request a model name such as the provider's own identifier. In the proxy configuration, define a model entry whose name is the alias the application sends, mapped to the real provider model and credentials. Keep aliases stable so application code does not change when the underlying model changes. Document each alias and its owner in the same repository as the configuration.

No assumed automated code converter

This path assumes no automated tool rewrites application code or imports existing keys and spend history. Teams should confirm whether any import or conversion tooling exists for their target version against the release notes on the LiteLLM releases page before planning around it. Without that confirmation, budget the client changes and key creation as manual, reviewed work.

LiteLLM releases

Inventory, pilot, parallel run and cutover for each service

This sequence moves each caller from direct OpenAI keys to the LiteLLM gateway one service at a time, so every switch is verified against the old path and can be reversed before the direct keys are retired.

  1. Inventory every service and its keys

    The platform team and each application owner list every service that calls OpenAI directly, including batch jobs, notebooks, scheduled tasks and third-party tools that hold a key. For each one, record the owning team, the models and endpoints used, whether streaming or tool calls are used, expected request volume, and where the key is stored. The inventory is done when every direct key has a named owner and a known set of callers, and nothing is left that no one can account for.

  2. Stand up the proxy with PostgreSQL and a master key

    The platform team deploys the LiteLLM proxy in infrastructure you control, backed by PostgreSQL, which LiteLLM names as its primary supported database and which virtual keys require. Store LITELLM_MASTER_KEY, which must start with sk-, in a secret manager rather than in a config file or environment file on a host, as the production guide recommends. Confirm that the admin can log in, that the health endpoint responds, and that a test request routed through a provider key succeeds before any application is pointed at the gateway.

  3. Issue team virtual keys with budgets and limits

    Create one virtual key per team rather than sharing a single key across services. Set a budget, rate limits (TPM and RPM) and the list of models each key may call, using the limits agreed with each team's owner. Store the issued keys in each team's secret store and confirm that a key outside its model list or over its budget is rejected. The step is complete when each inventoried service has a key that its owner has tested and that the gateway logs under the right team.

  4. Pilot one low-risk service

    Choose a service with low business impact, a single model, and no tool calls or streaming dependencies. Change its base_url to the proxy and its api_key to the team's virtual key, keeping the rest of the OpenAI client code unchanged. Watch error rates, latency and spend in the proxy logs for a period the team agrees on. The pilot is done when the owner signs off that responses, errors and spend attribution match expectations.

  5. Run old and new paths in parallel

    For services with meaningful traffic, send the same representative requests through the direct OpenAI path and the gateway path, either in a shadow setup or with a small share of production traffic. Compare response structure, finish reasons, tool call output, streamed chunk handling and token counts, and reconcile gateway spend with the provider bill for the same window. Differences in model names, default parameters or retry behavior are recorded and fixed before cutover. The output is a short comparison record per service that the owner accepts.

  6. Cut over service by service

    Move the remaining services one at a time, starting with those that have the lowest risk and the most consistent test results. For each service, change configuration to the gateway, keep the previous direct key available in the secret store, and document the rollback step that restores the old base_url and key. Do not move the next service until the current one has run cleanly through its normal business cycle. The cutover is complete when every inventoried service reports traffic through the gateway.

  7. Revoke direct keys and decommission

    Once no service depends on a direct OpenAI key, revoke those keys at the provider, remove them from application secret stores and CI variables, and confirm that the revoked keys return errors. Update the inventory to show each service's virtual key owner and retire the rollback paths. Record the final state so that auditors and security reviewers can trace each caller to a team key, a budget and a log stream. The step closes when the inventory shows zero direct provider keys in use.

What changes in code, config and keys during the move

For most services, the code change is small. The OpenAI client keeps working as long as it points at the proxy. LiteLLM documents this pattern directly: set base_url to the proxy address and api_key to a LiteLLM key, then keep the rest of the calling code as it is. The application still sends OpenAI-format requests, so the bulk of the change is configuration rather than rewritten logic.

  • Base URL: Point base_url at the proxy's service address, not at the provider. Confirm the path prefix your client library expects, since a trailing /v1 mismatch is a common cause of failed calls.
  • API key: Replace the provider key with the virtual key issued for that service. The provider key should no longer appear in application config.
  • Model names: Callers send the alias defined in the proxy, such as gpt-4o-prod, not the provider's model identifier. Each alias needs to be agreed with the owning team before cutover.
  • Retries and timeouts: Review client-side retry and timeout settings. The proxy adds a hop and may apply its own retries and routing, so retries stacked on both sides can multiply load.
  • Streaming and tool calls: Test these paths explicitly in a non-production environment, because they are the first to show differences in request handling.

Before cutover, confirm with each team that its test suite runs against the proxy alias and that error handling covers the proxy's responses.

How a request moves from the service through the proxy to the provider

The request starts in the calling service, which sends its OpenAI-format call with a LiteLLM virtual key to the proxy inside the company network. The proxy checks the key, its model access, budget and rate limits against PostgreSQL, resolves the model alias to a provider route, and optionally uses Redis for state shared across proxy instances. Only the final provider call crosses the trust boundary to the external model provider. Check that the alias, key scope and spend recording behave as expected before moving production traffic.

Request path from calling service through the LiteLLM proxy to the external provider.

How to test streaming and tool calls before cutover

Streaming and tool calls need their own test cases, because a gateway can pass a simple completion while breaking them. A caller that works with a plain request may still fail when the proxy relays server-sent chunks, when a tool call arrives split across several chunks, or when a long generation hits a timeout set at the proxy, the load balancer or the client. Before cutover, write explicit cases for each of these: confirm that chunks arrive in order and that the stream ends with a finish signal the SDK recognizes, that tool call id values survive the round trip so the follow-up message with the tool role matches them, and that the arguments string parses as JSON in every case your application handles. Check the timeout values on each hop, since a stream that runs longer than any single hop allows will fail mid-answer with an error the caller may not surface clearly.

Error handling needs the same attention as the happy path. A virtual key that has hit its budget or its RPM or TPM limit returns a denial, and the caller must treat it as a final error rather than retrying in a loop that burns quota or hides the cause. Test each denial type your teams can trigger, including a request for a model alias the key is not allowed to use, and confirm that the error body, status code and any streamed error reach the application in the form its error handling expects. Build a test matrix with one row per model alias and one column per team key, and mark each cell with the scenarios it has passed: plain completion, streamed completion, streamed tool call, parallel tool calls, and denial. Run the matrix against the provider and the LiteLLM proxy version you have chosen, and confirm the results there, because provider behavior and proxy releases can change how chunks and tool calls are shaped.

What drives the effort and duration of the migration

The same gateway can take a few services or a whole engineering organization to cut over, and the difference shows up in the factors below. Each card names one factor, why it changes the work, and what to confirm before a schedule is agreed. Durations depend on your environment and are set in the written scope, not stated here.

Number of services and languages

Each service that calls OpenAI directly has its own client construction, retry logic, error handling and configuration path. Services in several languages need the base_url and key change tested in each runtime, and SDK versions differ in how they read environment variables. Inventory every caller, including batch jobs, notebooks and scheduled scripts, because these are the calls teams most often forget. Confirm which owner signs off on each service before cutover.

Distinct provider keys in use

Every OpenAI key found in code, CI variables or secret stores must be traced to an owner and a purpose before it is replaced with a LiteLLM virtual key. Shared keys used by several services or teams multiply the mapping work, because each consumer needs its own virtual key and the upstream key moves into the gateway configuration. Ask for a list of keys with their owners, and confirm whether any key is also used outside the migrated services.

Team and budget structure

Teams that want separate budgets, rate limits and spend reports need their keys, and in some cases teams and users, defined before callers switch. If budgets are shared across a department, the design is simpler but chargeback is coarser. Decide early how a virtual key maps to a team, and whether temporary budget increases will be used during the cutover window. Unclear ownership here is one of the most common sources of delay.

Read the source

Model alias count

Application code often refers to model names such as a specific snapshot. Each name used in code needs an alias in the gateway configuration that points to a real provider deployment. A small set of aliases means a short mapping exercise, while dozens of names spread across services, prompts and evaluation scripts means more review and more chance of a silent model change. Tracking which alias each service uses is the basis for a safe rollout.

Streaming and tool-call usage

Services that stream responses or rely on function and tool calling need explicit tests against the proxy, since chunk handling and tool argument formats are where client code breaks most often. The effort grows with the number of streaming consumers, the number of tools defined, and any custom parsing of response objects. Ask whether each service uses streaming, tools or structured outputs, and plan a test for each pattern in staging before production.

Admin UI SSO needs

Identity for the admin UI depends on the edition. The admin UI supports SSO with several identity providers, and LiteLLM states that SSO is free for up to 5 users from v1.76.0, with an Enterprise license needed beyond that. If many platform, security and finance staff need UI access, plan the identity integration and the license question before cutover, not after. Confirm which identity provider your organization uses and how group membership maps to admin roles.

Read the source

Redis and high availability

A single proxy instance can be migrated in one pass, but more than one instance needs shared state. LiteLLM's production guidance requires Redis 7.0 or newer once more than one proxy instance runs, for shared rate limits, router state and cache. Running highly available instances adds work for the database, Redis, load balancer and health checks, and each adds testing during cutover. Decide the topology before the staged rollout so that tests reflect production.

Read the source

Common questions before moving OpenAI SDK services to LiteLLM

How much effort and cost does moving OpenAI SDK services to LiteLLM involve?

The effort depends mostly on how many services call OpenAI directly, how many distinct code paths they use, and how much each one relies on streaming, tool calls or provider-specific parameters. The main cost components are the people who inventory callers, configure the gateway, rotate keys, write test cases and run staged cutovers, plus the infrastructure that hosts the proxy and its PostgreSQL database. Some of this is one-time (migration and testing), and some recurs (key administration, model alias maintenance, upgrades). For a quote, ask the provider to break the scope into services, test cases per service, environments, and who owns each cutover step. No figure for effort is given here because the answer depends on your inventory.

How long does a move from the OpenAI SDK to LiteLLM take?

Duration follows scope. A small set of services with simple chat calls and one team can move quickly, while a larger estate with streaming clients, tool calling, several teams and separate environments takes longer because each group needs its own keys, aliases and test runs. The schedule is shaped by change windows, the number of cutover stages you choose, and how quickly your key owners and test authors respond. Ask for a timeline in the written scope that lists the stages, the services in each stage and the sign-off points, rather than a single overall estimate.

What does our team need to provide before the migration starts?

Three inputs drive most of the work. First, an inventory of every service, script and developer tool that calls OpenAI, including the models, parameters and client library versions each one uses. Second, a named key owner for each team or application who can approve virtual keys, budgets and model access. Third, test cases that reflect real traffic, including streaming responses, tool calls, error handling and timeouts. Without these, the cutover plan cannot show that callers behave the same way behind the proxy. Confirm that these owners are available during the planned stages.

Can our in-house platform team move services to LiteLLM without a partner?

Yes, many teams do this internally, especially when they already run Kubernetes or similar infrastructure, operate PostgreSQL and Redis, and have engineers comfortable with the OpenAI client. The work is mostly configuration and testing rather than custom code, but it still needs time for the inventory, the staged cutover and the verification of streaming and tool calls. The questions to answer honestly are whether the team has capacity for that testing, whether it can own the proxy after go-live, and whether it needs outside help for security review or the Enterprise decision. A partner is useful when the team wants fixed scope and a written test plan.

Do we need LiteLLM Enterprise for SSO and SCIM?

Not for basic SSO. According to the LiteLLM documentation, the admin UI supports SSO with Google, Microsoft Entra ID, Okta and generic OIDC providers, and from v1.76.0 SSO is free for up to 5 users. An Enterprise license is needed beyond that limit. SCIM is listed among the Enterprise features, along with JWT authentication with identity provider tokens, audit logs, organization and team RBAC and IP allowlisting. Confirm the current edition terms with LiteLLM before you commit, because the free limit and feature list can change between releases.

How does LiteLLM Enterprise describe its support terms?

According to the LiteLLM Enterprise documentation, Enterprise support includes a dedicated channel with the engineering team and optional 24/7 SLAs. Those SLAs are described as a 1 hour response for critical issues and 72 hours for security patches. These are the vendor's stated terms, and they apply to the vendor's own support contract, not to work performed by a migration partner. Ask LiteLLM for the signed terms that apply to your edition and region, and confirm how they interact with your internal on-call process and your own patch windows.

What breaks most often when services switch to the proxy?

The most common problems are streaming responses that the client parses differently through the proxy, tool call payloads that differ in edge cases, model names that do not match the aliases configured on the gateway, and timeouts or retries that were tuned for direct calls to OpenAI. Virtual keys can also fail when a budget or model restriction blocks a team unexpectedly. Test each of these with the actual client libraries your services use, run the old and new paths side by side in a non-production environment, and keep a rollback path for each stage. Confirm the exact client and proxy versions you intend to use before testing.

Official LiteLLM documentation for the migration

Before changing any caller, read the OpenAI-compatible endpoints page in the LiteLLM documentation. It shows how the OpenAI client is pointed at the proxy by setting base_url to the gateway address and api_key to a LiteLLM key, which is the core change this migration makes in each service. Use it to confirm the request paths your services call, the client library version they pin, and whether any call relies on a feature the page describes differently from your current code. Treat the examples as a starting point and test them against your own proxy build, since the gateway version you deploy determines which behavior applies.

Next, read the Virtual keys page, which covers the key model that replaces your provider keys. It describes how keys can carry per-key, per-user and per-team budgets, TPM and RPM limits, temporary budget increases and model restrictions, and it notes that virtual keys need a PostgreSQL database. Use it to decide how keys map to teams and services before you issue any, and to confirm which budget and limit fields your chosen release supports. Check the exact behavior of model restrictions in your environment, because a key that cannot reach an aliased model will fail at the gateway, not in the provider.

For the wider reference set, the LiteLLM GitHub repository and the LiteLLM releases page show which release you are targeting and what changed. Pin the version you test and the version you deploy, and record both in your cutover plan.

How DeployOpen scopes and delivers the OpenAI-to-LiteLLM move

DeployOpen approaches the move from direct OpenAI SDK calls to the LiteLLM proxy as a scoped change to your callers, keys and gateway configuration. We inventory every service that calls OpenAI, build the gateway in your own infrastructure, and cut traffic over in stages with tests for streaming and tool calls at each step.

How we scope

  • We inventory every service, SDK version and call pattern that currently sends requests straight to OpenAI.
  • We agree which teams receive virtual keys, which model aliases they use and which budgets and rate limits apply.
  • Engagements are fixed-scope, with deliverables, cutover stages and timelines agreed in writing before work starts.

How we build

  • We deploy the LiteLLM proxy in your infrastructure with PostgreSQL for virtual keys and spend records.
  • We map model names to aliases in configuration so callers change only the base URL and key.
  • We test streaming responses, tool calls and error handling for each service before it moves to the gateway.

How we hand over

  • We document the base URL, key issuance process, alias catalog and per-team budget settings for your staff.
  • We provide a cutover runbook with a rollback path that returns each service to its previous direct OpenAI key.
  • We walk your platform and application owners through the test results, open items and the monitoring to watch.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the cutover is complete.
  • Retainers can cover LiteLLM version upgrades on supported release lines and review of new callers added later.
  • Ask us to confirm support terms, response expectations and included work in the written scope before signing.

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.