Skill: ishaan-jaff/litellm (version 1.0.0)

--- name: litellm description: Call 100+ LLM providers through LiteLLM's unified API. Use when you need to call a different model than your primary (e.g., use GPT-4 for code review while running on Claude), compare outputs from multiple models, route to cheaper models for simple tasks, or access models your runtime doesn't natively support. --- # LiteLLM - Multi-Model LLM Calls Use LiteLLM when you need to call LLMs beyond your primary model. ## When to Use - **Model comparison**: Get outputs from multiple models and compare - **Specialized routing**: Use code-optimized models for code, writing models for prose - **Cost optimization**: Route simple queries to cheaper models - **Fallback access**: Access models your runtime doesn't support ## Quick Start ```python import litellm # Call any model with unified API response = litellm.completion( model="gpt-4o", messages=[{"role": "user", "content": "Explain this code"}] ) print(response.choices[0].message.content) ``` ## Common Patterns ### Compare Multiple Models ```python import litellm prompt = [{"role": "user", "content": "What's the best approach to X?"}] models = ["gpt-4o", "claude-sonnet-4-20250514", "gemini/gemini-1.5-pro"] for model in models: resp = litellm.completion(model=model, messages=prompt) print(f"{model}: {resp.choices[0].message.content[:200]}...") ``` ### Route by Task Type ```python import litellm def smart_call(task_type: str, prompt: str) -> str: model_map = { "code": "gpt-4o", # Strong at code "writing": "claude-sonnet-4-20250514", # Strong at prose "simple": "gpt-4o-mini", # Cheap for simple tasks "reasoning": "o1-preview", # Deep reasoning } model = model_map.get(task_type, "gpt-4o") resp = litellm.completion( model=model, messages=[{"role": "user", "content": prompt}] ) return resp.choices[0].message.content ``` ### Use LiteLLM Proxy (Recommended) If a LiteLLM proxy is available, point to it for caching, rate limiting, and observability: ```python import litellm litellm.api_base = "https://your-litellm-proxy.com" litellm.[REDACTED_SECRET]" response = litellm.completion( model="gpt-4o", # Proxy routes to configured provider messages=[{"role": "user", "content": "Hello"}] ) ``` ## Environment Setup Ensure `litellm` is installed and API keys are set: ```bash pip install litellm # Set provider keys (or configure in proxy) export OPENAI_API_KEY="sk-..." export ANTHROPIC_API_KEY="sk-..." ``` ## Model Reference Common model identifiers: - **OpenAI**: `gpt-4o`, `gpt-4o-mini`, `o1-preview`, `o1-mini` - **Anthropic**: `claude-sonnet-4-20250514`, `claude-opus-4-20250514` - **Google**: `gemini/gemini-1.5-pro`, `gemini/gemini-1.5-flash` - **Mistral**: `mistral/mistral-large-latest` Full list: https://docs.litellm.ai/docs/providers

path: scripts/llm_call.py
content: #!/usr/bin/env python3
"""
LiteLLM call helper - quickly call any LLM model.

Usage:
    python llm_call.py "Your prompt here"
    python llm_call.py "Your prompt" --model gpt-4o
    python llm_call.py "Your prompt" --model claude-sonnet-4-20250514 --json
    
Environment:
    LITELLM_API_BASE - LiteLLM proxy URL (optional)
    LITELLM_API_KEY - API key for proxy (optional)
    OPENAI_API_KEY - Direct OpenAI key
    ANTHROPIC_API_KEY - Direct Anthropic key
"""

import argparse
import json
import os
import sys

def main():
    parser = argparse.ArgumentParser(description="Call any LLM via LiteLLM")
    parser.add_argument("prompt", help="The prompt to send")
    parser.add_argument("--model", "-m", default="gpt-4o", help="Model to use (default: gpt-4o)")
    parser.add_argument("--system", "-s", help="System message")
    parser.add_argument("--json", action="store_true", help="Output raw JSON response")
    parser.add_argument("--temperature", "-t", type=float, default=0.7, help="Temperature (default: 0.7)")
    parser.add_argument("--max-tokens", type=int, help="Max output tokens")
    args = parser.parse_args()

    try:
        import litellm
    except ImportError:
        print("Error: litellm not installed. Run: pip install litellm", file=sys.stderr)
        sys.exit(1)

    # Configure proxy if set
    if os.environ.get("LITELLM_API_BASE"):
        litellm.api_base = os.environ["LITELLM_API_BASE"]
    if os.environ.get("LITELLM_API_KEY"):
        litellm.[REDACTED_SECRET]"LITELLM_API_KEY"]

    # Build messages
    messages = []
    if args.system:
        messages.append({"role": "system", "content": args.system})
    messages.append({"role": "user", "content": args.prompt})

    # Build kwargs
    kwargs = {
        "model": args.model,
        "messages": messages,
        "temperature": args.temperature,
    }
    if args.max_tokens:
        kwargs["max_tokens"] = args.max_tokens

    try:
        response = litellm.completion(**kwargs)
        
        if args.json:
            print(json.dumps(response.model_dump(), indent=2))
        else:
            print(response.choices[0].message.content)
            
    except Exception as e:
        print(f"Error: {e}", file=sys.stderr)
        sys.exit(1)

if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)