The best AI agent framework for Python beginners is CrewAI. If you want the smallest possible start, pick the OpenAI Agents SDK. If you want full control later, learn LangGraph.
All the tools below are free open-source Python packages. You only pay for the AI model calls. Each one has an install command and a few lines of code, so you can try it in minutes.
Quick answer
- Best for Python beginners: CrewAI. Agents are described as team roles.
- Least code: OpenAI Agents SDK. Three building blocks.
- Best for learning how agents work: smolagents. The core is short enough to read.
- Best for clean, typed Python: PydanticAI.
- Best for long, safe workflows: LangGraph.
What you need before you start
Every framework here runs on Python 3.10 or newer. CrewAI also needs a version below 3.14, so Python 3.11 or 3.12 is the safest choice. Agno, covered below, works from 3.9.
Make a virtual environment
Run
python -m venv .venvand activate it. This keeps each project’s packages apart, and it matters because agent libraries change fast.Get a model API key
Create a key with OpenAI, Anthropic, Google or another provider. Save it as an environment variable, for example
OPENAI_API_KEY. Never paste it into your code.Set a spending limit
In your model account, set a monthly cap before you run any agent. A looping agent can burn money quickly.
Install one framework with pip
Start with a single tool from this list. Do not install five at once.
Do you need a framework at all?
Not always. An agent is a loop: the model picks an action, a tool runs, and the result goes back to the model. If your agent has one or two tools, a short Python script that calls the model API is enough, and you will see every line that runs.
Use a framework when you need several agents, saved memory, human approval, or a way to resume after a crash. For the full idea, read what an AI agent framework is. For the wider list that also covers non-Python tools, see the best AI agent frameworks guide.
How each one is judged
- Time to first agent: how fast a beginner gets a working result.
- Python fit: how natural the code feels to a Python developer.
- Control: how much you can steer each step.
- Real cost: what you pay besides model calls.
- Model choice: whether you can use models from more than one company.
Last updated: September 21, 2026. Versions and prices change, so check the official site before you pay for anything.
Comparison table
| Framework | Best for | Install | Python | License |
|---|---|---|---|---|
| CrewAI | Beginners, agent teams | pip install crewai | 3.10 to 3.13 | MIT |
| OpenAI Agents SDK | Least code, OpenAI models | pip install openai-agents | 3.10+ | MIT |
| smolagents | Learning, small agents | pip install smolagents | 3.10+ | Apache 2.0 |
| PydanticAI | Typed, testable code | pip install pydantic-ai | 3.10+ | MIT |
| LangGraph | Long, safe workflows | pip install langgraph | 3.10+ | MIT |
| LangChain | Many integrations | pip install langchain | 3.10+ | MIT |
| LlamaIndex | Agents over your documents | pip install llama-index | 3.10+ | MIT |
| Agno | Simple agents with memory | pip install agno | 3.9+ | Apache 2.0 |
The best AI agent frameworks for Python
CrewAI
Best for beginners- Best forFirst multi-agent project
- Installpip install crewai
- Cost to start$0 (MIT license)
CrewAI treats agents like a small team. Each agent gets a role, a goal and a backstory. You add tasks, and the crew runs them. It reads almost like plain English, which is why beginners pick it up fast.
The library is free. The paid cloud platform has a free Basic plan with 50 workflow runs a month. You do not need it to learn.
Watch for loops. Agents can retry and spend tokens, and the max iteration setting does not always stop them. Use a spending cap on your model account.
Pros
- Fastest to learn
- Readable role-based code
- Large community
Cons
- Needs Python below 3.14
- Less control than a graph tool
- Loops can waste tokens
OpenAI Agents SDK
Least code- Best forSimple agents on OpenAI models
- Installpip install openai-agents
- Cost to start$0 code, you pay for model calls
This SDK has three core ideas: agents, handoffs (one agent passes work to another) and guardrails (checks on inputs and outputs). It also has sessions for memory and built-in tracing.
It supports other providers through adapters, but some built-in tools work only with OpenAI models. Test before you plan around them.
Pros
- Very small to learn
- Tracing and guardrails included
- Works with MCP tools
Cons
- Closest fit is OpenAI models
- You design long-term state yourself
smolagents
Best for learning- Best forUnderstanding how agents work
- Installpip install smolagents
- Cost to start$0 (Apache 2.0)
smolagents comes from Hugging Face. Its agent logic is short enough to read in one sitting. The CodeAgent writes small pieces of Python to do its work instead of picking from a fixed tool list.
Code written by an AI can be risky. Run it in a sandbox such as Docker, E2B or Modal. It works with hosted models and local models, so it is a good pick if you want to avoid API bills while you learn.
Pros
- Tiny and easy to read
- Local and hosted models
- Free
Cons
- Fewer production features
- Code agents need a sandbox
PydanticAI
Best for clean Python- Best forDevelopers who like type hints
- Installpip install pydantic-ai
- Cost to start$0 (MIT license)
PydanticAI is made by the team behind Pydantic, the data checking tool most Python developers already know. Inputs, tools and outputs are typed and validated, so many mistakes are caught before they reach a user.
You switch models by changing one text string, such as openai: or anthropic: followed by the model name. Logfire, their tracking product, is optional.
Pros
- Typed, validated output
- Easy model switching
- Good for testing
Cons
- Python only
- Feels heavier if you skip type hints
LangGraph
Best for control- Best forLong workflows that must not fail
- Installpip install langgraph
- Cost to start$0 (MIT license)
LangGraph makes you draw the agent as a graph. Each step is a node, and lines say what happens next. It saves state as it goes, so a workflow can pause for a human approval and resume later, or restart after a crash.
That control means more code. It is not the best first tool, but it is where many Python teams end up. The optional LangSmith tracking plan is $0 for one seat with 5,000 base traces a month, and $39 per seat per month on Plus.
Pros
- Saves progress and resumes
- Human approval built in
- Many model providers
Cons
- Steeper learning curve
- More code for simple jobs
LangChain
Most integrations- Best forQuick prototypes with many tools
- Installpip install -U langchain
- Cost to start$0 (MIT license)
LangChain connects to a huge list of models and tools. Its create_agent function builds a working tool-using agent in a few lines, and it runs on LangGraph underneath.
The trade-off is layers. They can hide the exact text sent to the model, so turn on tracing early. Old tutorials use older LangChain code that no longer matches, so follow the current quickstart.
Pros
- Biggest ecosystem
- Works with almost any model
- Grows into LangGraph
Cons
- Many concepts to sort through
- Outdated tutorials are common
LlamaIndex
Best for your documents- Best forAgents that read PDFs and data
- Installpip install llama-index
- Cost to start$0 (MIT license)
LlamaIndex started as a way to connect models to your own files, called RAG. It has agent tools now, but document search is still its strongest side.
The framework is free. Its cloud service, LlamaCloud, has a free plan with 10,000 credits. Starter is $50 per month with 40,000 credits, and Pro is $500 per month with 400,000 credits.
Pros
- Best for document search
- Large community
Cons
- Not built for agent teams
- Cloud credits can add up
Agno
Simple agents with memory- Best forSingle agents that need storage
- Installpip install agno
- Cost to start$0 (Apache 2.0)
Agno is a Python framework for building agents with storage, integrations and monitoring. It works on Python 3.9 and up, which helps if you cannot upgrade Python yet. It is a good look if CrewAI does not fit how you think about your project.
It has a smaller community than the tools above, so you will find fewer tutorials and answers online.
Pros
- Works on Python 3.9
- Storage and runtime included
Cons
- Fewer tutorials
- Smaller community
Other Python options to know
Google ADK
Python plus four more languages. Best if you deploy on Google Cloud. Install with pip install google-adk.
Microsoft Agent Framework
The current Microsoft choice for Python and .NET. Install with pip install agent-framework.
AutoGen
In maintenance mode with no new features. Do not start a new project on it.
Best AI agent frameworks for beginners in Python
If you are new to both Python and agents, follow this order. It gets you a result fast and teaches you what is happening.
Build one agent by hand
Write a Python script that calls a model and one tool. It takes an afternoon, and every framework makes more sense afterward.
Pick CrewAI, the OpenAI Agents SDK or smolagents
Rebuild the same agent and compare how much code you wrote.
Add limits and logging
Cap steps and cost, and log what the agent does.
Move up when you need control
Switch to PydanticAI for typed code or LangGraph for saved state and human approval.
Your first agent in four frameworks
Install the package, set your API key in your environment, then run the file. Change the model name to one you have access to. Check the official quickstart if a version has changed.
CrewAI
Python: role-based agent
from crewai import Agent, Task, Crew
researcher = Agent(
role="Researcher",
goal="Find clear facts about {topic}",
backstory="You check facts carefully.",
)
task = Task(
description="Research {topic} and list 3 facts.",
expected_output="Three short facts",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
print(crew.kickoff(inputs={"topic": "solar power"}))
OpenAI Agents SDK
Python: three lines of setup
from agents import Agent, Runner agent = Agent(name="Helper", instructions="Answer in one short sentence.") result = Runner.run_sync(agent, "What is an AI agent?") print(result.final_output)
PydanticAI
Python: typed agent
from pydantic_ai import Agent
agent = Agent("openai:gpt-5.5")
result = agent.run_sync("What is an AI agent?")
print(result.output)
LangChain
Python: agent with one tool
from langchain.agents import create_agent
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It's always sunny in {city}!"
agent = create_agent(
model="openai:gpt-5.5",
tools=[get_weather],
system_prompt="You are a helpful assistant",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Weather in Paris?"}]}
)
print(result["messages"][-1].content)
Tip
Test with a cheap model and a small task. Watch the token use before you add more tools.
Which Python framework should you pick?
| If you… | Pick |
|---|---|
| Are new and want a working agent team fast | CrewAI |
| Want the least code and already use OpenAI | OpenAI Agents SDK |
| Want to understand how agents work inside | smolagents |
| Love type hints and tests | PydanticAI |
| Need to pause for a human or resume after a crash | LangGraph |
| Want the most integrations | LangChain |
| Need an agent to search your files | LlamaIndex |
| Are stuck on Python 3.9 | Agno |
What Python agents really cost
The code is free. Bills come from three places: model calls, hosting and tracking tools.
| Tool | Free option | Paid option |
|---|---|---|
| CrewAI cloud | Basic: 50 workflow runs a month | Enterprise: custom price |
| LangSmith (for LangGraph and LangChain) | Developer: $0, 1 seat, 5,000 base traces | Plus: $39 per seat per month |
| LlamaCloud | 10,000 credits | Starter $50 per month, Pro $500 per month |
| OpenAI, Anthropic, Google | Depends on the model | You pay per token |
Watch out for loops
An agent that keeps retrying can spend real money in any framework. Set a step limit in your code and a spending limit on your model account.
Common mistakes to avoid
- Skipping the virtual environment. Package clashes cause strange errors.
- Not pinning versions. These libraries change fast. Pin them in
requirements.txt. - Following old tutorials. Code from 2024 often no longer runs. Use the official quickstart.
- Giving an agent too many tools. Start with two or three.
- Running AI-written code without a sandbox. This matters most with smolagents.
Our pick
Start with CrewAI, or with smolagents if you want to learn what happens inside. Use the OpenAI Agents SDK for the smallest setup. When your agent needs typed output, choose PydanticAI, and when it needs saved state and human approval, move to LangGraph. Whatever you choose, set step and cost limits on day one.
Frequently asked questions
What is the best AI agent framework for Python?
For most beginners it is CrewAI. For control and long jobs it is LangGraph, and for typed code it is PydanticAI.
Which Python version do I need?
Python 3.10 or newer works for all of them except Agno, which starts at 3.9. CrewAI needs a version below 3.14.
Do I need LangChain to build an AI agent in Python?
No. CrewAI, the OpenAI Agents SDK, smolagents and PydanticAI all work without it.
Are these frameworks free?
Yes, the code is free and open source. You pay for model calls, and optionally for hosting and tracking.
Can I run AI agents in Python without an API bill?
You can use a local model with tools like smolagents, though quality depends on the model and your computer.
Is AutoGen still a good choice?
No. It is in maintenance mode. New projects should use Microsoft Agent Framework or another tool from this list.