Socket
Book a DemoInstallSign in
Socket

llmswap

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

llmswap

Universal LLM SDK with Tool Calling: Enable ANY LLM to access YOUR data/APIs. Multi-provider (Anthropic, OpenAI, Gemini, Groq, xAI) with automatic format conversion. Features: universal tool calling, workspace memory, cost optimization, provider switching, zero vendor lock-in. Build AI agents, chatbots, data assistants with one SDK.

pipPyPI
Version
5.2.2
Maintainers
1

llmswap: Universal LLM SDK That Just Works

PyPI version PyPI Downloads Homebrew Python 3.8+ License: MIT

Ship AI Features in Minutes, Not Weeks

One SDK. 11 providers. Zero vendor lock-in.

Stop wrestling with complex frameworks. llmswap gives you tool calling, caching, and multi-provider support in 10 lines of code. Used by developers shipping real products.

πŸ“š Documentation: llmswap.org | ⚑ CLI Reference: CLI Docs | 🐍 SDK Guide: SDK Docs

πŸ†• NEW in v5.2.0: Universal Tool Calling

Enable LLMs to access YOUR data and systems - Define tools once, works across ALL providers.

from llmswap import LLMClient, Tool

# Define tool to access YOUR weather API
weather = Tool(
    name="get_weather",
    description="Get real-time weather data",
    parameters={"city": {"type": "string"}},
    required=["city"]
)

# Works with ANY provider - Anthropic, OpenAI, Gemini, Groq, xAI
client = LLMClient(provider="anthropic")
response = client.chat("What's the weather in Tokyo?", tools=[weather])

# LLM calls YOUR function β†’ you return data β†’ LLM gives natural response

Real-World Use Cases:

  • 🌦️ Give LLM access to YOUR weather API for real-time data
  • πŸ’Ύ Let LLM query YOUR database for customer information
  • πŸ›’ Enable LLM to search YOUR product catalog for shopping assistance
  • πŸ”§ Connect LLM to YOUR systems and APIs

Works with: Anthropic, OpenAI, Groq, Gemini, xAI | Quick Start Guide β†’ | Full Docs β†’

⚑ Quick Start (30 seconds)

# Install
pip install llmswap

# or Homebrew
brew tap llmswap/tap && brew install llmswap

# Create your first workspace
cd ~/my-project
llmswap workspace init

# Chat with AI that remembers everything
llmswap chat "Help me with Flask routing"
# AI has full project context + all past learnings!

# πŸ†• Compare models visually (optional)
pip install llmswap[web]
llmswap web  # Opens browser - compare GPT-4 vs Claude vs Gemini

πŸ†• Use Any Model from Any Provider! New model just launched? Use it immediately. llmswap's pass-through architecture means GPT-5, Claude Opus 4, Gemini 2.5 Pro work the day they release. Currently supports 10 providers (OpenAI, Anthropic, Gemini, Cohere, Perplexity, IBM watsonx, Groq, Ollama, xAI Grok, Sarvam AI).

