Chat models
Chat models are language models that use a sequence of messages as inputs and return messages as outputs (as opposed to using plain text). These are generally newer models.
info
If you'd like to write your own chat model, see this how-to. If you'd like to contribute an integration, see Contributing integrations.
- OpenAI
- Anthropic
- Azure
- AWS
- Cohere
- NVIDIA
- FireworksAI
- Groq
- MistralAI
- TogetherAI
pip install -qU langchain-openai
import getpass
import os
os.environ["OPENAI_API_KEY"] = getpass.getpass()
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4o-mini")
pip install -qU langchain-anthropic
import getpass
import os
os.environ["ANTHROPIC_API_KEY"] = getpass.getpass()
from langchain_anthropic import ChatAnthropic
model = ChatAnthropic(model="claude-3-5-sonnet-20240620")
pip install -qU langchain-openai
import getpass
import os
os.environ["AZURE_OPENAI_API_KEY"] = getpass.getpass()
from langchain_openai import AzureChatOpenAI
model = AzureChatOpenAI(
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
azure_deployment=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
openai_api_version=os.environ["AZURE_OPENAI_API_VERSION"],
)
pip install -qU langchain-google-vertexai
# Ensure your VertexAI credentials are configured
from langchain_google_vertexai import ChatVertexAI
model = ChatVertexAI(model="gemini-1.5-flash")
pip install -qU langchain-aws
# Ensure your AWS credentials are configured
from langchain_aws import ChatBedrock
model = ChatBedrock(model="anthropic.claude-3-5-sonnet-20240620-v1:0",
beta_use_converse_api=True)
pip install -qU langchain-cohere
import getpass
import os
os.environ["COHERE_API_KEY"] = getpass.getpass()
from langchain_cohere import ChatCohere
model = ChatCohere(model="command-r-plus")
pip install -qU langchain-nvidia-ai-endpoints
import getpass
import os
os.environ["NVIDIA_API_KEY"] = getpass.getpass()
from langchain_nvidia_ai_endpoints import ChatNVIDIA
model = ChatNVIDIA(model="meta/llama3-70b-instruct")
pip install -qU langchain-fireworks
import getpass
import os
os.environ["FIREWORKS_API_KEY"] = getpass.getpass()
from langchain_fireworks import ChatFireworks
model = ChatFireworks(model="accounts/fireworks/models/llama-v3p1-70b-instruct")
pip install -qU langchain-groq
import getpass
import os
os.environ["GROQ_API_KEY"] = getpass.getpass()
from langchain_groq import ChatGroq
model = ChatGroq(model="llama3-8b-8192")
pip install -qU langchain-mistralai
import getpass
import os
os.environ["MISTRAL_API_KEY"] = getpass.getpass()
from langchain_mistralai import ChatMistralAI
model = ChatMistralAI(model="mistral-large-latest")
pip install -qU langchain-openai
import getpass
import os
os.environ["TOGETHER_API_KEY"] = getpass.getpass()
from langchain_openai import ChatOpenAI
model = ChatOpenAI(
base_url="https://api.together.xyz/v1",
api_key=os.environ["TOGETHER_API_KEY"],
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
)
model.invoke("Hello, world!")
Featured Providers
info
While all these LangChain classes support the indicated advanced feature, you may have to open the provider-specific documentation to learn which hosted models or backends support the feature.
All chat models
Name | Description |
---|---|
AI21 Labs | Overview |
Alibaba Cloud PAI EAS | Alibaba Cloud PAI (Platform for AI) is a lightweight and cost-efficie... |
Anthropic | This notebook provides a quick overview for getting started with Anth... |
Anyscale | This notebook demonstrates the use of langchain.chat_models.ChatAnysc... |
Azure OpenAI | This guide will help you get started with AzureOpenAI chat models. Fo... |
Azure ML Endpoint | Azure Machine Learning is a platform used to build, train, and deploy... |
Baichuan Chat | Baichuan chat models API by Baichuan Intelligent Technology. For more... |
Baidu Qianfan | Baidu AI Cloud Qianfan Platform is a one-stop large model development... |
AWS Bedrock | This doc will help you get started with AWS Bedrock chat models. Amaz... |
Cerebras | This notebook provides a quick overview for getting started with Cere... |
Cloudflare Workers AI | This will help you getting started with CloudflareWorkersAI chat mode... |
Cohere | This notebook covers how to get started with Cohere chat models. |
Coze Chat | ChatCoze chat models API by coze.com. For more information, see https... |
Dappier AI | Dappier: Powering AI with Dynamic, Real-Time Data Models |
Databricks | Databricks Lakehouse Platform unifies data, analytics, and AI on one ... |
DeepInfra | DeepInfra is a serverless inference as a service that provides access... |
Eden AI | Eden AI is revolutionizing the AI landscape by uniting the best AI pr... |
EverlyAI | EverlyAI allows you to run your ML models at scale in the cloud. It a... |
Fireworks | This doc help you get started with Fireworks AI chat models. For deta... |
Friendli | Friendli enhances AI application performance and optimizes cost savin... |
GigaChat | This notebook shows how to use LangChain with GigaChat. |
Google AI | This docs will help you get started with Google AI chat models. For d... |
Google Cloud Vertex AI | This page provides a quick overview for getting started with VertexAI... |
GPTRouter | GPTRouter is an open source LLM API Gateway that offers a universal A... |
Groq | This will help you getting started with Groq chat models. For detaile... |
ChatHuggingFace | This will help you getting started with langchainhuggingface chat mod... |
IBM watsonx.ai | ChatWatsonx is a wrapper for IBM watsonx.ai foundation models. |
JinaChat | This notebook covers how to get started with JinaChat chat models. |
Kinetica | This notebook demonstrates how to use Kinetica to transform natural l... |
Konko | Konko API is a fully managed Web API designed to help application dev... |
LiteLLM | LiteLLM is a library that simplifies calling Anthropic, Azure, Huggin... |
LiteLLM Router | LiteLLM is a library that simplifies calling Anthropic, Azure, Huggin... |
Llama 2 Chat | This notebook shows how to augment Llama-2 LLMs with the Llama2Chat w... |
Llama API | This notebook shows how to use LangChain with LlamaAPI - a hosted ver... |
LlamaEdge | LlamaEdge allows you to chat with LLMs of GGUF format both locally an... |
Llama.cpp | llama.cpp python library is a simple Python bindings for @ggerganov |
maritalk | Introduction |
MiniMax | Minimax is a Chinese startup that provides LLM service for companies ... |
MistralAI | This will help you getting started with Mistral chat models. For deta... |
MLX | This notebook shows how to get started using MLX LLM's as chat models. |
Moonshot | Moonshot is a Chinese startup that provides LLM service for companies... |
Naver | This notebook provides a quick overview for getting started with Nave... |
NVIDIA AI Endpoints | This will help you getting started with NVIDIA chat models. For detai... |
ChatOCIModelDeployment | This will help you getting started with OCIModelDeployment chat model... |
OCIGenAI | This notebook provides a quick overview for getting started with OCIG... |
ChatOctoAI | OctoAI offers easy access to efficient compute and enables users to i... |
Ollama | Ollama allows you to run open-source large language models, such as L... |
OpenAI | This notebook provides a quick overview for getting started with Open... |
Perplexity | This notebook covers how to get started with Perplexity chat models. |
PremAI | PremAI is an all-in-one platform that simplifies the creation of robu... |
PromptLayer ChatOpenAI | This example showcases how to connect to PromptLayer to start recordi... |
Reka | This notebook provides a quick overview for getting started with Reka... |
SambaNovaCloud | This will help you getting started with SambaNovaCloud chat models. F... |
SambaStudio | This will help you getting started with SambaStudio chat models. For ... |
Snowflake Cortex | Snowflake Cortex gives you instant access to industry-leading large l... |
solar | Related |
SparkLLM Chat | SparkLLM chat models API by iFlyTek. For more information, see iFlyTe... |
Nebula (Symbl.ai) | Overview |
Tencent Hunyuan | Tencent's hybrid model API (Hunyuan API) |
Together | This page will help you get started with Together AI chat models. For... |
Tongyi Qwen | Tongyi Qwen is a large language model developed by Alibaba's Damo Aca... |
Upstage | This notebook covers how to get started with Upstage chat models. |
vLLM Chat | vLLM can be deployed as a server that mimics the OpenAI API protocol.... |
Volc Enging Maas | This notebook provides you with a guide on how to get started with vo... |
Writer | This notebook provides a quick overview for getting started with Writ... |
xAI | This page will help you get started with xAI chat models. For detaile... |
YandexGPT | This notebook goes over how to use Langchain with YandexGPT chat mode... |
ChatYI | This will help you getting started with Yi chat models. For detailed ... |
Yuan2.0 | This notebook shows how to use YUAN2 API in LangChain with the langch... |
ZHIPU AI | This notebook shows how to use ZHIPU AI API in LangChain with the lan... |