> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-devupd-1765394015-eccef47.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat models

[Chat models](/oss/javascript/langchain/models) are language models that use a sequence of [messages](/oss/javascript/langchain/messages) as inputs and return messages as outputs <Tooltip tip="Older models that do not follow the chat model interface and instead use an interface that takes a string as input and returns a string as output. These models typically do not include the prefix 'Chat' in their name or include 'LLM' as a suffix.">(as opposed to plaintext)</Tooltip>.

## Install and use

<Tip>
  See [this section for general instructions on installing LangChain packages](/oss/javascript/langchain/install).
</Tip>

<AccordionGroup>
  <Accordion title="OpenAI">
    Install:

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

      ```bash yarn theme={null}
      yarn add @langchain/openai
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/openai
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    OPENAI_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatOpenAI } from "@langchain/openai";

    const model = new ChatOpenAI({ model: "gpt-4o-mini" });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="Anthropic">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/anthropic
      ```

      ```bash yarn theme={null}
      yarn add @langchain/anthropic
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/anthropic
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    ANTHROPIC_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatAnthropic } from "@langchain/anthropic";

    const model = new ChatAnthropic({
    model: "claude-3-sonnet-20240620",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="Google Gemini">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/google-genai
      ```

      ```bash yarn theme={null}
      yarn add @langchain/google-genai
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/google-genai
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    GOOGLE_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatGoogleGenerativeAI } from "@langchain/google-genai";

    const model = new ChatGoogleGenerativeAI({
    modelName: "gemini-2.5-flash-lite",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="Google VertexAI">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/google-vertexai
      ```

      ```bash yarn theme={null}
      yarn add @langchain/google-vertexai
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/google-vertexai
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    GOOGLE_APPLICATION_CREDENTIALS=credentials.json
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatVertexAI } from "@langchain/google-vertexai";

    const model = new ChatVertexAI({
    model: "gemini-2.5-flash",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="MistralAI">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/mistralai
      ```

      ```bash yarn theme={null}
      yarn add @langchain/mistralai
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/mistralai
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    MISTRAL_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatMistralAI } from "@langchain/mistralai";

    const model = new ChatMistralAI({
    model: "mistral-large-latest",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="FireworksAI">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/community
      ```

      ```bash yarn theme={null}
      yarn add @langchain/community
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/community
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    FIREWORKS_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatFireworks } from "@langchain/community/chat_models/fireworks";

    const model = new ChatFireworks({
    model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>

  <Accordion title="Groq">
    Install:

    <CodeGroup>
      ```bash npm theme={null}
      npm i @langchain/groq
      ```

      ```bash yarn theme={null}
      yarn add @langchain/groq
      ```

      ```bash pnpm theme={null}
      pnpm add @langchain/groq
      ```
    </CodeGroup>

    Add environment variables:

    ```bash theme={null}
    GROQ_API_KEY=your-api-key
    ```

    Instantiate the model:

    ```typescript theme={null}
    import { ChatGroq } from "@langchain/groq";

    const model = new ChatGroq({
    model: "llama-3.3-70b-versatile",
    temperature: 0
    });
    ```

    ```javascript theme={null}
    await model.invoke("Hello, world!")
    ```
  </Accordion>
</AccordionGroup>

## Featured models

<Info>
  **While these LangChain classes support the indicated advanced feature**, you may need to refer to provider-specific documentation to learn which hosted models or backends support the feature.
</Info>

| Model                                                                                | Stream | JSON mode | [Tool Calling](/oss/javascript/langchain/tools/) | [`withStructuredOutput()`](/oss/javascript/langchain/structured-output#the-.withstructuredoutput-method) | [Multimodal](/oss/javascript/langchain/messages#multimodal) |
| ------------------------------------------------------------------------------------ | ------ | --------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [`ChatOpenAI`](/oss/javascript/integrations/chat/openai/)                            | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatAnthropic`](/oss/javascript/integrations/chat/anthropic/)                      | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatGoogleGenerativeAI`](/oss/javascript/integrations/chat/google_generative_ai/)  | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatVertexAI`](/oss/javascript/integrations/chat/google_vertex_ai/)                | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`BedrockChat`](/oss/javascript/integrations/chat/bedrock/)                          | ✅      | ❌         | 🟡 (Bedrock Anthropic only)                      | 🟡 (Bedrock Anthropic only)                                                                              | 🟡 (Bedrock Anthropic only)                                 |
| [`ChatBedrockConverse`](/oss/javascript/integrations/chat/bedrock_converse/)         | ✅      | ❌         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatCloudflareWorkersAI`](/oss/javascript/integrations/chat/cloudflare_workersai/) | ✅      | ❌         | ❌                                                | ❌                                                                                                        | ❌                                                           |
| [`ChatCohere`](/oss/javascript/integrations/chat/cohere/)                            | ✅      | ❌         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatFireworks`](/oss/javascript/integrations/chat/fireworks/)                      | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatGroq`](/oss/javascript/integrations/chat/groq/)                                | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatMistralAI`](/oss/javascript/integrations/chat/mistral/)                        | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatOllama`](/oss/javascript/integrations/chat/ollama/)                            | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatTogetherAI`](/oss/javascript/integrations/chat/togetherai/)                    | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ✅                                                           |
| [`ChatXAI`](/oss/javascript/integrations/chat/xai/)                                  | ✅      | ✅         | ✅                                                | ✅                                                                                                        | ❌                                                           |

## Chat Completions API

Certain model providers offer endpoints that are compatible with OpenAI's (legacy) [Chat Completions API](https://platform.openai.com/docs/guides/completions). In such case, you can use [`ChatOpenAI`](/oss/javascript/integrations/chat/openai) with a custom `base_url` to connect to these endpoints. Note that features built on top of the Chat Completions API may not be fully supported by `ChatOpenAI`; in such cases, consider using a provider-specific class if available.

