Call OpenAI and Anthropic from one Python API with LiteLLM LiteLLM, an open-source library from BerriAI, lets developers call more than 100 LLM providers through a single OpenAI-format completion call, so switching between OpenAI's gpt-4o and Anthropic's claude-sonnet-4-20250514 requires changing only the model string. The library also ships a proxy with virtual keys and spend tracking for teams that need shared model access without distributing raw provider API keys. The quick-start proxy listens on 0.0.0.0:4000, and the writeup cautions that network, TLS and access controls must be added before exposing it. Every LLM provider has its own SDK, auth pattern and error types. Adding a model usually means more glue code. LiteLLM https://github.com/BerriAI/litellm gives you one OpenAI-format call for 100+ providers, so switching from OpenAI to Anthropic is a one-string change. This is the short setup from the README. One completion call in OpenAI format returns a response from whichever provider you name. You change only the model string. You still need an account and API key for each provider, and each provider's own pricing and limits apply. uv add litellm Set them as environment variables, such as OPENAI API KEY and ANTHROPIC API KEY . Keep them out of your code and out of version control. python from litellm import completion messages = {"role": "user", "content": "Hello "} print completion model="openai/gpt-4o", messages=messages Change the model string and run the same call again: print completion model="anthropic/claude-sonnet-4-20250514", messages=messages Same code, same response shape, different provider. If several developers need model access without sharing raw provider keys, LiteLLM also ships a proxy with virtual keys and spend tracking. uv tool install 'litellm proxy ' litellm --model gpt-4o Point any OpenAI client at http://0.0.0.0:4000 and use a virtual key as the api key . The README links an end-to-end tutorial for creating virtual keys: https://docs.litellm.ai/docs/proxy/docker quick start https://docs.litellm.ai/docs/proxy/docker quick start One caution: the quick start listens on 0.0.0.0:4000, so add your own network, TLS and access controls before you expose it to a team. "Using the litellm repo, write a short Python script that sends 'Hello ' to openai/gpt-4o and to anthropic/claude-sonnet-4-20250514 through litellm.completion. Print both responses. Verify both API keys are set in the environment before running." Step-by-step card: Call 100+ LLM providers through one OpenAI-format API https://dedupedai.com/use-cases/berriai-litellm/call-100-llms-with-one-openai-format-api/?utm source=devto&utm medium=article&utm campaign=howto litellm . More on the repo: LiteLLM use cases https://dedupedai.com/use-cases/berriai-litellm/?utm source=devto&utm medium=article&utm campaign=howto litellm . Source repo: BerriAI/litellm https://github.com/BerriAI/litellm . Want the setup commands for 50 AI repos people actually ship with? Get the free AI Repos That Actually Ship pack: https://dedupedai.com/ship-pack/?utm source=devto&utm medium=article&utm campaign=shippack https://dedupedai.com/ship-pack/?utm source=devto&utm medium=article&utm campaign=shippack Get one email every Monday with the week's hottest AI repos and exactly how to use them: subscribe free at dedupedai.com https://dedupedai.com/join/?utm source=devto&utm medium=article&utm campaign=howto litellm