Rendered Source Note

LiteLLM — completion() Unified Interface

Generated HTML view. Markdown remains canonical.

LiteLLM — completion() Unified Interface

Type: official-doc Tier: 1 (Official Doc) Author(s): BerriAI (LiteLLM) Date: Accessed 2026-06-01 URL: https://docs.litellm.ai/docs/completion/input Accessed: 2026-06-01

Why This Source Matters

LiteLLM is the lab's provider-abstraction layer. It lets the same application code call OpenAI, Anthropic, and 20+ other providers by changing only the model string. This source establishes the unified function signature and the "switch providers without changing logic" property that Learning Objective 7 of Project 1 depends on.

Key Claims

Unified interface

Function signature (key params)

def completion(
    model: str,
    messages: List = [],
    temperature: Optional[float] = None,
    top_p: Optional[float] = None,
    stream: Optional[bool] = None,
    stop=None,
    max_tokens: Optional[int] = None,
    response_format: Optional[dict] = None,
    seed: Optional[int] = None,
    tools: Optional[List] = None,
    tool_choice: Optional[str] = None,
    **kwargs,
) -> ModelResponse:

Message shape (OpenAI style)

Provider switching

import litellm

# OpenAI
litellm.completion(model="gpt-4o", messages=[{"role":"user","content":"Hello!"}], max_tokens=10)

# Anthropic — only the model string changes
litellm.completion(model="claude-sonnet-4-6", messages=[{"role":"user","content":"Hello!"}], max_tokens=10)

Response shape

Relevant To

Notes