<Accordion title="Example: OpenRouter">
  To use OpenRouter, you will need to sign up for an account and obtain an [API key](https://openrouter.ai/docs/api-reference/authentication).

  ```typescript theme={null}
  import { ChatOpenAI } from "@langchain/openai";

  const model = new ChatOpenAI({
      model: "...", // Specify a model available on OpenRouter
      configuration: {
      apiKey: "OPENROUTER_API_KEY",
      baseURL: "https://openrouter.ai/api/v1",
      }
  });
  ```

  Refer to the [OpenRouter documentation](https://openrouter.ai/docs/quickstart) for more details.
</Accordion>

## All chat models

<Columns cols={3}>
  <Card title="Alibaba Tongyi" icon="link" href="/oss/javascript/integrations/chat/alibaba_tongyi" arrow="true" cta="View guide" />

  <Card title="Anthropic" icon="link" href="/oss/javascript/integrations/chat/anthropic" arrow="true" cta="View guide" />

  <Card title="Arcjet Redact" icon="link" href="/oss/javascript/integrations/chat/arcjet" arrow="true" cta="View guide" />

  <Card title="Azure OpenAI" icon="link" href="/oss/javascript/integrations/chat/azure" arrow="true" cta="View guide" />

  <Card title="Baidu Qianfan" icon="link" href="/oss/javascript/integrations/chat/baidu_qianfan" arrow="true" cta="View guide" />

  <Card title="Amazon Bedrock" icon="link" href="/oss/javascript/integrations/chat/bedrock" arrow="true" cta="View guide" />

  <Card title="Amazon Bedrock Converse" icon="link" href="/oss/javascript/integrations/chat/bedrock_converse" arrow="true" cta="View guide" />

  <Card title="Cerebras" icon="link" href="/oss/javascript/integrations/chat/cerebras" arrow="true" cta="View guide" />

  <Card title="Cloudflare Workers AI" icon="link" href="/oss/javascript/integrations/chat/cloudflare_workersai" arrow="true" cta="View guide" />

  <Card title="Cohere" icon="link" href="/oss/javascript/integrations/chat/cohere" arrow="true" cta="View guide" />

  <Card title="Deep Infra" icon="link" href="/oss/javascript/integrations/chat/deep_infra" arrow="true" cta="View guide" />

  <Card title="DeepSeek" icon="link" href="/oss/javascript/integrations/chat/deepseek" arrow="true" cta="View guide" />

  <Card title="Fake LLM" icon="link" href="/oss/javascript/integrations/chat/fake" arrow="true" cta="View guide" />

  <Card title="Fireworks" icon="link" href="/oss/javascript/integrations/chat/fireworks" arrow="true" cta="View guide" />

  <Card title="Friendli" icon="link" href="/oss/javascript/integrations/chat/friendli" arrow="true" cta="View guide" />

  <Card title="Google GenAI" icon="link" href="/oss/javascript/integrations/chat/google_generative_ai" arrow="true" cta="View guide" />

  <Card title="Google Vertex AI" icon="link" href="/oss/javascript/integrations/chat/google_vertex_ai" arrow="true" cta="View guide" />

  <Card title="Groq" icon="link" href="/oss/javascript/integrations/chat/groq" arrow="true" cta="View guide" />

  <Card title="IBM watsonx.ai" icon="link" href="/oss/javascript/integrations/chat/ibm" arrow="true" cta="View guide" />

  <Card title="Llama CPP" icon="link" href="/oss/javascript/integrations/chat/llama_cpp" arrow="true" cta="View guide" />

  <Card title="Minimax" icon="link" href="/oss/javascript/integrations/chat/minimax" arrow="true" cta="View guide" />

  <Card title="MistralAI" icon="link" href="/oss/javascript/integrations/chat/mistral" arrow="true" cta="View guide" />

  <Card title="Moonshot" icon="link" href="/oss/javascript/integrations/chat/moonshot" arrow="true" cta="View guide" />

  <Card title="Novita AI" icon="link" href="/oss/javascript/integrations/chat/novita" arrow="true" cta="View guide" />

  <Card title="Ollama" icon="link" href="/oss/javascript/integrations/chat/ollama" arrow="true" cta="View guide" />

  <Card title="OpenAI" icon="link" href="/oss/javascript/integrations/chat/openai" arrow="true" cta="View guide" />

  <Card title="Perplexity" icon="link" href="/oss/javascript/integrations/chat/perplexity" arrow="true" cta="View guide" />

  <Card title="PremAI" icon="link" href="/oss/javascript/integrations/chat/premai" arrow="true" cta="View guide" />

  <Card title="Tencent Hunyuan" icon="link" href="/oss/javascript/integrations/chat/tencent_hunyuan" arrow="true" cta="View guide" />

  <Card title="Together" icon="link" href="/oss/javascript/integrations/chat/togetherai" arrow="true" cta="View guide" />

  <Card title="WebLLM" icon="link" href="/oss/javascript/integrations/chat/web_llm" arrow="true" cta="View guide" />

  <Card title="xAI" icon="link" href="/oss/javascript/integrations/chat/xai" arrow="true" cta="View guide" />

  <Card title="YandexGPT" icon="link" href="/oss/javascript/integrations/chat/yandex" arrow="true" cta="View guide" />

  <Card title="ZhipuAI" icon="link" href="/oss/javascript/integrations/chat/zhipuai" arrow="true" cta="View guide" />
</Columns>

<Info>
  If you'd like to contribute an integration, see [Contributing integrations](/oss/javascript/contributing#add-a-new-integration).
</Info>

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/chat/index.mdx)
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
