Tutorials & Examples

Real-world examples and practical tutorials for llmswap.


Quick Examples

🚀 DevOps & System Administration

# Generate Docker Compose file
llmswap generate "docker compose for WordPress with MySQL"

# Debug server error
llmswap debug --error "nginx: [emerg] bind() to 0.0.0.0:80 failed"

# Analyze logs
llmswap logs --analyze /var/log/system.log --since "1h ago"

💻 Development Workflows

# Code review
llmswap review api.py --focus security

# Generate unit tests
llmswap generate "pytest tests for user authentication" --save test_auth.py

# Fix code issues
llmswap debug --file error.log --language python

📊 Data Science

from llmswap import LLMClient

client = LLMClient()

# Generate data cleaning code
response = client.query("""
Generate pandas code to:
1. Load CSV with proper encoding
2. Handle missing values
3. Remove duplicates
4. Standardize column names
""")
print(response.content)

🎯 Cost Optimization

# Compare provider costs
llmswap compare --input-tokens 100000 --output-tokens 50000

# Check monthly spending
llmswap costs --days 30

# Use cheaper provider for simple tasks
llmswap ask "What time is it in Tokyo?" --provider gemini

📱 Build a Chatbot

Create an intelligent chatbot with conversation memory and provider switching.

View Tutorial →

🔄 Replace GitHub Copilot

Use llmswap as a free alternative to GitHub Copilot CLI.

View Tutorial →

💰 Cost Optimization Guide

Reduce AI costs by 90% with smart provider selection.

View Tutorial →

🏢 Enterprise Setup

Configure llmswap for team use with security and compliance.

View Tutorial →

🤖 RAG Implementation

Build a retrieval-augmented generation system.

View Tutorial →

🔒 Local AI Setup

Run completely offline with Ollama models.

View Tutorial →

Code Snippets

Vim Integration

" Add to .vimrc
" Generate code with ,g
nnoremap ,g :r !llmswap generate "

" Review current file with ,r
nnoremap ,r :!llmswap review %<CR>

" Get help with error under cursor
nnoremap ,d :exec '!llmswap debug --error "' . getline('.') . '"'<CR>

Shell Aliases

# Add to .bashrc or .zshrc
alias ai='llmswap ask'
alias aic='llmswap chat'
alias aigen='llmswap generate'
alias aicode='llmswap review'

# Quick provider switching
alias ai-gpt='llmswap chat --provider openai'
alias ai-claude='llmswap chat --provider anthropic'
alias ai-local='llmswap chat --provider ollama'

Git Hooks

#!/bin/bash
# .git/hooks/pre-commit

# AI code review before commit
files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(py|js|ts)$')
for file in $files; do
    echo "Reviewing $file..."
    llmswap review "$file" --focus bugs --quiet
done

Integration Examples

VS Code Task

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "AI Review",
      "type": "shell",
      "command": "llmswap review ${file}",
      "problemMatcher": []
    },
    {
      "label": "Generate Tests",
      "type": "shell", 
      "command": "llmswap generate 'unit tests for ${file}' --save ${fileDirname}/test_${fileBasename}",
      "problemMatcher": []
    }
  ]
}

GitHub Actions

name: AI Code Review
on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install llmswap
        run: pip install llmswap
      - name: Review Changes
        env:
          ANTHROPIC_API_KEY: $
        run: |
          for file in $(git diff --name-only origin/main...HEAD); do
            llmswap review "$file" --focus security
          done

Browse All Tutorials


Table of contents


Copyright © 2025 llmswap. Distributed under the MIT license.