Skip to main content

Production-grade LLM client for Python - 100+ providers, 11,000+ models. Rust-powered.

Project description

LLMKit Python

The production-grade LLM client for Python. Native Rust performance with a Pythonic API.

PyPI Python License

Why LLMKit?

  • Rust Core — Native performance, memory safety, no GIL limitations
  • 100+ Providers — OpenAI, Anthropic, Google, AWS Bedrock, Azure, Groq, and more
  • 11,000+ Models — Built-in registry with pricing and capabilities
  • Prompt Caching — Save up to 90% on API costs with native caching support
  • Extended Thinking — Unified reasoning API across 5 providers
  • Production Ready — No memory leaks, no worker restarts, runs forever

Installation

pip install llmkit-python

Quick Start

from llmkit import LLMKitClient, CompletionRequest, Message

# Create client from environment variables
client = LLMKitClient.from_env()

# Make a completion request
response = client.complete(CompletionRequest(
    model="anthropic/claude-sonnet-4-20250514",
    messages=[Message.user("Hello!")]
))
print(response.text_content())

Async Support

from llmkit import AsyncLLMKitClient, CompletionRequest, Message

async def main():
    client = AsyncLLMKitClient.from_env()
    response = await client.complete(CompletionRequest(
        model="openai/gpt-4o",
        messages=[Message.user("Hello!")]
    ))
    print(response.text_content())

Streaming

# Sync streaming
for chunk in client.complete_stream(request):
    if chunk.text:
        print(chunk.text, end="", flush=True)

# Async streaming
async for chunk in await async_client.complete_stream(request):
    if chunk.text:
        print(chunk.text, end="", flush=True)

Tool Calling

from llmkit import ToolBuilder

# Build tools with fluent API
weather_tool = ToolBuilder("get_weather") \
    .description("Get current weather for a location") \
    .string_param("city", "City name", required=True) \
    .enum_param("unit", "Temperature unit", ["celsius", "fahrenheit"]) \
    .build()

request = CompletionRequest(
    model="anthropic/claude-sonnet-4-20250514",
    messages=[Message.user("What's the weather in Tokyo?")]
).with_tools([weather_tool])

response = client.complete(request)
for tool_call in response.tool_calls():
    print(f"Call {tool_call.name} with {tool_call.arguments}")

Prompt Caching

Save up to 90% on repeated prompts:

# Large system prompts are automatically cached
request = CompletionRequest(
    model="anthropic/claude-sonnet-4-20250514",
    messages=[
        Message.system(large_system_prompt),  # Cached after first call
        Message.user("Question 1")
    ]
).with_cache()

# Subsequent calls reuse the cached system prompt
response = client.complete(request)
print(f"Cache savings: {response.usage.cache_read_tokens} tokens")

Extended Thinking

Unified reasoning across Anthropic, OpenAI, Google, DeepSeek, and OpenRouter:

request = CompletionRequest(
    model="anthropic/claude-sonnet-4-20250514",
    messages=[Message.user("Solve this step by step: ...")]
).with_thinking(budget_tokens=10000)

response = client.complete(request)
print("Reasoning:", response.thinking_content())
print("Answer:", response.text_content())

Model Registry

11,000+ models with pricing and capabilities — no API calls needed:

from llmkit import get_model_info, get_models_by_provider, get_models_with_capability

# Get model details instantly
info = get_model_info("anthropic/claude-sonnet-4-20250514")
print(f"Context: {info.context_window:,} tokens")
print(f"Input: ${info.input_price}/1M tokens")
print(f"Output: ${info.output_price}/1M tokens")

# Find models by provider
anthropic_models = get_models_by_provider("anthropic")

# Find models with specific capabilities
vision_models = get_models_with_capability(vision=True)

Features

Feature Status
Chat Completions Supported
Streaming Supported
Tool Calling Supported
Structured Output Supported
Extended Thinking Supported
Prompt Caching Supported
Vision/Images Supported
Embeddings Supported
Image Generation Supported
Audio STT/TTS Supported
Video Generation Supported

Documentation

License

MIT OR Apache-2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

llmkit_python-0.1.1-cp39-abi3-win_amd64.whl (9.6 MB view details)

Uploaded CPython 3.9+Windows x86-64

llmkit_python-0.1.1-cp39-abi3-manylinux_2_39_x86_64.whl (9.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.39+ x86-64

llmkit_python-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (9.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

llmkit_python-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl (9.5 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file llmkit_python-0.1.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for llmkit_python-0.1.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9c49467b79da1916d7128358bf7ddd8877205ea50d35ef924190ffd428ea460f
MD5 d3d987f7d4ac5be3935a9e2026833e7a
BLAKE2b-256 5d9ed9b0a8b61e93864fcea7ab7e6a9d20925954f2c33058e87f8c4872e37cef

See more details on using hashes here.

File details

Details for the file llmkit_python-0.1.1-cp39-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for llmkit_python-0.1.1-cp39-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 743855b66a2e83e78f81ab9f405b2e212541c75deb9dc2973fbd666797c5a05f
MD5 cbe0ce91bd41b31235caa036132cc197
BLAKE2b-256 870cbf982922bcdec38799d1f6e56680789514e5172f186d55729b94cc439a75

See more details on using hashes here.

File details

Details for the file llmkit_python-0.1.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for llmkit_python-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c389d0baeacb9956aac620b183a282014fb9127e1749070ee3e04185d32d9e98
MD5 5f8e4e36f0de777e97a2b028e1a8e3c8
BLAKE2b-256 8bcc0f5039a7c90e82d32d1d7f73273775c66298d33aac11813782a9df16a8ab

See more details on using hashes here.

File details

Details for the file llmkit_python-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for llmkit_python-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ef2198f071db9fbf58e47263214420f93813024de5d6008a23551591f4380647
MD5 c2568a7246b0d25c423e646700d9be10
BLAKE2b-256 02bbf1bfd896b6cd439969e2df9c4bc823962ec16f48d1898557ef8ab7be2361

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