βœ… Battle-Tested with LMArena Top Models: All 10 providers tested and validated with top-rated models from LMArena leaderboard. From Grok-4 (xAI's flagship) to Claude Sonnet 4.5 (best coding model) to Gemini 2.0 Flash Exp - every model in our defaults is production-validated and arena-tested for real-world use.

The First AI Tool with Project Memory & Learning Journals - LLMSwap v5.1.0 introduces revolutionary workspace system that remembers your learning journey across projects. Build apps without vendor lock-in (SDK) or use from terminal (CLI). Works with your existing subscriptions: Claude, OpenAI, Gemini, Cohere, Perplexity, IBM watsonx, Groq, Ollama, xAI Grok, Sarvam AI (10 providers). Use any model from your provider - even ones released tomorrow. Pass-through architecture means GPT-5, Gemini 2.5 Pro, Claude Opus 4? They work the day they launch.

🎯 Solve These Common Problems:

  • ❌ "I need multiple second brains for different aspects of my life" πŸ†•
  • ❌ "AI strays over time, I need to re-steer it constantly" πŸ†•
  • ❌ "I keep explaining the same context to AI over and over"
  • ❌ "AI forgets what I learned yesterday"
  • ❌ "I lose track of architecture decisions across projects"
  • ❌ "Context switching between projects is exhausting"
  • ❌ "I want AI to understand my specific codebase, not generic answers"

βœ… llmswap v5.1.0 Solves All These:

  • βœ… Multiple independent "second brains" per project/life aspect πŸ†•
  • βœ… Persistent context prevents AI from straying πŸ†•
  • βœ… Per-project workspaces that persist context across sessions
  • βœ… Auto-tracked learning journals - never forget what you learned
  • βœ… Architecture decision logs - all your technical decisions documented
  • βœ… Zero context switching - AI loads the right project automatically
  • βœ… Project-aware AI - mentor understands YOUR specific tech stack

Why Developers Choose llmswap

βœ… 10 Lines to Production - Not 1000 like LangChain βœ… Automatic Fallback - Never down. Switches providers if one fails βœ… 50-90% Cost Savings - Built-in caching. Same query = FREE βœ… Workspace Memory - Your AI remembers your project context βœ… Universal Tool Calling - Define once, works everywhere (NEW v5.2.0) βœ… CLI + SDK - Code AND terminal. Your choice βœ… Zero Lock-in - Switch from OpenAI to Claude in 1 line

Built for Speed:

  • πŸš€ Hackathons - Ship in hours
  • πŸ’‘ MVPs - Validate ideas fast
  • πŸ“± Production Apps - Scale as you grow
  • 🎯 Real Projects - Trusted by developers worldwide

v5.1.0: Revolutionary AI mentorship with project memory, workspace-aware context, auto-tracked learning journals, and persistent mentor relationships. The first AI tool that truly remembers your learning journey across projects.

NEW in v5.2.0:

  • πŸ› οΈ Universal Tool Calling - Enable LLMs to use YOUR custom functions across all providers
  • πŸ”§ 5 Providers Supported - Anthropic, OpenAI, Groq, Gemini, xAI with automatic format conversion
  • πŸ“– Complete Documentation - Full guides, examples, and real-world use cases
  • βœ… 100% Backward Compatible - All existing features work without changes

v5.1.6:

  • 🌐 Web UI - Compare 20+ models side-by-side in beautiful browser interface & learn prompting techniques
  • πŸ“Š Visual Comparison - Live streaming results with speed badges (⚑πŸ₯ˆπŸ₯‰), cost charts, efficiency metrics
  • πŸ’° Cost Optimizer - See exact costs across providers, find cheapest model for your use case
  • 🎨 Markdown + Code Highlighting - Syntax-highlighted code blocks with individual copy buttons
  • πŸ’Ύ Smart Preferences - Remembers your favorite models via localStorage
  • πŸ“ˆ Real-time Metrics - Tokens/sec efficiency, response length indicators, actual API token counts

NEW in v5.1.0:

  • 🧠 Workspace Memory - Per-project context that persists across sessions
  • πŸ“š Auto-Learning Journal - Automatically tracks what you learn in each project
  • 🎯 Context-Aware Mentorship - AI mentor understands your project and past learnings
  • πŸ“– Architecture Decision Log - Document and remember key technical decisions
  • πŸ”„ Cross-Project Intelligence - Learn patterns from one project, apply to another
  • πŸ’‘ Proactive Learning - AI suggests next topics based on your progress
  • πŸ—‚οΈ Project Knowledge Base - Custom prompt library per workspace

🧠 Finally: An Elegant Solution for Multiple Second Brains

The Problem Industry Leaders Can't Solve:

"I still haven't found an elegant solution to the fact that I need several second brains for the various aspects of my life, each with different styles and contexts." - Industry feedback

The LLMSwap Solution: Workspace System

Each aspect of your life gets its own "brain" with independent memory:

  • πŸ’Ό Work Projects - ~/work/api-platform - Enterprise patterns, team conventions
  • πŸ“š Learning - ~/learning/rust - Your learning journey, struggles, progress
  • πŸš€ Side Projects - ~/personal/automation - Personal preferences, experiments
  • 🌐 Open Source - ~/oss/django - Community patterns, contribution history

What Makes It "Elegant":

  • βœ… Zero configuration - just cd to project directory
  • βœ… Auto-switching - AI loads the right "brain" automatically
  • βœ… No context bleed - work knowledge stays separate from personal
  • βœ… Persistent memory - each brain remembers across sessions
  • βœ… Independent personas - different teaching style per project if you want

Stop Re-Explaining Context. Start Building.

🎯 Transform AI Into Your Personal Mentor with Project Memory

Inspired by Eklavya - the legendary self-taught archer who learned from dedication and the right guidance - LLMSwap transforms any AI provider into a personalized mentor that adapts to your learning style and remembers your journey.

The Challenge: Developers struggle to learn effectively from AI because:

  • πŸ”΄ Responses are generic, lack personality, and don't adapt to individual needs
  • πŸ”΄ AI loses context between sessions - you repeat the same explanations
  • πŸ”΄ No learning history - AI doesn't know what you already learned
  • πŸ”΄ Project context is lost - AI doesn't understand your codebase

LLMSwap's Solution v5.1.0: Choose your mentorship style, initialize a workspace, and ANY AI provider becomes your personalized guide that remembers everything:

# πŸ†• v5.1.0: Initialize workspace for your project
cd ~/my-flask-app
llmswap workspace init
# Creates .llmswap/ with context.md, learnings.md, decisions.md

# Now your AI mentor KNOWS your project
llmswap chat --mentor guru --alias "Guruji"
# Mentor has full context: your tech stack, past learnings, decisions made

# πŸ†• Auto-tracked learning journal
# Every conversation automatically saves key learnings
llmswap workspace journal
# View everything you've learned in this project

# πŸ†• Architecture decision log
llmswap workspace decisions
# See all technical decisions documented automatically

# View all your workspaces
llmswap workspace list

# Get wisdom and deep insights from a patient teacher
llmswap chat --mentor guru --alias "Guruji"

# High-energy motivation when you're stuck
llmswap ask "How do I debug this?" --mentor coach

# Collaborative peer learning for exploring ideas
llmswap chat --mentor friend --alias "CodeBuddy"

# Question-based learning for critical thinking
llmswap ask "Explain REST APIs" --mentor socrates

# πŸ†• Use Claude Sonnet 4.5 - Best coding model
llmswap chat --provider anthropic --model claude-sonnet-4-5
# Or set as default in config for all queries

πŸ”„ Rotate Personas to Expose Blind Spots

Industry Insight: "Rotate personas: mentor, skeptic, investor, end-user. Each lens exposes blind spots differently."

Use Case: Reviewing API Design

# Round 1: Long-term wisdom
llmswap chat --mentor guru "Design API for multi-tenant SaaS"
# Catches: scalability, technical debt, maintenance

# Round 2: Critical questions
llmswap chat --mentor socrates "Review this API design"
# Catches: assumptions, alternatives, edge cases

# Round 3: Practical execution
llmswap chat --mentor coach "What's the fastest path to v1?"
# Catches: over-engineering, paralysis by analysis

Same project context. Different perspectives. Complete understanding.

What Makes v5.1.0 Revolutionary:

  • 🧠 Works with ANY provider - Transform Claude, GPT-4, or Gemini into your mentor
  • 🎭 6 Teaching Personas - Guru, Coach, Friend, Socrates, Professor, Tutor
  • πŸ“Š Project Memory - Per-project context that persists across sessions ⭐ NEW
  • πŸ“š Auto-Learning Journal - Automatically tracks what you learn ⭐ NEW
  • πŸ“– Decision Tracking - Documents architecture decisions ⭐ NEW
  • πŸŽ“ Age-Appropriate - Explanations tailored to your level (--age 10, --age 25, etc.)
  • πŸ’° Cost Optimized - Use cheaper providers for learning, premium for complex problems
  • πŸ”„ Workspace Detection - Automatically loads project context ⭐ NEW

Traditional AI tools give you answers. LLMSwap v5.1.0 gives you a personalized learning journey that REMEMBERS.

πŸ† Production-Validated with LMArena Top Models

Every model in LLMSwap's defaults comes from LMArena's top performers:

All 10 providers ship with carefully selected default models based on LMArena rankings and real-world production testing. We track arena performance and update defaults to ensure you're always using validated, battle-tested models.

ProviderDefault ModelArena StatusWhy We Chose It
Anthropicclaude-sonnet-4-5#1 CodingBest coding model in the world (Sept 2025)
xAIgrok-4-0709Top 5 OverallAdvanced reasoning, real-time data access
Geminigemini-2.0-flash-expTop 10Lightning-fast, multimodal, cutting-edge
OpenAIgpt-4o-miniCost LeaderBest price/performance ratio
Coherecommand-r-08-2024Top RAGEnterprise-grade retrieval-augmented generation
PerplexitysonarWeb SearchReal-time web-connected AI with citations
Groqllama-3.1-8b-instantSpeed King840+ tokens/second ultra-fast inference
Sarvamsarvam-mMultilingual24B params, best for 10 Indian languages
Watsonxgranite-3-8b-instructEnterpriseIBM's production-grade AI for business
Ollamagranite-code:8bLocal AIPrivacy-first, runs on your hardware

βœ… Battle-tested with real API calls - Every provider validated in production, not simulated tests.

βœ… Weekly model updates - We monitor LMArena rankings and deprecation notices to keep defaults current.

βœ… Zero lock-in - Don't like our defaults? Override with any model: LLMClient(model="gpt-5") or llmswap config set provider.models.openai gpt-5

πŸ”“ Use Any Model Your Provider Supports (Zero-Wait Model Support)

Here's something cool: LLMSwap doesn't restrict which models you can use. When GPT-5 or Gemini 2.5 Pro drops tomorrow, you can start using it immediately. No waiting for us to update anything.

How? We use pass-through architecture. Whatever model name you pass goes directly to your provider's API. We don't gatekeep.

CLI Examples:

# Use any OpenAI model (even ones that don't exist yet)
llmswap chat --provider openai --model gpt-5
llmswap chat --provider openai --model o3-mini

# Use any Anthropic model
llmswap chat --provider anthropic --model claude-opus-4
llmswap chat --provider anthropic --model claude-sonnet-4-5

# Use any Gemini model
llmswap chat --provider gemini --model gemini-2-5-pro
llmswap chat --provider gemini --model gemini-ultra-2

# Set as default so you don't have to type it every time
llmswap config set provider.models.openai gpt-5
llmswap config set provider.models.anthropic claude-opus-4

Python SDK:

from llmswap import LLMClient

# Use whatever model your provider offers
client = LLMClient(provider="openai", model="gpt-5")
client = LLMClient(provider="anthropic", model="claude-opus-4")
client = LLMClient(provider="gemini", model="gemini-2-5-pro")

# Model just released? Use it right now
client = LLMClient(provider="openai", model="gpt-6")  # works!

The point: You're not limited to what we've documented. If your provider supports it, llmswap supports it.

πŸ†š LLMSwap vs Single-Provider Tools

For Python Developers Building Apps:

Your NeedSingle-Provider SDKsLLMSwap SDK
Build chatbot/appImport openai library (locked in)Import llmswap (works with any provider)
Switch providersRewrite all API callsChange 1 line: provider="anthropic"
Try different modelsSign up, new SDK, refactor codeJust change config, same code
Use new modelsWait for SDK updateWorks immediately (pass-through)
Cost optimizationManual implementationBuilt-in caching (50-90% savings)
Use multiple providersMaintain separate codebasesOne codebase, switch dynamically

For Developers Using Terminal:

Your NeedVendor CLIsLLMSwap CLI
Have Claude subscriptionInstall Claude Code (Claude only)Use llmswap (works with Claude)
Have OpenAI subscriptionBuild your own scriptsUse llmswap (works with OpenAI)
Have multiple subscriptionsInstall 3+ different CLIsOne CLI for all subscriptions
New model launchesWait for CLI updateUse it same day (pass-through)
Want AI to teach youNot availableBuilt-in Eklavya mentorship
Switch providers mid-chatCan't - locked in/switch anthropic command

The Bottom Line:

  • Building an app? Use llmswap SDK - no vendor lock-in
  • Using terminal? Use llmswap CLI - works with your existing subscriptions
  • Both? Perfect - it's the same tool!
# πŸ†• NEW v5.1.0: Workspace System - Project Memory That Persists
llmswap workspace init
# Creates .llmswap/ directory with:
#   - workspace.json (project metadata)
#   - context.md (editable project description)
#   - learnings.md (auto-tracked learning journal)
#   - decisions.md (architecture decision log)

llmswap workspace list                    # View all your workspaces
llmswap workspace info                    # Show current workspace statistics
llmswap workspace journal                 # View learning journal
llmswap workspace decisions               # View decision log
llmswap workspace context                 # Edit project context

# πŸ†• NEW v5.1.0: Context-Aware Mentorship
# AI mentor automatically loads project context, past learnings, and decisions
llmswap chat
# Mentor knows: your tech stack, what you've learned, decisions made

# πŸ†• NEW v5.0: Age-Appropriate AI Explanations
llmswap ask "What is Docker?" --age 10
# Output: "Docker is like a magic lunch box! πŸ₯ͺ When your mom packs..."

llmswap ask "What is blockchain?" --audience "business owner"
# Output: "Think of blockchain like your business ledger system..."

# πŸ†• NEW v5.0: Teaching Personas & Personalization  
llmswap ask "Explain Python classes" --teach --mentor developer --alias "Sarah"
# Output: "[Sarah - Senior Developer]: Here's how we handle classes in production..."

# πŸ†• NEW v5.0: Conversational Chat with Provider Switching
llmswap chat --age 25 --mentor tutor
# In chat: /switch anthropic  # Switch mid-conversation
# In chat: /provider         # See current provider
# Commands: /help, /switch, /clear, /stats, /quit

# πŸ†• NEW v5.0: Provider Management & Configuration
llmswap providers                    # View all providers and their status
llmswap config set provider.models.cohere command-r-plus-08-2024
llmswap config set provider.default anthropic
llmswap config show

# Code Generation (GitHub Copilot CLI Alternative)
llmswap generate "sort files by size in reverse order"
# Output: du -sh * | sort -hr

llmswap generate "Python function to read JSON with error handling" --language python
# Output: Complete Python function with try/catch blocks

# Advanced Log Analysis with AI
llmswap logs --analyze /var/log/app.log --since "2h ago"
llmswap logs --request-id REQ-12345 --correlate

# Code Review & Debugging
llmswap review app.py --focus security
llmswap debug --error "IndexError: list index out of range"
# ❌ Problem: Vendor Lock-in
import openai  # Locked to OpenAI forever
client = openai.Client(api_key="sk-...")
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello"}]
)
# To switch to Claude? Rewrite everything.

