Python LLM libraries

Updated Nov 2026

Python LLM libraries wrap calls to large language models (LLMs) and organize the work around them, such as tool calls, retrieval, and multi-step workflows. These libraries are how developers build AI agents and chat features on top of a model provider's API.

Popularity

LangChain has the most monthly downloads in this comparison, at 156.9M.

LibraryMonthly downloadsStarsLast releaseLicense
LangChain
156.9M
149.6KNov 2026MIT
LangGraph
60.4M
45.1KNov 2026MIT
Pydantic AI
36.2M
21.3KNov 2026MIT
Google ADK
10.9M
22.3KNov 2026Apache-2.0
Instructor
10.1M
14.1KSep 2026MIT
DSPy
5.8M
39.1KNov 2026MIT
LlamaIndex Core
5.7M
53.0KNov 2026MIT
CrewAI
2.6M
61.1KNov 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

LangChain is a framework for building agents and other applications on large language models. init_chat_model opens a chat model from any supported provider by name, and create_agent combines a model, a list of tools, and middleware into an agent that calls tools until it reaches an answer. A declared schema returns the final answer as validated data. Each provider, vector store, and tool comes from a separate integration package, and the agent itself runs on LangGraph.

Downloads / mo
156.9M
Stars
149.6K
Last release
1.5.0
License
MIT

Strengths

  • Creates customizable tool agents. Compose a model, tools, and middleware with create_agent.
  • Validates structured agent responses. Declare a schema and receive validated data in structured_response.

Limitations

  • Provider integrations install separately. Install the package for the chosen model provider.
  • JSON schemas need explicit strategies. Wrap schema dictionaries in ProviderStrategy or ToolStrategy.

Quickstart

From agents.md
$ pip install -U "langchain[openai]"
from langchain.chat_models import init_chat_model

model = init_chat_model("gpt-6.1-sol")
response = model.invoke("Why do parrots have colorful feathers?")
print(response)

LangChain examples

From open-source projects on GitHub

LangGraph is a low-level framework and runtime for long-running, stateful agents. A workflow is a graph: nodes are Python functions that read and update a shared state, and edges decide which node runs next, including loops and branches. The graph compiles before it runs, and compilation is where a checkpointer attaches. With a checkpointer, a run survives failures and resumes where it stopped, and an interrupt pauses the graph to wait for human input.

Downloads / mo
60.4M
Stars
45.1K
Last release
1.2.22
License
MIT

Strengths

  • Pauses for human input. An interrupt saves the graph state and waits for external input before the run continues.

Quickstart

From graph-api.md
$ pip install langgraph
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END

class State(TypedDict):
    message: str

builder = StateGraph(State)
builder.add_node('echo', lambda state: {'message': state['message']})
builder.add_edge(START, 'echo')
builder.add_edge('echo', END)
print(builder.compile().invoke({'message': 'hello'}))

LangGraph examples

From open-source projects on GitHub

Pydantic AI is an agent framework from the Pydantic team. An Agent has a model name, instructions, tools, and an output type, and run executes the agent loop and returns output validated against that type. Switching providers means changing the model string, and a fallback model can take over when a provider fails. Tools can require human approval before they run, and agents can run under durable execution engines such as Temporal. The pydantic-ai-slim package installs the core, with each provider added as an extra.

Downloads / mo
36.2M
Stars
21.3K
Last release
2.68.0
License
MIT

Strengths

  • Swaps models by name. The same agent runs on another provider by changing the model string.
  • Tool approval built in. A tool marked requires_approval waits for a person to approve the call.

Quickstart

From agents.md
$ pip install "pydantic-ai-slim[openai]"
from pydantic_ai import Agent, AgentRunResultEvent, AgentStreamEvent

agent = Agent('openai:gpt-6.1-sol')

result_sync = agent.run_sync('What is the capital of Italy?')
print(result_sync.output)
#> The capital of Italy is Rome.

Pydantic AI examples

From open-source projects on GitHub

Google ADK, the Agent Development Kit, is a framework for defining, evaluating, and deploying agents in Python code. An agent combines a model, instructions, and tools, which can be Python functions, OpenAPI specs, or MCP tools, and several agents can be composed into a hierarchy. A graph-based workflow runtime adds routing, loops, retries, and human input to a run. The kit is optimized for Gemini but works with other models, and agents deploy to Cloud Run or Google's managed agent runtime.

Downloads / mo
10.9M
Stars
22.3K
Last release
2.14.1
License
Apache-2.0

Strengths

  • Model-agnostic, Gemini-first. Agents run on Gemini or on other models, and work with other frameworks.

Quickstart

From runners.py
$ pip install google-adk
import asyncio
import os
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner

async def main():
    agent = Agent(name='assistant', model=os.environ['GEMINI_MODEL'], instruction='Answer briefly.')
    runner = InMemoryRunner(agent=agent)
    await runner.run_debug('Hello')

asyncio.run(main())

Google ADK examples

From open-source projects on GitHub

Instructor returns structured data from a language model as a validated Pydantic object. A Pydantic class declares the fields, instructor.from_provider opens a client for a named provider and model, and a call with response_model returns an instance of that class instead of raw text. When validation fails, Instructor sends the errors back to the model and retries. The library handles single extraction calls, and its README points to Pydantic AI for full agents.

Downloads / mo
10.1M
Stars
14.1K
Last release
1.17.0
License
MIT

Strengths

  • Same code across providers. instructor.from_provider takes a provider and model name, such as OpenAI, Anthropic, Google, or Ollama, and returns the same client.
  • Retries on failed validation. When a reply fails Pydantic validation, Instructor sends the request again.

