LangChain Overview

website·Indexed 18 days ago

https://js.langchain.com/v0.1/docs/get_started/introduction/

Documentation providing an overview of LangChain, including core benefits and instructions for creating agents.

Tokens
846
Snippets
3
Records
8
Agent score
49%

What's inside LangChain

  1. Choose between LangChain, LangGraph, and Deep Agents

    v0.1

    Depending on the level of control and automation needed, choose the appropriate framework:

    • Deep Agents: Use for 'batteries-included' agents with built-in context compression, virtual filesystems, and subagent-spawning.
    • LangChain (create_agent): Use for a highly customizable agent harness that can be tailored to specific use cases and data.
    • LangGraph: Use for low-level orchestration of advanced workflows combining deterministic and agentic logic.
    • LangSmith: Use across any of these frameworks for tracing, debugging, and evaluating agent behavior.
  2. Create a custom agent using createAgent

    v0.1
    LangChain provides the createAgent function to build a minimal, configurable agent harness. An agent is composed of a model, tools, a prompt, and middleware. You can define custom tools using the tool function and a Zod schema for input validation.
    // Example using OpenAI
    // Install: npm install langchain zod @langchain/openai
    import { createAgent, tool } from "langchain";
    import * as z from "zod";
    
    const getWeather = tool(
      (input) => `It's always sunny in ${input.city}!`,
      {
        name: "get_weather",
        description: "Get the weather for a given city",
        schema: z.object({
          city: z.string().describe("The city to get the weather for"),
        }),
      }
    );
    
    const agent = createAgent({
      model: "gpt-5.5",
      tools: [getWeather],
    });
    
    console.log(
      await agent.invoke({
        messages: [{ role: "user", content: "What's the weather in San Francisco?" }],
      })
    );
  3. Configure model providers for createAgent

    v0.1
    The createAgent function supports multiple model providers via specific string identifiers. Ensure the corresponding provider package is installed (e.g., @langchain/openai, @langchain/google-genai, @langchain/anthropic).
    // Model identifier examples for createAgent:
    
    // OpenAI
    model: "gpt-5.5"
    
    // Google Gemini
    model: "google-genai:gemini-2.5-flash-lite"
    
    // Anthropic
    model: "claude-sonnet-4-6"
    
    // OpenRouter
    model: "openrouter:anthropic/claude-sonnet-4-6"
    
    // Fireworks
    model: "fireworks:accounts/fireworks/models/qwen3p5-397b-a17b"
    
    // Baseten
    model: "baseten:zai-org/GLM-5.2"
    
    // Ollama
    model: "ollama:devstral-2"
    
    // Azure OpenAI
    model: "azure_openai:gpt-5.5"
    
    // AWS Bedrock
    model: "bedrock:gpt-5.5"