LiteLLM

Call providers through the LiteLLM Python SDK with tools, knowledge, history, structured output and media.

LiteLLM runs the multi-provider Python SDK in your process. For a separate proxy server, use the LiteLLMOpenAI examples.

ExampleDescription
LiteLLM Audio Input AgentPass an MP3 file as audio input to a gpt-audio model routed through LiteLLM.
LiteLLM BasicRun a Hugging Face Mistral model through LiteLLM with sync, async, and streaming calls.
LiteLLM Basic GPTCall OpenAI's gpt-5.6-luna through the LiteLLM model class for a basic agent response.
DBPersist LiteLLM agent sessions in SQLite and answer follow-ups with chat history in context.
LiteLLM Image AgentAnalyze an image from a URL with gpt-5.6-luna via LiteLLM and pull related news using web search.
LiteLLM Image Agent BytesSend an image as raw bytes to gpt-5.6-luna via LiteLLM and fetch related news with web search.
LiteLLM KnowledgeAnswer questions from a PDF knowledge base stored in PgVector using a LiteLLM agent.
LiteLLM MemoryKeep up to three previous runs in context and inspect session messages using an in-memory database.
LiteLLM MetricsInspect per-message and run-level token metrics from a LiteLLM agent using YFinance tools.
LiteLLM PDF Input BytesPass a downloaded PDF as raw bytes to a LiteLLM agent and summarize its contents.
LiteLLM PDF Input LocalAttach a local PDF file to a LiteLLM agent and ask questions about a specific recipe.
LiteLLM PDF Input URLAttach a PDF by URL to a LiteLLM agent and ask for a recipe from the document.
LiteLLM Reasoning Agent ExampleStream DeepSeek V4 Flash reasoning content through the LiteLLM SDK.
RetryReview retry settings and why invalid model IDs cannot reliably exercise the retry path.
LiteLLM Structured OutputRequest JSON mode and JSON Schema through LiteLLM, then validate responses with MovieScript.
LiteLLM Tool UseCall YFinance tools from a LiteLLM agent with sync, streaming, and async runs.
LiteLLM Append Trailing User MessageAppend a trailing user turn so Claude 4.6+ models that reject assistant prefill work through LiteLLM.