9 KiB
Build a typed agent in Pydantic AI. Long-running, stateful agents suit LangGraph. Apps tied to one model vendor can use that vendor's Python AI agent library.
How to choose:
- Typed agents: Pydantic AI, or LangGraph for long-running, stateful ones
- Agents on Claude, OpenAI, or Gemini models: Claude Agent SDK, OpenAI Agents SDK, or Google ADK
- Skills for your coding agent: Django AI Skills, Sentry Skills, or Trail of Bits Skills
- MCP servers and clients: MCP Python SDK, or FastMCP to compose and proxy servers
- Sandboxing AI-written code: Monty
- A personal assistant in your chat apps: Hermes Agent, or AstrBot for QQ, Feishu, and DingTalk
- Prompts tuned against a metric: DSPy
- Agent data: Instructor for structured output, LlamaIndex for RAG, Mem0 for memory
- Open models from the Hugging Face Hub: Transformers
- Running open models locally: Ollama, llama-cpp-python in your own process, MLX LM on Apple silicon
- Serving open models: vLLM or SGLang
- Image and video generation: Diffusers
- Fine-tuning: TRL with PEFT adapters, Unsloth for less GPU memory, Axolotl from YAML
- Speech: faster-whisper, FunASR for Chinese, gTTS for text to speech
Pydantic AI comes from the Pydantic team and is typed end to end. Outputs, tools, and dependencies all carry types, so your type checker knows what an agent returns. Switching models takes one string. Give an agent an output type and tools, and every run comes back validated.
LangGraph is a low-level orchestration framework for long-running, stateful agents, and it can mix hand-coded steps with LLM-driven ones in one graph. For your first agent, its docs suggest LangChain's agents instead: a minimal harness built on LangGraph, which you extend through middleware.
The Claude Agent SDK gives you the tools and agent loop behind Claude Code, so it fits agents that read files, run commands, and edit code. Call query() for a one-off task, and switch to ClaudeSDKClient when the next step depends on Claude's reply, as in a chat.
The OpenAI Agents SDK keeps to a small set of primitives: use it when you want the runtime to handle turns, tool calls, handoffs, and guardrails for you. Despite the name, it isn't limited to OpenAI models.
Google ADK is optimized for Gemini but model-agnostic. Start a project with adk create.
All three skill collections install from a Claude Code plugin marketplace. Django AI Skills and Sentry Skills follow the open Agent Skills format, so other coding agents can load them too. Sentry Skills is written for Sentry's own engineers, so some of its skills follow Sentry's internal standards.
CrewAI splits an app into Flows, which manage state and control execution, and Crews, teams of agents that work on one task together. For a production app, start with a Flow, and hand a Crew only the steps that need autonomy.
The MCP Python SDK reads each tool's schema from its type hints and docstring, so you write no JSON Schema or request handlers. FastMCP wrote the high-level API that the SDK took in. The standalone project is a fuller framework: it can mount several servers into one and proxy another MCP server through your own.
Monty is a Python sandbox written in Rust for code written by AI. It runs Code Mode in Pydantic AI, where the model writes one Python program that calls your tools, instead of one tool call per action. The sandbox has no filesystem, environment variables, or network, so the code reaches your host only through the functions and mounts you pass in. Open a pool of workers and check out a session, setting memory and time limits on the checkout. A host function runs with your process's full authority, so validate its arguments like any untrusted input. Monty implements only enough Python for a model to express what it wants, so turn on type checking to catch most unsupported code before it runs.
Hermes Agent talks to you on Telegram, Discord, Slack, WhatsApp, and Signal from one gateway process, and writes itself new skills as it works. Since it runs commands for whoever it lets in, allow only your own account on its gateway with an allowlist, and leave approval prompts on for dangerous commands. AstrBot covers chat apps such as QQ, Feishu, and DingTalk. It's AGPL, while Hermes Agent is MIT.
DSPy has you write structured signatures, not prompts, and its optimizers tune the prompts for you. Before they can, define a metric and score a baseline to beat.
Instructor turns an LLM's reply into a validated Pydantic model, and when validation fails, it retries with the error message. Its docs draw the line at extraction versus agents: Instructor for the first, Pydantic AI for the second.
LlamaIndex builds agents over your own data. Its high-level API goes from documents to answers in a few lines, and its lower-level API lets you replace any part.
Mem0 gives an agent memory of each user: search their memories before the model answers, then add the new exchange. Run it as a library in your app, or as a self-hosted server for a team.
Transformers is the model definition that most training frameworks and inference engines share, Axolotl, Unsloth, vLLM, and SGLang among them. Load a model from the Hugging Face Hub with from_pretrained(), then run it through Pipeline for inference or Trainer for training. For large production deployments, its docs send you to vLLM or SGLang.
The Ollama Python library talks to Ollama, which runs models on your computer. Start Ollama and pull a model with ollama pull, then pass the model's name to chat(). llama-cpp-python gives you Python bindings for llama.cpp, so the model runs inside your program. Load a GGUF file with the Llama class, or fetch one from the Hugging Face Hub with Llama.from_pretrained(). Its completions come back in the OpenAI format. On a Mac, MLX LM runs and fine-tunes models on Apple silicon.
vLLM runs batch inference offline or an OpenAI-compatible server, so apps written for the OpenAI API work unchanged. SGLang is optimized for agentic workloads, RL rollouts, and large-scale serving.
Diffusers centers on the DiffusionPipeline: a few lines generate an image, video, or audio clip.
Start fine-tuning with LoRA or QLoRA rather than training every weight, as both PEFT and Unsloth advise. TRL trains with methods from SFT to DPO and GRPO, and every TRL trainer takes a peft_config for PEFT adapters. Axolotl keeps the whole pipeline, from dataset preprocessing to inference, in one YAML file.
faster-whisper reimplements Whisper on CTranslate2 for the same accuracy in less time and memory. For Chinese audio, FunASR's AutoModel chains speech recognition with voice activity detection, punctuation, and speaker models in one call. gTTS speaks through Google Translate's undocumented speech feature, so upstream changes can break it without notice.