Skip to main content

A fast LLM gateway

Project description

RiteLLM

A blazingly fast LLM gateway built with Rust 🦀

Python Version License

Overview

RiteLLM is a high-performance LLM (Large Language Model) gateway that provides a unified interface for interacting with multiple LLM providers. Built with Rust and exposed through elegant Python bindings, RiteLLM combines the speed of compiled systems programming with the ease of Python development.

✨ Key Features

  • 🚀 Unified LLM Gateway: Single, consistent API for multiple LLM providers
  • 🔌 Provider Support: Currently supports OpenAI, with more providers coming soon (Anthropic, Google, Cohere, and more)
  • ⚡ Rust-Powered Performance: Core engine built in Rust for maximum speed and efficiency
  • 📊 First-Class Observability: Built-in integration with Weights & Biases Weave for seamless tracing, monitoring, and debugging
  • 🐍 Pythonic Interface: Clean, intuitive Python API that feels native to the ecosystem
  • 🔒 Type-Safe: Full type hints for better IDE support and code quality
  • 🌊 Streaming Support: Real-time streaming responses for better user experience

🚀 Installation

Install RiteLLM using pip:

uv pip install ritellm

💻 Quick Start

Basic Usage

from ritellm import completion

# Define your messages
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Explain what Rust is in one sentence."}
]

# Make a completion request
response = completion(
    model="openai/gpt-3.5-turbo",
    messages=messages,
    temperature=0.7,
    max_tokens=100
)

# Access the response
print(response["choices"][0]["message"]["content"])
print(f"Tokens used: {response['usage']['total_tokens']}")

Streaming Responses

For real-time streaming of responses:

from ritellm import completion

messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Write a short poem about Rust."}
]

# Enable streaming
response = completion(
    model="openai/gpt-3.5-turbo",
    messages=messages,
    stream=True
)

# Stream the response
for chunk in response:
    if "choices" in chunk and len(chunk["choices"]) > 0:
        content = chunk["choices"][0]["delta"].get("content", "")
        if content:
            print(content, end="", flush=True)

With Weave Tracing

RiteLLM has first-class support for Weave, enabling automatic tracing and monitoring of your LLM calls:

import weave
from ritellm import completion

# Initialize Weave
weave.init(project_name="my-llm-project")

# Wrap completion with Weave's op decorator for automatic tracing
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is the capital of France?"}
]

response = weave.op(completion)(
    model="openai/gpt-3.5-turbo",
    messages=messages,
    temperature=0.7
)

# Your calls are now automatically traced in Weave!

🙏 Gratitude

ritellm is highly inspired by litellm and its simple API design.

Made with ❤️ and 🦀

Project details


Download files

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

Source Distribution

ritellm-0.1.7.tar.gz (188.1 kB view details)

Uploaded Source

Built Distributions

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

ritellm-0.1.7-cp313-cp313-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ritellm-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

ritellm-0.1.7-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

ritellm-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file ritellm-0.1.7.tar.gz.

File metadata

  • Download URL: ritellm-0.1.7.tar.gz
  • Upload date:
  • Size: 188.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ritellm-0.1.7.tar.gz
Algorithm Hash digest
SHA256 459c7764ad948b45643778cc54da08aa3bb5df0ec1ccea721e054bb16444918d
MD5 99ccad80248eb9b2ee3f74a14fa59db9
BLAKE2b-256 2589c20b0210c559c2acee329c35ec7e9f46539c96e087938b7046ab7b0c0f80

See more details on using hashes here.

Provenance

The following attestation bundles were made for ritellm-0.1.7.tar.gz:

Publisher: publish-to-pypi.yml on soumik12345/ritellm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ritellm-0.1.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ritellm-0.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e39afe91b7b9d43b973182cc8b17f428c5c9f43e9fedb8b66e06ed4e7e0d4eec
MD5 26d8ae835f3b0e684d6becddd432d47d
BLAKE2b-256 21aefcc9f17754c0a491ee3f826cd49e6b7a7a2c3ec67802afb3e5d5a05a5031

See more details on using hashes here.

Provenance

The following attestation bundles were made for ritellm-0.1.7-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish-to-pypi.yml on soumik12345/ritellm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ritellm-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ritellm-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ddd356284875552e43121ed23641ac43ad3e160cd4822c4362436f5d52a0c5c0
MD5 176b5021bc6f5ebd806c7318fb4987b2
BLAKE2b-256 82c024815fd1fd2640fde43be23b942dcd7a2ade8def5fca432d3d2e907ad25f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ritellm-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: publish-to-pypi.yml on soumik12345/ritellm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ritellm-0.1.7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ritellm-0.1.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 1.6 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ritellm-0.1.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8d93da6c69104309de66591354643d48ba8315c09e732408e7e7c39cc4f4a7e0
MD5 5ceb4179723ad67e024ba1389db0f1c9
BLAKE2b-256 ff84fa55b12adac76a5ac37460666465d21fefc51e374a8de8f6d3ac6e9c8502

See more details on using hashes here.

Provenance

The following attestation bundles were made for ritellm-0.1.7-cp39-cp39-win_amd64.whl:

Publisher: publish-to-pypi.yml on soumik12345/ritellm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ritellm-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ritellm-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21594b11024c9ce824ad86d07f86ff08685f93a41ae069834ac251288dd19e5c
MD5 7d6915877136005fe9f4ff4982a06ca6
BLAKE2b-256 f05385f1ec2646ba4f30d0c316f8bbbca45ceaadd5424c540a3ee560d7793408

See more details on using hashes here.

Provenance

The following attestation bundles were made for ritellm-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-to-pypi.yml on soumik12345/ritellm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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