Skip to main content

Overview

LiteLLM provides full support for OpenAI’s models including GPT-4o, O1, O3-mini, and more. You can use all OpenAI features including streaming, function calling, vision, audio, and batch processing.

Quick Start

1

Install LiteLLM

2

Set API Key

3

Make Your First Call

Supported Models

Latest and most capable GPT-4 models with optimized performance.

Authentication

Set your OpenAI API key as an environment variable:

Streaming

Get real-time responses as they’re generated:

Async Streaming

Function Calling

OpenAI models support sophisticated function/tool calling:

Vision (Multimodal)

GPT-4o and GPT-4 Turbo support image inputs:

JSON Mode

Force models to return valid JSON:

Advanced Features

Seed for Reproducibility

Logprobs

Max Tokens and Stop Sequences

Temperature and Top P

Embeddings

Generate text embeddings for semantic search and clustering:

Available Embedding Models

Batch Processing

Process large volumes of requests asynchronously:

Error Handling

Cost Tracking

Best Practices

Use GPT-4o-mini First

Start with gpt-4o-mini for testing - it’s fast and cost-effective. Upgrade to gpt-4o when you need maximum quality.

Set Max Tokens

Always set max_tokens to prevent unexpectedly long (and expensive) responses.

Use Streaming

Enable streaming for better user experience in interactive applications.

Handle Rate Limits

Implement exponential backoff when handling RateLimitError exceptions.

Streaming

Learn more about streaming responses

Function Calling

Deep dive into function calling

Vision

Working with images and vision models

Embeddings

Guide to embeddings and semantic search