LiteLLM: Call 100+ LLM APIs With One Unified OpenAI Interface
LiteLLM normalizes the APIs of OpenAI, Anthropic, Bedrock, Gemini, and 100+ other providers into one OpenAI-compatible interface with built-in fallbacks and cost tracking.
If you write code against the OpenAI SDK and later want to switch to Claude or Gemini, you rewrite your API calls. If you want fallback logic (try GPT-4o, fall back to Claude if it's down), you implement it yourself. If you want to track spend across providers, you build that too.
LiteLLM solves all three problems with a single library and an optional proxy server.
The completion() Function
from litellm import completion
# OpenAI
response = completion(model="gpt-4o", messages=[{"role": "user", "content": "Hello"}])
# Anthropic - same function, same response format
response = completion(model="claude-3-5-sonnet-20241022", messages=[{"role": "user", "content": "Hello"}])
# Bedrock Claude
response = completion(model="bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0", messages=[{"role": "user", "content": "Hello"}])
# Gemini
response = completion(model="gemini/gemini-1.5-pro", messages=[{"role": "user", "content": "Hello"}])
Every response comes back in OpenAI format regardless of provider.
Team workspace
Ship faster with chat, meetings, and projects in one place — Zlyqor.
Practical deep-dives on LLMs, developer tools, and AI engineering. No filler. Unsubscribe any time.
// written byFIG. AUTH-01
530
Mahmudul Haque Qudrati
CEO & ML Engineer
CEO and ML Engineer at Pristren. Builds AI-powered software for teams and writes about machine learning, LLMs, developer tools, and practical AI applications.
Open Code Review – An AI-powered code review CLI tool: A Practical Overview
Open Code Review is an open-source CLI tool from Alibaba that uses AI to review code changes. It runs locally, supports multiple LLMs, and costs about $0.01 per review. Here's a practical breakdown.