# βœ… Solution: llmswap SDK - Universal Interface
from llmswap import LLMClient

# Works with any provider you're subscribed to
client = LLMClient()  # Auto-detects from env vars
response = client.query("Hello")

# Want Claude instead? Just change provider:
client = LLMClient(provider="anthropic")  # That's it!

# Want to try Gemini? 
client = LLMClient(provider="gemini")  # Same code, different provider

# Built-in cost optimization:
# - Automatic response caching (50-90% savings)
# - Provider cost comparison
# - Smart provider selection based on query type

πŸ†• v5.1.0: Workspace System - Real-World Scenarios

🎯 Scenario 1: New Developer Learning Flask

Problem: Junior developer learning Flask keeps asking AI the same questions because AI forgets previous conversations.

Solution with llmswap v5.1.0:

cd ~/my-first-flask-app
llmswap workspace init --name "Learning Flask"

# Day 1: Learn about routing
llmswap chat --mentor professor
"How do Flask routes work?"
# AI explains. Learning auto-saved to learnings.md

# Day 2: Same workspace, AI remembers!
llmswap chat
"Can I use decorators for authentication?"
# AI response: "Building on what you learned about routes yesterday..."
# No need to re-explain basics!

# View your learning journey
llmswap workspace journal
# See: Day 1 - Routes, Day 2 - Authentication, etc.

Result: 60% faster learning because AI builds on previous knowledge instead of repeating basics.

🏒 Scenario 2: Team Onboarding on Legacy Project

Problem: New team member joins 2-year-old codebase. Spends weeks understanding architecture decisions.

Solution with llmswap v5.1.0:

cd ~/legacy-ecommerce-app
llmswap workspace init

# Edit context.md with project overview
llmswap workspace context
# Add: Tech stack, key components, known issues

# Ask questions - AI has full context
llmswap ask "Why did we choose MongoDB over PostgreSQL?" --mentor guru
# AI suggests checking decisions.md
# If documented: "According to your decision log from 2023-05..."
# If not: AI helps document it now

llmswap workspace decisions
# See all past architectural decisions in one place

Result: Onboarding time reduced from 3 weeks to 1 week.

πŸ’Ό Scenario 3: Freelancer Managing Multiple Projects

Problem: Freelancer switches between 5 client projects daily. Context switching is exhausting.

Solution with llmswap v5.1.0:

# Morning: Client A's React project
cd ~/client-a-dashboard
llmswap chat
# AI loads: React patterns you learned, components built, state management decisions

# Afternoon: Client B's Python API
cd ~/client-b-api
llmswap chat
# AI switches context: Python best practices, API design decisions, database schema

# List all projects
llmswap workspace list
# See: 5 workspaces, each with independent context and learnings

# Each workspace has separate:
# - Learning journal (React patterns vs Python patterns)
# - Decision log (frontend vs backend decisions)
# - Project context (different tech stacks)

Result: Zero mental overhead for context switching. AI handles it automatically.

πŸŽ“ Scenario 4: Learning Journey Across Technologies

Problem: Developer learning full-stack wants to track progress across frontend, backend, DevOps.

Solution with llmswap v5.1.0:

# Frontend project
cd ~/react-app
llmswap workspace init --name "React Learning"
llmswap chat --mentor tutor
# Learn: Hooks, State, Components
# All auto-tracked in learnings.md

