Examples
- Introduction
- Getting Started
- Agents
- Teams
- Workflows
- Applications
Agent Concepts
- Multimodal
- RAG
- Knowledge
- Memory
- Async
- Hybrid Search
- Storage
- Tools
- Vector Databases
- Context
- Embedders
- Agent State
Models
- Anthropic
- AWS Bedrock
- AWS Bedrock Claude
- Azure AI Foundry
- Azure OpenAI
- Cerebras
- Cerebras OpenAI
- Cohere
- DeepInfra
- DeepSeek
- Fireworks
- Gemini
- Groq
- Hugging Face
- Meta
- Mistral
- NVIDIA
- Ollama
- OpenAI
- Perplexity
- Together
- xAI
- IBM
- LM Studio
- LiteLLM
- LiteLLM OpenAI
Meta
Structured output
Code
cookbook/models/meta/structured_output.py
from typing import List
from pydantic import BaseModel, Field
from agno.agent import Agent
from agno.models.meta import Llama
class MovieScript(BaseModel):
name: str = Field(..., description="Name of the movie.")
setting: str = Field(..., description="Provide a setting for the movie.")
ending: str = Field(..., description="Describe the movie ending.")
genre: str = Field(..., description="Genre of the movie.")
characters: List[str] = Field(..., description="List of characters.")
storyline: str = Field(..., description="A 3-sentence storyline.")
agent = Agent(
model=Llama(id="Llama-3.3-70B"),
response_model=MovieScript,
markdown=True,
)
agent.print_response("Generate a movie script outline for a sci-fi adventure.")
Usage
1
Create a virtual environment
Open the Terminal
and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2
Set your LLAMA API key
export LLAMA_API_KEY=YOUR_API_KEY
3
Install libraries
pip install llama-api-client agno
4
Run Agent
python cookbook/models/meta/structured_output.py
Was this page helpful?