Skip to content

Home

LLM Client Logo

Infografik

The LLM Client is a versatile Python tool that provides a unified interface for accessing various AI providers such as OpenAI, Groq, Google Gemini, and Ollama. The software features automatic API detection, which flexibly falls back to a local Ollama instance if keys are missing. Technical highlights include precise token counting, full async support, and the ability to switch dynamically between different providers during runtime. Thanks to a clean architecture based on design patterns, the library also enables advanced tool calling and the upload of a wide variety of file formats. The library is easy to use compared to more complex frameworks and offers seamless integration into environments such as Google Colab.

graph TD subgraph "One Code" CODE["client = LLMClient()
response = client.chat_completion(messages)"] end subgraph "Four APIs" OPENAI[OpenAI] GROQ[Groq] GEMINI[Gemini] OLLAMA[Ollama
Local/Cloud] end subgraph "Many Possibilities" SWITCH[πŸ”„ Switch Provider] TOKENS[πŸ“Š Monitor Costs] ASYNC[⚑ Async/Await] STREAM[🌊 Streaming] FILES[πŸ“Ž Send Files] end CODE --> OPENAI CODE --> GROQ CODE --> GEMINI CODE --> OLLAMA GEMINI -.-> ASYNC GEMINI -.-> SWITCH GEMINI -.-> TOKENS GEMINI -.-> STREAM GEMINI -.-> FILES classDef codeClass fill:#e1f5ff,stroke:#01579b,stroke-width:3px,color:#000 classDef apiClass fill:#e8f5e green,stroke:#1b5e20,stroke-width:2px,color:#000 classDef featureClass fill:#fff9c4,stroke:#f57f17,stroke-width:2px,color:#000 class CODE codeClass class OPENAI,GROQ,GEMINI,OLLAMA apiClass class SWITCH,TOKENS,ASYNC,STREAM,FILES featureClass

πŸš€ FeaturesΒΆ

Core FeaturesΒΆ

  • πŸ” Automatic API Detection - Uses available API keys or falls back to Ollama
  • βš™οΈ Unified Interface - One method for all LLM backends
  • πŸ”„ Dynamic Provider Switching - Switch between APIs at runtime without creating a new object
  • 🧩 Flexible Configuration - Model, temperature, tokens freely adjustable
  • πŸ” Google Colab Support - Automatic loading of secrets from userdata
  • πŸ“¦ Zero-Config - Works out-of-the-box with Ollama
  • πŸ“Š Token counting with tiktoken - Precise token counting for cost management
  • ⚑ Full async support - Async/await for all providers
  • πŸ“ Configuration files - YAML/JSON configuration for multi-provider setups

ArchitectureΒΆ

  • πŸ—οΈ Strategy Pattern - Clean architecture with provider classes
  • 🏭 Factory Pattern - Central provider creation and management

🚦 Quick Start¢

from llm_client import LLMClient

# Automatic API detection
client = LLMClient()

messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Explain machine learning in one sentence."}
]

response = client.chat_completion(messages)
print(response)

πŸ“– DocumentationΒΆ

Getting StartedΒΆ

FeaturesΒΆ

Further ResourcesΒΆ