# Backend project
cd ~/python-api
llmswap workspace init --name "Python API"
llmswap chat --mentor tutor
# Learn: FastAPI, SQLAlchemy, Testing
# Separate learning journal

# View all learning across projects
llmswap workspace list
# See progress in each area

# Each workspace shows:
# - Total queries
# - Learnings count
# - Last accessed

Result: Complete visibility into learning journey across all technologies.

πŸš€ Scenario 5: Open Source Contributor

Problem: Contributing to 3 different OSS projects. Each has different conventions, patterns, testing approaches.

Solution with llmswap v5.1.0:

# Project 1: Django
cd ~/django-oss
llmswap workspace init
# Document in context.md: Coding style, PR process, testing patterns

# Project 2: FastAPI
cd ~/fastapi-oss
llmswap workspace init
# Different conventions, different patterns

# Ask project-specific questions
cd ~/django-oss
llmswap ask "How should I write tests here?"
# AI knows: This project uses pytest with Django TestCase

cd ~/fastapi-oss
llmswap ask "How should I write tests here?"
# AI knows: This project uses pytest with async fixtures

# Each workspace maintains separate:
# - Testing patterns learned
# - Code review feedback
# - Architecture understanding

Result: Contribute confidently to multiple projects without mixing up conventions.

πŸ’‘ Real-World Use Cases (v5.0 Features)

πŸ“š Learning & Skill Development

# Junior developer learning system design
llmswap chat --mentor professor --alias "Dr. Smith"
"Explain microservices architecture"
# Response adapts to teaching style with examples and deep explanations

# Career switcher exploring new domains
llmswap ask "What is Kubernetes?" --age 25 --audience "beginner"
# Age-appropriate explanation without assuming prior DevOps knowledge

πŸš€ Professional Development

# Get different perspectives on technical decisions
llmswap ask "Should I use MongoDB or PostgreSQL?" --mentor guru
# Wisdom-based response considering trade-offs and bigger picture

llmswap ask "Should I use MongoDB or PostgreSQL?" --mentor developer
# Practical engineering perspective with production experience

πŸ’Ό Team Collaboration

# Explain technical concepts to non-technical stakeholders
llmswap ask "Explain our API architecture" --audience "business owner"
# Business-friendly explanation without jargon

# Onboard new team members
llmswap chat --mentor friend --alias "TeamBuddy"
# Collaborative, approachable learning environment

🎭 Same Question, Different Perspectives

Watch how the SAME question gets tailored responses based on your role:

# As a Developer: Implementation focus
llmswap ask "Explain Model Context Protocol (MCP)" --audience developer

Response: "MCP is a standardized protocol for connecting AI models to external 
data sources and tools. Unlike traditional chatbots that bundle everything into 
one monolithic system, MCP uses a client-server architecture:

- Server: Exposes tools, resources, and prompts via standard interface
- Client: Your AI application that consumes these capabilities
- Transport: JSON-RPC over stdio/HTTP

Key difference from older chatbots:
OLD: Hardcoded integrations, tight coupling, monolithic deployment
NEW: Pluggable architecture, loose coupling, independent tool servers

Code example:
from mcp import Server
server = Server("my-tools")
@server.tool()
def get_weather(city: str): ..."

---

# As an Architect: System design focus  
llmswap ask "Explain Model Context Protocol (MCP)" --audience architect

Response: "MCP introduces a service-oriented architecture for AI systems, 
addressing key architectural concerns:

**System Architecture:**
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AI Client   │◄────►│ MCP Protocol │◄────►│ Tool Server β”‚
β”‚ (Claude App)β”‚      β”‚  (JSON-RPC)  β”‚      β”‚ (Resources) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

**Design Patterns:**
- Service Discovery: Dynamic capability negotiation
- Loose Coupling: Clients/servers evolve independently  
- Extensibility: Add new tools without modifying core
- Standardization: Uniform interface across tools

**vs Traditional Chatbots:**
- Monolithic β†’ Microservices for AI tools
- Static β†’ Dynamic capability loading
- Vendor lock-in β†’ Provider-agnostic standard

**Scalability:** Deploy tool servers independently, horizontal scaling per service"

---

# As a Business Leader: ROI and strategy focus
llmswap ask "Explain Model Context Protocol (MCP)" --audience "business leader"

Response: "Model Context Protocol (MCP) is like moving from custom-built 
integrations to standardized APIs - but for AI systems.

**Business Impact:**

1. **Reduced Integration Costs**
   - OLD: $50K-$100K per custom AI integration
   - NEW: Plug-and-play tools, 80% cost reduction
   - Time to market: Weeks instead of months

2. **Vendor Independence**  
   - Not locked to one AI provider
   - Switch between Claude, GPT-4, Gemini seamlessly
   - Negotiating power with vendors

3. **Reusable Components**
   - Build once, use across multiple AI applications
   - Internal tools become valuable assets
   - Ecosystem of third-party MCP tools

4. **Competitive Advantage**
   - Deploy AI features 10x faster than competitors
   - Respond quickly to market changes
   - Lower total cost of ownership

**vs Traditional Chatbots:** Traditional bots were closed systems requiring 
custom development for each feature. MCP creates an open ecosystem where your 
team (or partners) can extend capabilities without vendor dependencies.

**ROI Example:** A company saved $200K in integration costs and reduced 
deployment time from 6 months to 3 weeks using MCP architecture."

The Power: Same command, same AI provider, completely different responses tailored to what each role needs to know.

⚠️ Privacy & Usage Disclaimers

llmswap is an interface tool only - all AI interactions and billing are handled directly by your chosen providers.

πŸ”’ Context Privacy & Provider Switching

  • No context sharing: When switching providers mid-conversation, NO conversation history is transferred between providers
  • Fresh start: Each provider switch starts a completely new conversation thread
  • Legal compliance: This protects your privacy and complies with provider Terms of Service
  • Your control: You decide what each provider sees in their separate conversations

πŸ’° Cost Information

Cost estimates (~$X.XX estimated) are approximate based on public pricing and common tokenizers. Actual costs may differ. You are responsible for all provider costs and billing.

Legal Notice: llmswap provides estimates and interface functionality for convenience only. We are not responsible for billing differences, provider charges, pricing changes, or data handling by individual providers. Always verify costs with your provider's billing dashboard.

⚑ Get Started in 30 Seconds

# Add our tap and install
brew tap llmswap/tap
brew install llmswap

# Ready to use immediately!
llmswap --help

🐍 PyPI (All platforms)

pip install llmswap

Why Homebrew? No virtualenv needed, global access, automatic dependency management, and easier updates.

πŸš€ Quick Start with Workspaces (v5.1.0)

Complete Beginner's Guide - 3 Steps:

Step 1: Install llmswap

pip install llmswap
# or
brew install llmswap

Step 2: Set up API key (one provider is enough)

export ANTHROPIC_API_KEY="your-key-here"  # For Claude
# or
export OPENAI_API_KEY="your-key-here"     # For GPT-4
# or any other provider

Step 3: Initialize workspace in your project

cd ~/my-project
llmswap workspace init

# Start chatting - AI has full project context!
llmswap chat --mentor guru
# Ask anything about your project
# Learnings automatically tracked
# Decisions automatically documented

# View your learning journey
llmswap workspace journal

That's it! Your AI mentor now remembers everything about your project. πŸŽ‰

