Using python, is there a single module that can access openai, anthropic and google LLM…
- User
Using python, is there a single module that can access openai, anthropic and google LLM models in similar way?
Assistant
Yes,
litellmis a Python library specifically designed to provide a unified interface for multiple LLM providers including OpenAI, Anthropic, and Google. It lets you switch between models with minimal code changes.Here's a simple example:
pythonimport litellm # OpenAI response = litellm.completion( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello, OpenAI!"}] ) # Anthropic response = litellm.completion( model="claude-3-opus-20240229", messages=[{"role": "user", "content": "Hello, Anthropic!"}] ) # Google response = litellm.completion( model="gemini-pro", messages=[{"role": "user", "content": "Hello, Google!"}] )Would you like me to explain how this code works?