Skip to main content
Agents are AI-powered entities that can understand and respond to messages. Each agent is backed by an LLM provider and can be customized with roles, goals, instructions, and additional features like memory, tools, and RAG.

Quick Start

from lyzr import Studio

studio = Studio(api_key="your-api-key")

# Create an agent
agent = studio.create_agent(
    name="Support Bot",
    provider="gpt-4o",
    role="Customer support agent",
    goal="Help customers resolve issues",
    instructions="Be empathetic, concise, and solution-oriented"
)

# Run the agent
response = agent.run("I can't login to my account")
print(response.response)

Agent Lifecycle

Create → Configure → Run → Manage
  1. Create: Use studio.create_agent() to create an agent with a name, provider, and configuration
  2. Configure: Add features like memory, tools, contexts, or RAI policies
  3. Run: Execute the agent with agent.run() to get responses
  4. Manage: Update, clone, or delete agents as needed

Key Features

Provider Selection

Choose from multiple LLM providers:
# OpenAI
agent = studio.create_agent(provider="gpt-4o", ...)

# Anthropic
agent = studio.create_agent(provider="claude-sonnet-4.5", ...)

# Google
agent = studio.create_agent(provider="gemini-2.5-pro", ...)

# Full format with provider prefix
agent = studio.create_agent(provider="openai/gpt-4o", ...)

Streaming Responses

Get real-time responses:
for chunk in agent.run("Tell me a story", stream=True):
    print(chunk.content, end="", flush=True)

Structured Outputs

Get type-safe responses with Pydantic:
from pydantic import BaseModel

class Analysis(BaseModel):
    sentiment: str
    score: float
    summary: str

agent = studio.create_agent(
    name="Analyzer",
    provider="gpt-4o",
    response_model=Analysis
)

result: Analysis = agent.run("Analyze this text...")
print(result.sentiment)  # Type-safe access

Memory

Maintain conversation context:
agent = studio.create_agent(
    name="Assistant",
    provider="gpt-4o",
    memory=30  # Remember last 30 messages
)

Knowledge Bases (RAG)

Add document retrieval:
kb = studio.create_knowledge_base(name="Docs")
kb.add_pdf("manual.pdf")

response = agent.run(
    "What's in the manual?",
    knowledge_bases=[kb]
)

Tools

Execute Python functions:
def get_weather(city: str) -> str:
    """Get weather for a city"""
    return f"72°F in {city}"

agent.add_tool(get_weather)
response = agent.run("What's the weather in NYC?")

RAI Guardrails

Add safety features:
policy = studio.create_rai_policy(
    name="SafePolicy",
    toxicity_threshold=0.3
)

agent = studio.create_agent(..., rai_policy=policy)

Agent Properties

PropertyTypeDescription
idstrUnique agent identifier
namestrAgent name
descriptionstrAgent description
provider_idstrLLM provider (e.g., “openai”)
modelstrModel name (e.g., “gpt-4o”)
rolestrAgent role
goalstrAgent goal
instructionsstrAgent instructions
temperaturefloatCreativity setting (0.0-2.0)
top_pfloatNucleus sampling (0.0-1.0)

Next Steps

Creating Agents

Learn all agent creation options

Running Agents

Execute agents and handle responses

Managing Agents

Update, clone, and delete agents

Agent Features

Add memory, tools, and more