Without Workspace (Classic Mode)

# Works exactly like v5.0 - no workspace needed
llmswap ask "How do I deploy a Flask app?"
llmswap chat --mentor tutor
llmswap generate "Python function to read CSV"

πŸ“‹ Quick Reference - v5.1.0 Commands

πŸ†• Workspace Commands (NEW!)

CommandDescriptionExample
llmswap workspace initInitialize workspace in current directoryCreates .llmswap/ with context, learnings, decisions
llmswap workspace init --nameInitialize with custom project namellmswap workspace init --name "My API"
llmswap workspace infoShow current workspace statisticsDisplays queries, learnings, decisions count
llmswap workspace listList all registered workspacesShows all projects with llmswap workspaces
llmswap workspace journalView learning journalSee everything you've learned
llmswap workspace decisionsView architecture decision logSee all technical decisions
llmswap workspace contextEdit project contextOpens context.md in default editor

Provider & Config Commands (v5.0)

CommandDescriptionExample
llmswap providersView all providers and their statusShows configured/missing API keys
llmswap config set provider.models.<provider> <model>Update default model for any providerllmswap config set provider.models.cohere command-r-plus-08-2024
llmswap config listView current configurationShows all settings and models
/switch (in chat)Switch providers mid-conversationPrivacy-compliant provider switching
/provider (in chat)Show current provider and available optionsQuick status check

πŸ”§ First-Time Setup (v5.0.4 NEW!)

# First run automatically creates ~/.llmswap/config.yaml with defaults
llmswap ask "Hello world"
# Output: πŸ”§ Creating config file at ~/.llmswap/config.yaml
#         βœ… Default configuration created

# View all providers and their configuration status
llmswap providers

# Set up your API keys and start using
export ANTHROPIC_API_KEY="your-key-here"
llmswap ask "Explain Docker in simple terms"

πŸ’‘ Smart Defaults: llmswap comes pre-configured with sensible model defaults for all 8 providers. No configuration needed to get started!

from llmswap import LLMClient

# Works with any provider you have configured
client = LLMClient()  # Auto-detects from environment/config
response = client.query("Explain quantum computing in 50 words")
print(response.content)

🎯 Why LLMSwap v5.1.0 for AI Development?

FeatureLLMSwap v5.1.0Claude CodeCursor AIAiderLangChainDirect APIs
Project Memoryβœ… Workspace system❌ No memory❌ No memory❌ No memory❌ Manual❌ None
Learning Journalβœ… Auto-tracked❌ Not available❌ Not available❌ Not available❌ Manual❌ None
Context Awarenessβœ… Project-specific❌ Generic❌ Generic❌ Generic❌ Manual❌ None
AI Providersβœ… 8+ providers, instant switch❌ Claude only❌ Few providers❌ OpenAI only⚠️ 50+ complex setup❌ 1 per codebase
Conversational Modeβœ… Provider-native, allβœ… Claude onlyβœ… Limited❌ Not available⚠️ Manual setup❌ Not available
Memory Usageβœ… 99% reduction⚠️ Local storage⚠️ Local storage⚠️ Local storage❌ Heavy framework❌ Manual
Configurationβœ… Git-like, shareable⚠️ Basic settings⚠️ Basic settings⚠️ Basic settings❌ Complex files❌ None
Cost Analyticsβœ… Real-time tracking❌ No cost info❌ No cost info❌ No cost info❌ External tools❌ Manual
Provider Switchingβœ… Mid-conversation❌ Locked to Claude⚠️ Limited❌ Locked to OpenAI❌ Restart required❌ New session
Workspace Systemβœ… Per-project context❌ Not available❌ Not available❌ Not available❌ Not available❌ None
CLI Commandsβœ… 15+ powerful tools⚠️ Limited❌ IDE only⚠️ Limited❌ Separate packages❌ None
SDK + CLIβœ… Both included❌ CLI only❌ IDE only❌ CLI onlyβœ… SDK only⚠️ SDK only
Teaching Personasβœ… 6 mentors❌ Not available❌ Not available❌ Not available❌ Not available❌ None
Open Sourceβœ… 100% MIT licensed❌ Proprietary❌ Proprietaryβœ… Open sourceβœ… Open source⚠️ Varies

Key Differentiators for LLMSwap v5.1.0:

  • 🧠 Only AI tool with persistent project memory - Never repeat context again
  • πŸ“š Automatic learning journals - Track your progress without manual work
  • 🎯 Workspace-aware mentorship - AI understands your specific project
  • πŸ”„ Zero context switching overhead - Change projects, AI adapts automatically
  • πŸ’‘ Learning extraction - AI summarizes key takeaways from conversations

πŸš€ Three Ways to Use LLMSwap:

πŸ“š 1. Python Library/SDK

from llmswap import LLMClient
client = LLMClient()  # Import into any codebase
response = client.query("Analyze this data")

⚑ 2. CLI Tools

llmswap generate "sort files by size"           # GitHub Copilot alternative
llmswap generate "Python function to read JSON" # Multi-language code generation
llmswap ask "Debug this error"                  # Terminal AI assistant
llmswap costs                                    # Cost optimization insights

πŸ“Š 3. Enterprise Analytics

stats = client.get_usage_stats()         # Track AI spend
comparison = client.get_provider_comparison()  # Compare costs

🎯 What's New in v5.1.0

πŸ†• Revolutionary Workspace & Memory Features

  • 🧠 Workspace System: Per-project memory with .llmswap/ directories (inspired by .git/)
  • πŸ“š Auto-Learning Journal: AI automatically tracks what you learn in learnings.md
  • πŸ“– Architecture Decision Log: Document technical decisions in decisions.md
  • 🎯 Context-Aware Mentorship: AI mentor loads project context, past learnings, and decisions
  • πŸ” Workspace Detection: Automatically finds .llmswap/ in current or parent directories
  • πŸ—‚οΈ Project Knowledge Base: Editable context.md for project-specific information
  • πŸ“Š Workspace Statistics: Track queries, learnings, and decisions per project
  • 🌐 Global Workspace Registry: Manage all workspaces from ~/.llmswap/workspaces/registry.json
  • πŸ’‘ Learning Extraction: Uses fast AI (Groq) to extract key learnings from conversations
  • πŸ”„ Workspace Switching: Change directories, AI automatically loads different context

Teaching & Conversational Features (v5.0)

  • πŸŽ“ Age-Appropriate AI: First CLI with age-targeted explanations (--age 10, --audience "teacher")
  • πŸ§‘β€πŸ« Teaching Personas: 6 AI mentors (teacher, developer, tutor, professor, mentor, buddy)
  • πŸ‘€ Personalized Aliases: Custom AI names (--alias "Sarah" for your personal tutor)
  • πŸ’¬ Multi-Provider Chat: Provider-native conversational mode with mid-chat switching
  • 🧠 Zero Local Storage: 99% memory reduction, all context at provider level
  • βš™οΈ Git-like Config: Team-shareable configuration management
  • πŸ“Š Session Analytics: Real-time cost and token tracking

Provider & Model Flexibility

  • πŸ”“ Pass-Through Architecture: Use ANY model from your provider - GPT-5, Claude Opus 4, Gemini 2.5 Pro work immediately
  • ⚑ Zero-Wait Updates: New model released? Use it the same day, no llmswap update needed
  • 🌐 10 Providers Currently: OpenAI, Anthropic, Gemini, Cohere, Perplexity, IBM watsonx, Groq, Ollama, xAI (Grok), Sarvam AI
  • πŸ†• v5.1.4: Added xAI Grok and Sarvam AI support for cutting-edge and Indian language AI