Limitations

  • Extraction only. The Instructor README points agent workflows to Pydantic AI.

Quickstart

From README.md
$ pip install instructor
import instructor
from pydantic import BaseModel


# Define what you want
class User(BaseModel):
 name: str
 age: int


# Extract it from natural language
client = instructor.from_provider("openai/gpt-4o-mini")
user = client.chat.completions.create(
 response_model=User,
 messages=[{"role": "user", "content": "John is 25 years old"}],
)

print(user) # User(name='John', age=25)

Instructor examples

From open-source projects on GitHub

DSPy builds language model programs from Python code instead of hand-written prompts. A signature declares a task's typed inputs and outputs, such as a question in and an answer out, and modules such as Predict and ChainOfThought turn a signature into model calls. Modules compose into larger programs, including retrieval pipelines and agent loops. Optimizers such as GEPA then tune the prompts, and optionally the weights, using example data and a scoring function.

Downloads / mo
5.8M
Stars
39.1K
Last release
3.5.0
License
MIT

Strengths

  • Defines tasks with typed signatures. Declare input and output fields instead of assembling prompts manually.
  • Optimizes prompts against a metric. Use examples and a scoring function to tune the program.

Limitations

  • Optimization needs examples and metrics. Provide evaluation data and a scoring function before optimizing the program.
  • Cached streams skip token chunks. Cached results yield the final prediction rather than individual streamed tokens.

Quickstart

From index.md
$ pip install dspy
import os
import dspy

dspy.configure(lm=dspy.LM(os.environ['DSPY_MODEL']))
answer = dspy.Predict('question -> answer')
print(answer(question='What is a hash table?').answer)

DSPy examples

From open-source projects on GitHub

LlamaIndex Core

LlamaIndex is a framework for applications that answer from a body of documents. The llama-index-core package contains the core classes, and models, embeddings, and vector stores come from separate integration packages. SimpleDirectoryReader loads files, VectorStoreIndex splits them into chunks and embeds them, and as_query_engine answers questions from the retrieved chunks. Indexes start in memory and persist to disk on request. Agents and event-driven workflows build on the same parts.

Downloads / mo
5.7M
Stars
53.0K
Last release
0.14.26
License
MIT

Strengths

  • Indexes documents for model queries. Build an index and retrieve relevant context through a query engine.
  • Wraps functions as agent tools. Convert existing functions into tools with inferred schemas.

Limitations

  • Streaming waits for earlier calls. Earlier model calls finish before the final answer starts streaming.
  • Indexes start in memory. Persist index storage to retain it after the process exits.

Quickstart

From README.md
$ pip install llama-index-core llama-index-llms-openai
import asyncio
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
# Define a simple calculator tool
def multiply(a: float, b: float) -> float:
 """Useful for multiplying two numbers."""
 return a * b
# Create an agent workflow with our calculator tool
agent = FunctionAgent(
 tools= [multiply],
 llm= OpenAI(model="gpt-4o-mini"),
 system_prompt="You are a helpful assistant that can multiply two numbers.",
)
async def main():
 # Run the agent
 response = await agent.run("What is 1234 * 4567?")
 print(str(response))
# Run the agent
if __name__ == "__main__":
 asyncio.run(main())

LlamaIndex Core examples

From open-source projects on GitHub

CrewAI is a framework for multi-agent workflows in two forms. A crew groups agents, each with a role, a goal, and tools, and assigns them a list of tasks that run in a sequential or hierarchical process. Flows are event-driven sequences of steps that combine single model calls, plain code, and crews. The crewai command creates a project in which agents and tasks are defined in YAML files, and kickoff starts a run.

Downloads / mo
2.6M
Stars
61.1K
Last release
1.15.41
License
MIT

Strengths

  • Role-based crews. Each crew assigns tasks to agents with their own roles and runs them in a set process.

Quickstart

From crews.md
$ pip install crewai
import os
from crewai import Agent, Task, Crew, Process

agent = Agent(role='Explainer', goal='Explain programming concepts', backstory='You teach concise technical lessons.', llm=os.environ['CREWAI_MODEL'])
task = Task(description='Explain a hash table.', expected_output='A short explanation.', agent=agent)
result = Crew(agents=[agent], tasks=[task], process=Process.sequential).kickoff()
print(result.raw)

CrewAI examples

From open-source projects on GitHub

FAQ

Instructor returns typed data from a single model call. LangChain, Pydantic AI, Google ADK, and CrewAI build tool-calling agents, LangGraph runs long, stateful workflows, LlamaIndex queries indexed documents, and DSPy optimizes prompts against examples.

LangChain builds an agent from a model, tools, and middleware with create_agent. LangGraph is the lower-level runtime underneath, where a workflow is a graph of nodes over shared state, with checkpoints that let a run pause for human input and resume.

LangChain centers on agents and a standard interface to models, tools, and vector stores. LlamaIndex centers on loading documents into indexes and querying them through retrievers and query engines, and it also builds agents and workflows.

Pydantic AI, from the Pydantic team, runs a typed agent loop in which tools and outputs are Pydantic models and a model change is a string swap. LangChain composes agents from a model, tools, and middleware, with a separate integration package for each provider.

CrewAI groups agents with roles and goals into a crew that works through a list of tasks, and adds event-driven Flows for fixed steps. LangChain builds a single agent from a model and tools, and leaves multi-agent orchestration to LangGraph.

DSPy declares each model task as a signature of typed inputs and outputs, and its optimizers tune the prompts against examples and a scoring function. LangChain prompts and agent instructions are written by hand.

For coding agents

Found your LLM library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official