peargent.

Models

Use different model providers in your Agents and Pools.

Models define which LLM your Agent or Pool uses. Peargent provides a simple, unified interface for connecting to different providers (OpenAI, Groq, Gemini, etc.).

Think of a Model as the brain of your Agent or Pool, the thing that actually generates responses.

Creating a Model

Models are imported from peargent.models and created using simple factory functions:

from peargent.models import openai, groq, gemini, anthropic

model = openai("gpt-4o")
# or
model = anthropic("claude-3-5-sonnet-20241022")

You can run the model directly to get a response:

response = model.generate("Hello, how are you?")
print(response)

Passing model to Agent or Pool

from peargent import create_agent, create_pool
from peargent.models import openai

agent = create_agent(
    name="Researcher",
    description="You are a researcher who can answer questions about the world.",
    persona="You are a researcher who can answer questions about the world.",
    model=openai("gpt-4o")
)
pool = create_pool(
    agents=[agent],
    model=openai("gpt-4o")
)

Supported Model Providers

Peargent’s model support is continuously expanding. New providers and model families are added regularly, so expect this list to grow over time.

from peargent.models import openai

model = openai(
    model_name="gpt-4o",
    api_key="sk-",
    endpoint_url="https://api.openai.com/v1",
    parameters={}
)