πŸš€ Complete Feature Set

1️⃣ Python SDK - Multi-Provider Intelligence

from llmswap import LLMClient

# Auto-detects available providers
client = LLMClient()  

# Or specify your preference
client = LLMClient(provider="anthropic")  # Claude 3 Opus/Sonnet/Haiku
client = LLMClient(provider="openai")     # GPT-4, GPT-3.5
client = LLMClient(provider="gemini")     # Google Gemini Pro/Flash
client = LLMClient(provider="watsonx")    # IBM watsonx.ai Granite
client = LLMClient(provider="ollama")     # Llama, Mistral, Phi, 100+ local
client = LLMClient(provider="groq")       # Groq ultra-fast inference
client = LLMClient(provider="cohere")     # Cohere Command models for RAG
client = LLMClient(provider="perplexity") # Perplexity web-connected AI
client = LLMClient(provider="xai")        # xAI Grok models πŸ†•
client = LLMClient(provider="sarvam")     # Sarvam AI (Indian languages) πŸ†•

# Automatic failover
client = LLMClient(fallback=True)
response = client.query("Hello")  # Tries multiple providers

# Save 50-90% with intelligent caching
client = LLMClient(cache_enabled=True)
response1 = client.query("Expensive question")  # $$$ API call
response2 = client.query("Expensive question")  # FREE from cache

# πŸ†• v5.1.0: Workspace-Aware SDK (Auto-detects .llmswap/)
from llmswap import LLMClient

# SDK automatically detects workspace in current directory
client = LLMClient()  # Loads workspace context if .llmswap/ exists

# Query with full project context
response = client.query("How should I structure my API?")
# AI has access to: project context, past learnings, architecture decisions

# Check if workspace is loaded
if client.workspace_manager:
    workspace_data = client.workspace_manager.load_workspace()
    print(f"Working in: {workspace_data['project_name']}")
    print(f"Learnings tracked: {workspace_data['statistics']['learnings_count']}")

# Learnings are automatically saved after each query
# No manual tracking needed!

# πŸ†• v5.1.0: Eklavya Mentor Integration with Workspace
from llmswap import LLMClient
from llmswap.eklavya.mentor import EklavyaMentor

# Initialize client and mentor
client = LLMClient(provider="anthropic")
mentor = EklavyaMentor(persona="guru", alias="Guruji")

# Generate teaching system prompt with workspace context
teaching_prompt = mentor.generate_system_prompt()

# Use mentor for teaching-focused responses
response = client.query(
    "Explain Python decorators",
    system_prompt=teaching_prompt
)
print(response.content)  # Guru-style teaching response

# Different personas for different learning styles
coach = EklavyaMentor(persona="coach", alias="Coach Sarah")  # Motivational
friend = EklavyaMentor(persona="friend", alias="CodeBuddy")  # Collaborative
socrates = EklavyaMentor(persona="socrates")  # Question-based learning

# πŸ†• v5.0: Conversational Sessions (Provider-Native)
client.start_chat_session()
response = client.chat("Tell me about Python")  # Context maintained
response = client.chat("What are its best features?")  # Remembers previous
client.end_chat_session()  # Clean provider-level cleanup

# πŸ†• v5.0: Async Support for High Performance
import asyncio
from llmswap import AsyncLLMClient

async def main():
    async_client = AsyncLLMClient()
    response = await async_client.query_async("Process this data")
    
asyncio.run(main())

2️⃣ CLI Suite - 15+ Powerful Terminal Commands

πŸ†• v5.1.0: Workspace Commands

# Initialize workspace in current project
llmswap workspace init
llmswap workspace init --name "My Flask App"

# View workspace information
llmswap workspace info                    # Current workspace stats
llmswap workspace list                    # All workspaces
llmswap workspace journal                 # View learning journal
llmswap workspace decisions               # View decision log
llmswap workspace context                 # Edit project context

# Workspace automatically detected when you run:
llmswap chat                              # Loads workspace context
llmswap ask "How do I test this?"         # Uses project-specific context

CLI Commands (All Features)

# πŸ†• v5.0: Conversational Chat with Provider-Native Context
llmswap chat  # Interactive AI assistant with memory

# πŸ†• v5.0: Configuration Management (Git-like)
llmswap config set provider.default anthropic
llmswap config export --file team-config.yaml

# Generate code from natural language (GitHub Copilot alternative)
llmswap generate "sort files by size in reverse order"
llmswap generate "Python function to read JSON file" --language python
llmswap generate "find large files over 100MB" --execute

# Ask one-line questions
llmswap ask "How to optimize PostgreSQL queries?"

# Interactive AI chat
llmswap chat

# AI code review
llmswap review app.py --focus security

# Debug errors instantly
llmswap debug --error "ConnectionTimeout at line 42"

# Analyze logs with AI
llmswap logs --analyze app.log --since "2h ago"

# πŸ†• Web UI - Compare models side-by-side
llmswap web  # Opens browser at http://localhost:5005

🌐 Web UI for Model Comparison (v5.1.6 NEW!)

Compare 20+ AI models side-by-side in a beautiful web interface with live streaming results:

LLMSwap Web UI - Model Comparison Compare responses from GPT-4, Claude, Gemini, Grok, and more - see speed rankings, costs, and quality side-by-side

# Install web UI dependencies (one-time, optional)
pip install llmswap[web]

# Start local web server (opens at http://localhost:5005)
llmswap web

# Note: If you haven't installed [web] dependencies, you'll get a helpful message
# with installation instructions. The core SDK and CLI work without it.

# Custom port (if 5005 is already in use)
llmswap web --port 8080

# Allow network access (access from other devices on your network)
llmswap web --host 0.0.0.0 --port 8080

# Don't auto-open browser
llmswap web --no-browser

# Combine options
llmswap web --port 3000 --host 0.0.0.0 --no-browser

Features:

  • ⚑ Live streaming results - Cards fill in real-time as responses arrive with speed badges (⚑ Fastest! πŸ₯ˆ πŸ₯‰)
  • πŸ“Š Rich metrics - Response time, tokens, tokens/sec efficiency, response length indicators (πŸ“ Brief, πŸ“„ Detailed, πŸ“š Comprehensive)
  • πŸ’° Visual cost comparison - Bar chart showing relative costs, FREE badges for $0 models (Ollama, Groq)
  • 🎨 Markdown rendering - Full markdown support with syntax-highlighted code blocks (Highlight.js)
  • πŸ“‹ Code block copy - Individual copy buttons on each code block with hover reveal
  • πŸ’Ύ Smart preferences - Remembers your favorite models via localStorage with "Welcome back!" messages
  • 🎯 Real token counts - Uses actual API token data (not estimates) for accurate cost calculation
  • πŸ”’ Local-first - Runs on your machine, uses your API keys, zero data leaves your system

Perfect for:

  • Quality comparison - See which model gives better coding responses (Claude vs GPT-4o vs Grok)
  • Speed testing - Find fastest model for latency-sensitive apps (Groq vs Gemini Flash)
  • Cost optimization - Compare $0.0001 vs $0.0150 and decide if quality difference justifies 150x price
  • Prompt engineering - Test same prompt across providers to find best match
  • Model evaluation - Compare 20+ models simultaneously without switching tabs

