> ## Documentation Index
> Fetch the complete documentation index at: https://www.edenai.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain

> Integrate Eden AI with LangChain for building powerful LLM applications with access to 500+ models.

export const TechArticleSchema = ({title, description, path, articleSection, about, proficiencyLevel = "Beginner", dependencies, keywords = [], datePublished, dateModified, image, inLanguage = "en"}) => {
  const baseUrl = "https://www.edenai.co/docs";
  const canonicalUrl = `${baseUrl}/${path}`.replace(/\/+$/, "");
  const ogParams = new URLSearchParams({
    division: articleSection || "",
    title: title || "",
    description: description || ""
  });
  const resolvedImage = image || `https://edenai.mintlify.app/_mintlify/api/og?${ogParams.toString()}`;
  const data = {
    "@context": "https://schema.org",
    "@type": "TechArticle",
    "@id": `${canonicalUrl}#techarticle`,
    mainEntityOfPage: {
      "@type": "WebPage",
      "@id": canonicalUrl
    },
    headline: title,
    name: title,
    description: description,
    url: canonicalUrl,
    inLanguage: inLanguage,
    isPartOf: {
      "@type": "WebSite",
      name: "Eden AI Documentation",
      url: baseUrl
    },
    author: [{
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/"
    }],
    publisher: {
      "@type": "Organization",
      name: "Eden AI",
      url: "https://www.edenai.co/",
      logo: {
        "@type": "ImageObject",
        url: "https://www.edenai.co/assets/logo.png"
      }
    }
  };
  if (articleSection) data.articleSection = articleSection;
  if (about) data.about = {
    "@type": "Thing",
    name: about
  };
  if (proficiencyLevel) data.proficiencyLevel = proficiencyLevel;
  if (dependencies) data.dependencies = dependencies;
  if (keywords && keywords.length) data.keywords = keywords;
  if (datePublished) data.datePublished = datePublished;
  if (dateModified) data.dateModified = dateModified;
  data.image = Array.isArray(resolvedImage) ? resolvedImage : [resolvedImage];
  const json = JSON.stringify(data);
  const schemaId = `techarticle-${canonicalUrl}`;
  React.useEffect(() => {
    if (typeof document === "undefined") return;
    document.querySelectorAll(`script[data-schema-id="${schemaId}"]`).forEach(n => n.remove());
    const script = document.createElement("script");
    script.type = "application/ld+json";
    script.dataset.schemaId = schemaId;
    script.textContent = json;
    document.head.appendChild(script);
    return () => script.remove();
  }, [json, schemaId]);
  return null;
};

<TechArticleSchema title={"LangChain"} description={"Integrate Eden AI with LangChain for building powerful LLM applications with access to 500+ models."} path="v3/integrations/langchain" articleSection="AI Frameworks" about={"LLM Framework Integration"} proficiencyLevel="Intermediate" keywords={["Eden AI", "AI API", "LangChain"]} datePublished="2026-05-06T00:00:00Z" dateModified="2026-05-07T00:00:00Z" />

Integrate Eden AI with LangChain for building powerful LLM applications with access to 500+ models.

## Overview

[LangChain](https://langchain.com) is a framework for developing applications powered by language models. Eden AI integrates seamlessly with LangChain's `ChatOpenAI` class, giving you access to multiple providers through a single interface.

## Installation

<CodeGroup>
  ```bash Python theme={null}
  pip install "langchain~=1.2" "langchain-openai~=1.1" "langchain-community~=0.4" "langgraph~=1.0"
  ```

  ```bash TypeScript theme={null}
  npm install langchain @langchain/openai
  ```
</CodeGroup>

## Quick Start (Python)

<CodeGroup>
  ```python Python theme={null}
  from langchain_openai import ChatOpenAI
  from langchain_core.messages import HumanMessage, SystemMessage

  llm = ChatOpenAI(
      model="openai/gpt-4",
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  messages = [
      SystemMessage(content="You are a helpful assistant."),
      HumanMessage(content="What is LangChain?")
  ]

  response = llm.invoke(messages)
  print(response.content)
  ```
</CodeGroup>

## Quick Start (TypeScript)

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { ChatOpenAI } from "@langchain/openai";
  import { HumanMessage, SystemMessage } from "@langchain/core/messages";

  const llm = new ChatOpenAI({
    modelName: "openai/gpt-4",
    openAIApiKey: "YOUR_EDEN_AI_API_KEY",
    configuration: {
      baseURL: "https://api.edenai.run/v3",
    },
  });

  const messages = [
    new SystemMessage("You are a helpful assistant."),
    new HumanMessage("What is LangChain?"),
  ];

  const response = await llm.invoke(messages);
  console.log(response.content);
  ```
</CodeGroup>

## Available Models

Pass any `provider/model` string as the `model` (or `modelName`) parameter. For example:

* `openai/gpt-4` — GPT-4
* `anthropic/claude-sonnet-4-5` — Claude Sonnet
* `google/gemini-2.5-flash` — Gemini Flash

## Prompt Templates

<CodeGroup>
  ```python Python theme={null}
  from langchain_openai import ChatOpenAI
  from langchain_core.prompts import ChatPromptTemplate

  llm = ChatOpenAI(
      model="openai/gpt-4",
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  prompt = ChatPromptTemplate.from_messages([
      ("system", "You are a helpful assistant that translates {input_language} to {output_language}."),
      ("human", "{text}")
  ])

  chain = prompt | llm

  response = chain.invoke({
      "input_language": "English",
      "output_language": "French",
      "text": "Hello, how are you?"
  })

  print(response.content)
  ```
</CodeGroup>

## Chains

<CodeGroup>
  ```python Python theme={null}
  from langchain_openai import ChatOpenAI
  from langchain_core.prompts import ChatPromptTemplate
  from langchain_core.output_parsers import StrOutputParser

  llm = ChatOpenAI(
      model="openai/gpt-4",
      api_key="YOUR_EDEN_AI_API_KEY",
      base_url="https://api.edenai.run/v3"
  )

  joke_prompt = ChatPromptTemplate.from_template("Tell me a joke about {topic}")
  explanation_prompt = ChatPromptTemplate.from_template("Explain this joke: {joke}")

  joke_chain = joke_prompt | llm | StrOutputParser()
  explanation_chain = explanation_prompt | llm | StrOutputParser()

  full_chain = {"joke": joke_chain} | explanation_chain

  result = full_chain.invoke({"topic": "programming"})
  print(result)
  ```
</CodeGroup>

## Environment Variables

<CodeGroup>
  ```bash .env theme={null}
  EDEN_AI_API_KEY=your_api_key_here
  ```

  ```python Python theme={null}
  import os
  from dotenv import load_dotenv
  from langchain_openai import ChatOpenAI

  load_dotenv()

  llm = ChatOpenAI(
      model="openai/gpt-4",
      api_key=os.getenv("EDEN_AI_API_KEY"),
      base_url="https://api.edenai.run/v3"
  )
  ```
</CodeGroup>

## Next Steps

* [OpenAI SDK (Python)](./openai-sdk-python) - Direct SDK usage
