Skip to main content

Model Configuration

Configure LLM models from different providers for your applications.

Model Selection

OpenAI Models

from openai import OpenAI

client = OpenAI()

# GPT-4o (recommended)
response = client.chat.completions.create(
    model="gpt-4o",
    messages=messages,
    temperature=0.7
)

# GPT-4o-mini (faster, cheaper)
response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=messages
)

Anthropic Models

from anthropic import Anthropic

client = Anthropic()

# Claude 3.5 Sonnet
response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=4096,
    messages=messages
)

Google Models

import google.generativeai as genai

model = genai.GenerativeModel('gemini-1.5-pro')
response = model.generate_content(prompt)

Common Parameters

temperature
number
Controls randomness (0.0 = deterministic, 1.0 = creative)
max_tokens
integer
Maximum tokens in response
top_p
number
Nucleus sampling threshold

Framework Integration

Agno

from agno import Agent, OpenAI, Anthropic, Gemini

# OpenAI
agent = Agent(model=OpenAI(id="gpt-4o"))

# Anthropic
agent = Agent(model=Anthropic(id="claude-3-5-sonnet-20241022"))

# Gemini
agent = Agent(model=Gemini(id="gemini-1.5-pro"))

LangChain

from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatOpenAI(model="gpt-4o")
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro")

Local Models (Ollama)

from agno import Agent, Ollama

# Run Llama 3.2 locally
agent = Agent(model=Ollama(id="llama3.2"))
Install Ollama from ollama.ai for local model support.

API Keys

Set up provider API keys

Local RAG

Use local models with Ollama

Build docs developers (and LLMs) love