What Makes It Special:

  • Compare up to 20 models at once (9 visible by default, 12 expandable)
  • Success/failure tracking - see exactly which models succeeded vs failed
  • First-time user tips - gentle onboarding for new users
  • Better error messages - helpful setup instructions when API keys missing

Screenshot: Compare GPT-4o, Claude Sonnet 4.5, Gemini 2.0 Flash, Grok-4, and 17 more models simultaneously. See speed badges update in real-time, cost bars visualize price differences, and code blocks with syntax highlighting.

3️⃣ Provider Management & Model Configuration (v5.0.4 NEW!)

🎯 View All Providers and Models:

# Beautiful table showing all providers, their status, and default models
llmswap providers

Output Example:

πŸ€– llmswap Provider Status Report
============================================================
| Provider   | Default Model              | Status            | Issue                    |
|============|============================|===================|==========================| 
| ANTHROPIC  | claude-3-5-sonnet-20241022 | βœ… CONFIGURED     |                          |
| OPENAI     | gpt-4o                     | ❌ NOT CONFIGURED | OPENAI_API_KEY missing   |
| GEMINI     | gemini-1.5-pro             | βœ… CONFIGURED     |                          |
| COHERE     | command-r-plus-08-2024     | ❌ NOT CONFIGURED | COHERE_API_KEY missing   |
| PERPLEXITY | sonar-pro                  | βœ… CONFIGURED     |                          |
| WATSONX    | granite-13b-chat           | βœ… CONFIGURED     |                          |
| GROQ       | llama-3.3-70b-versatile    | βœ… CONFIGURED     |                          |
| OLLAMA     | llama3.1                   | ⚠️ NOT RUNNING   | Local server not running |

πŸ“Š Summary: 5/8 providers available

πŸ”§ Model Configuration:

# Update any provider's default model
llmswap config set provider.models.openai gpt-4o-mini
llmswap config set provider.models.cohere command-r-plus-08-2024
llmswap config set provider.models.anthropic claude-3-5-haiku-20241022

# Set default provider
llmswap config set provider.default anthropic

# View current configuration
llmswap config list

# Export/import team configurations
llmswap config export team-config.yaml
llmswap config import team-config.yaml --merge

