Skip to main content

Library to easily interface with LLM API providers

Project description

🚅 litellm

PyPI Version PyPI Version CircleCI Downloads litellm

a simple & light package to call OpenAI, Azure, Cohere, Anthropic API Endpoints

litellm manages:

  • translating inputs to completion and embedding endpoints
  • guarantees consistent output, text responses will always be available at ['choices'][0]['message']['content']

usage

Read the docs - https://litellm.readthedocs.io/en/latest/

quick start

pip install litellm
from litellm import completion

## set ENV variables
# ENV variables can be set in .env file, too. Example in .env.example
os.environ["OPENAI_API_KEY"] = "openai key"
os.environ["COHERE_API_KEY"] = "cohere key"

messages = [{ "content": "Hello, how are you?","role": "user"}]

# openai call
response = completion(model="gpt-3.5-turbo", messages=messages)

# cohere call
response = completion("command-nightly", messages)

# azure openai call
response = completion("chatgpt-test", messages, azure=True)

# openrouter call
response = completion("google/palm-2-codechat-bison", messages)

Code Sample: Getting Started Notebook

Stable version

pip install litellm==0.1.1

hosted version

why did I build this

  • Need for simplicity: My code started to get extremely complicated managing & translating calls between Azure, OpenAI, Cohere

Support

Contact us at ishaan@berri.ai / krrish@berri.ai

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litellm-0.1.31.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litellm-0.1.31-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file litellm-0.1.31.tar.gz.

File metadata

  • Download URL: litellm-0.1.31.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for litellm-0.1.31.tar.gz
Algorithm Hash digest
SHA256 f36ca42fc6a09a0ed0a81e177b36e16c05d1aac7dd451a230cc6ba4199634d4c
MD5 e7e3577e6e5f9ab4b0361e093f7939c1
BLAKE2b-256 2f13df523488f19a229783321b8845b8beb682fd312f874d9ad95e6a510f1bf1

See more details on using hashes here.

File details

Details for the file litellm-0.1.31-py3-none-any.whl.

File metadata

  • Download URL: litellm-0.1.31-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for litellm-0.1.31-py3-none-any.whl
Algorithm Hash digest
SHA256 276433345fbfa88beab9b1efd65bb24274c3bd1a9ebd5be7013f151a80d5bc95
MD5 31e99e793fc3f8a4966b7128343ec524
BLAKE2b-256 4566d2b1860ec101fbb4a9735aa3d2a7ddd1a0bc3ebbdcf7b7005e181bc8c5d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page