con un clic
langchain
// Build agents with a prebuilt architecture and integrations for any model or tool. Use when creating tool-calling agents, switching model providers, or adding structured output.
// Build agents with a prebuilt architecture and integrations for any model or tool. Use when creating tool-calling agents, switching model providers, or adding structured output.
Use this skill when migrating inline code samples from LangChain docs (MDX files) into external, testable code files that are extracted by this repo’s snippet scripts and used as Mintlify snippets. Applies when extracting code blocks from documentation, creating runnable code samples, using snippet delineators, or wiring snippet output into MDX includes.
Build batteries-included agents with planning, context management, subagent delegation, and sandboxed execution. Use for complex, multi-step tasks that need built-in capabilities.
Build stateful, durable agent workflows with LangGraph. Use when you need custom graph-based control flow, human-in-the-loop, persistence, or multi-agent orchestration.
Trace, evaluate, and deploy AI agents and LLM applications with LangSmith. Use when adding observability, running evaluations, engineering prompts, or deploying agents to production.
Use when the user wants the current date and time written to a file via the bundled script inside the sandbox.
| name | langchain |
| description | Build agents with a prebuilt architecture and integrations for any model or tool. Use when creating tool-calling agents, switching model providers, or adding structured output. |
| license | MIT |
| compatibility | Python 3.10+, Node.js 20+ |
| metadata | {"author":"langchain-ai","version":"1.0"} |
LangChain is an open-source framework with a prebuilt agent architecture and integrations for any model or tool. Build agents and LLM-powered applications in under 10 lines of code, with integrations for OpenAI, Anthropic, Google, and hundreds more.
Use LangChain when you need to:
create_agent() and a prebuilt agent loopinit_chat_model()# Python
pip install -U langchain
# JavaScript/TypeScript
npm install langchain @langchain/core
Install a provider integration:
# Python
pip install -U langchain-openai # or langchain-anthropic, langchain-google-genai
# JavaScript/TypeScript
npm install @langchain/openai # or @langchain/anthropic, @langchain/google-genai
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.4",
tools=[get_weather],
system_prompt="You are a helpful assistant",
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What is the weather in SF?"}]}
)
from langchain.chat_models import init_chat_model
# Switch providers by changing the string
model = init_chat_model("openai:gpt-5.4")
model = init_chat_model("anthropic:claude-opus-4-6")
model = init_chat_model("google_genai:gemini-2.5-flash-lite")
from langchain.tools import tool
@tool
def search(query: str) -> str:
"""Search the web for information."""
return "search results"
get_weather, not get-weather.type, name, or description as these conflict with the tool schema.langchain-openai). The base langchain package does not include providers."provider:model-name" format with init_chat_model() (e.g., "openai:gpt-5.4").For SDK class and method details, use the LangChain API Reference site:
https://reference.langchain.com/python/langchain-corehttps://reference.langchain.com/mcp