πŸš€ Handle Model Deprecations: When providers deprecate models (like Cohere's command-r-plus β†’ command-r-plus-08-2024):

# Simply update your config - no code changes needed!
llmswap config set provider.models.cohere command-r-plus-08-2024
llmswap providers  # Verify the change

βš™οΈ Configuration File Location:

  • User config: ~/.llmswap/config.yaml (created automatically on first run)
  • Custom location: Set LLMSWAP_CONFIG_HOME environment variable
  • Team sharing: Export/import YAML configs for team standardization

πŸ’¬ Interactive Chat Commands:

llmswap chat  # Start interactive conversation

# Available commands in chat:
/help      # Show all commands
/provider  # Show current provider and available providers
/switch    # Switch to different provider (privacy-compliant)
/clear     # Clear conversation history
/stats     # Show session statistics
/quit      # Exit chat

# Example session:
[0] > Hello, I'm working on a Python project
[anthropic] Hi! I'd be happy to help with your Python project...

[1] > /switch
πŸ“‹ Available providers: anthropic, gemini, perplexity, watsonx, groq
Enter provider name: gemini

πŸ”’ PRIVACY NOTICE: Switching to gemini
   βœ… NO conversation history will be shared with the new provider
   βœ… This protects your privacy and complies with provider Terms of Service
Continue? (y/n): y

βœ… Switched to gemini
πŸ’¬ Starting fresh conversation with gemini

4️⃣ Analytics & Cost Optimization (v4.0 NEW!)

# Compare provider costs before choosing
llmswap compare --input-tokens 1000 --output-tokens 500
# Output: Gemini $0.0005 | OpenAI $0.014 | Claude $0.011

# Track your actual usage and spending
llmswap usage --days 30 --format table
# Shows: queries, tokens, costs by provider, response times

# Get AI spend optimization recommendations
llmswap costs
# Suggests: Switch to Gemini, enable caching, use Ollama for dev
# Python SDK - Full analytics suite
client = LLMClient(analytics_enabled=True)

# Automatic conversation memory
response = client.chat("What is Python?")
response = client.chat("How is it different from Java?")  # Remembers context

# Real-time cost tracking
stats = client.get_usage_stats()
print(f"Total queries: {stats['totals']['queries']}")
print(f"Total cost: ${stats['totals']['cost']:.4f}")
print(f"Avg response time: {stats['avg_response_time_ms']}ms")

# Cost optimization insights
analysis = client.get_cost_breakdown()
print(f"Potential savings: ${analysis['optimization_opportunities']['potential_provider_savings']:.2f}")
print(f"Recommended provider: {analysis['recommendations'][0]}")

# Compare providers for your specific use case
comparison = client.get_provider_comparison(input_tokens=1500, output_tokens=500)
print(f"Cheapest: {comparison['cheapest']} (${comparison['cheapest_cost']:.6f})")
print(f"Savings vs current: {comparison['max_savings_percentage']:.1f}%")

4️⃣ Advanced Features

Async/Streaming Support

import asyncio
from llmswap import AsyncLLMClient

async def main():
    client = AsyncLLMClient()
    
    # Async queries
    response = await client.query("Explain AI")
    
    # Streaming responses
    async for chunk in client.stream("Write a story"):
        print(chunk, end="")

Multi-User Security

# Context-aware caching for multi-tenant apps
response = client.query(
    "Get user data",
    cache_context={"user_id": "user123"}  # Isolated cache
)

Provider Comparison

# Compare responses from different models
comparison = client.compare_providers(
    "Solve this problem",
    providers=["anthropic", "openai", "gemini"]
)

πŸ“Š Real-World Use Cases & Examples

🏒 Enterprise: Content Generation at Scale

Netflix-style recommendation descriptions for millions of items:

from llmswap import LLMClient

# Start with OpenAI, switch to Gemini for 96% cost savings
client = LLMClient(provider="gemini", cache_enabled=True)

def generate_descriptions(items):
    for item in items:
        # Cached responses save 90% on similar content
        description = client.query(
            f"Create engaging description for {item['title']}",
            cache_context={"category": item['category']}
        )
        yield description.content

# Cost: $0.0005 per description vs $0.015 with OpenAI

πŸ‘¨β€πŸ’» Developers: AI-Powered Code Review

GitHub Copilot alternative for your team:

# CLI for instant code review
$ llmswap review api_handler.py --focus security

# Python SDK for CI/CD integration
from llmswap import LLMClient

client = LLMClient(analytics_enabled=True)
review = client.query(f"Review this PR for bugs: {pr_diff}")

# Track costs across your team
stats = client.get_usage_stats()
print(f"This month's AI costs: ${stats['totals']['cost']:.2f}")

πŸŽ“ Education: AI Tutoring Platform

Khan Academy-style personalized learning:

client = LLMClient(provider="ollama")  # Free for schools!

def ai_tutor(student_question, subject):
    # Use watsonx for STEM, Ollama for general subjects
    if subject in ["math", "science"]:
        client.set_provider("watsonx")
    
    response = client.query(
        f"Explain {student_question} for a {subject} student",
        cache_context={"grade_level": student.grade}
    )
    return response.content

# Zero cost with Ollama, enterprise-grade with watsonx

πŸš€ Startups: Multi-Modal Customer Support

Shopify-scale merchant assistance:

from llmswap import LLMClient

# Start with Anthropic, fallback to others if rate-limited
client = LLMClient(fallback=True, cache_enabled=True)

async def handle_support_ticket(ticket):
    # 90% of questions are similar - cache saves thousands
    response = await client.aquery(
        f"Help with: {ticket.issue}",
        cache_context={"type": ticket.category}
    )
    
    # Auto-escalate complex issues
    if response.confidence < 0.8:
        client.set_provider("anthropic")  # Use best model
        response = await client.aquery(ticket.issue)
    
    return response.content

πŸ“± Content Creators: Writing Assistant

Medium/Substack article generation:

# Quick blog post ideas
llmswap ask "10 trending topics in AI for developers"

# Full article draft
llmswap chat
> Write a 1000-word article on prompt engineering
> Make it more technical
> Add code examples

πŸ”§ DevOps Engineers: Infrastructure as Code

Kubernetes and Docker automation:

# Generate Kubernetes deployment
llmswap generate "Kubernetes deployment for React app with 3 replicas" --save k8s-deploy.yaml

# Docker multi-stage build
llmswap generate "Docker multi-stage build for Node.js app with Alpine" --language dockerfile

# Terraform AWS infrastructure
llmswap generate "Terraform script for AWS VPC with public/private subnets" --save main.tf

🎯 Data Scientists: Analysis Workflows

Pandas, visualization, and ML pipeline generation:

# Data analysis scripts
llmswap generate "Pandas script to clean CSV and handle missing values" --language python

# Visualization code
llmswap generate "Matplotlib script for correlation heatmap" --save plot.py

# ML pipeline
llmswap generate "scikit-learn pipeline for text classification with TF-IDF" --language python

πŸ’¬ App Developers: Full Applications

Complete app generation with modern frameworks:

# Streamlit chatbot
llmswap generate "Streamlit chatbot app with session state and file upload" --save chatbot.py

# FastAPI REST API
llmswap generate "FastAPI app with CRUD operations for user management" --save api.py

# React component
llmswap generate "React component for data table with sorting and filtering" --language javascript --save DataTable.jsx

πŸ€– AI/ML Engineers: Model Deployment

Production-ready ML workflows and deployments:

# LangChain RAG pipeline
llmswap generate "LangChain RAG system with ChromaDB and OpenAI embeddings" --language python --save rag_pipeline.py

# Hugging Face model fine-tuning
llmswap generate "Script to fine-tune BERT for sentiment analysis with Hugging Face" --save finetune.py

# Gradio ML demo app
llmswap generate "Gradio app for image classification with drag and drop" --save demo.py

# Vector database setup
llmswap generate "Pinecone vector database setup for semantic search" --language python

πŸ”’ Security Engineers: Vulnerability Scanning

Security automation and compliance scripts:

# Security audit script
llmswap generate "Python script to scan for exposed API keys in codebase" --save security_scan.py

# OAuth2 implementation
llmswap generate "FastAPI OAuth2 with JWT tokens implementation" --language python

# Rate limiting middleware
llmswap generate "Redis-based rate limiting for Express.js" --language javascript

πŸ› οΈ AI Agent Development: Tool Creation

Build tools and functions for AI agents (inspired by Anthropic's writing tools):

# Create tool functions for agents
llmswap generate "Python function for web scraping with BeautifulSoup error handling" --save tools/scraper.py

# Database interaction tools
llmswap generate "SQLAlchemy functions for CRUD operations with type hints" --save tools/database.py

# File manipulation utilities
llmswap generate "Python class for safe file operations with context managers" --save tools/file_ops.py

# API integration tools
llmswap generate "Async Python functions for parallel API calls with rate limiting" --save tools/api_client.py

# Agent orchestration
llmswap generate "LangChain agent with custom tools for research tasks" --language python

πŸ† Hackathon Power Kit: Win Your Next Hackathon

Build complete MVPs in minutes, not hours:

# RAG Chatbot for Document Q&A (Most requested hackathon project)
llmswap generate "Complete RAG chatbot with OpenAI embeddings, Pinecone vector store, and Streamlit UI for PDF document Q&A" --save rag_chatbot.py

# Full-Stack SaaS Starter (0 to production in 5 minutes)
llmswap generate "Next.js 14 app with Clerk auth, Stripe payments, Prisma ORM, and PostgreSQL schema for SaaS platform" --save saas_mvp.js

πŸ› οΈ Installation & Setup

# Install package
pip install llmswap

# Set any API key (one is enough to get started)
export ANTHROPIC_API_KEY="sk-..."       # For Claude
export OPENAI_API_KEY="sk-..."          # For GPT-4
export GEMINI_API_KEY="..."             # For Google Gemini
export WATSONX_API_KEY="..."            # For IBM watsonx
export WATSONX_PROJECT_ID="..."         # watsonx project
export GROQ_API_KEY="gsk_..."           # For Groq ultra-fast inference
export COHERE_API_KEY="co_..."            # For Cohere Command models
export PERPLEXITY_API_KEY="pplx-..."      # For Perplexity web search
# Or run Ollama locally for 100% free usage

πŸ“ˆ Token Usage Guidelines

Task TypeInput TokensOutput TokensEstimated Cost
Simple Q&A10050~$0.001
Code Review1000300~$0.010
Document Analysis3000800~$0.025
Creative Writing5002000~$0.020

πŸš€ Get Started in 30 Seconds

# Install
pip install llmswap

# Set ANY API key (one is enough)
export ANTHROPIC_API_KEY="your-key"  # or OpenAI, or Gemini...

# Start building
llmswap chat "Hello!"

Or use the SDK:

from llmswap import LLMClient

# Auto-detects available providers
client = LLMClient()

# Chat with AI
response = client.chat("Write a Python function to sort a list")
print(response.content)

# Add tool calling (v5.2.0)
from llmswap import Tool

weather = Tool(
    name="get_weather",
    description="Get weather data",
    parameters={"city": {"type": "string"}},
    required=["city"]
)

response = client.chat("What's the weather in Tokyo?", tools=[weather])

That's it! Automatic provider detection, failover, caching, and now tool calling - all in 10 lines.

πŸ“Š Why Thousands Choose llmswap

  • ⚑ 12,000+ Downloads - Trusted by developers worldwide
  • πŸš€ v5.2.0 - Now with universal tool calling
  • πŸ”“ MIT License - 100% open source, free forever
  • 🐍 Python 3.8+ - Works on all platforms
  • 🌍 11 Providers - Anthropic, OpenAI, Gemini, Groq, xAI, Cohere, Perplexity, Sarvam, IBM watsonx, Ollama
  • πŸ“¦ pip & Homebrew - Install in seconds
  • 🎯 Production Ready - Used in real products

Compare with Alternatives

FeaturellmswapLiteLLMLangChain
Setup Time30 seconds5 minutes1 hour
Lines of Code1020100+
Tool Callingβœ… Universalβœ… Universalβœ… Complex
Cachingβœ… Built-inβœ… Optional❌ External
Workspace Memoryβœ… Unique❌❌
CLI + SDKβœ… BothSDK onlySDK only
Learning CurveEasyMediumHard
Best ForShipping fastGatewayAgents

Choose llmswap when you want to ship fast without the complexity.

Built with ❀️ for developers who ship. Star us on GitHub if llmswap helps you build faster!

Latest: v5.2.0 - Universal tool calling across all providers πŸš€

Keywords

10-providers

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts