Docs /Getting Started/LangChain

LangChain

LangChain, the most widely adopted of these libraries, provides developers with powerful tools and patterns for managing complex prompts and conversational state.

Prerequisites

  1. Sign up for an account at Featherless

  2. Subscribe to a plan and get your API key from API Keys

Setup

First, let's import the required libraries and set up our API key.

pip install langchain-featherless-ai

Creating a LangChain Chat Model

Create a ChatFeatherlessAi instance using the Featherless LangChain integration. Set the FEATHERLESS_API_KEY environment variable to your Featherless API key before running this example. The example selects deepseek-ai/DeepSeek-V4.1-Flash-1017 and translates a sentence from English to French.

LangChain Chat Model
import os
from langchain_featherless_ai import ChatFeatherlessAi

llm = ChatFeatherlessAi(
    api_key=os.environ["FEATHERLESS_API_KEY"],
    base_url="https://api.featherless.ai/v1",
    model="deepseek-ai/DeepSeek-V4.1-Flash-1017",
)

messages = [
    ("system", "Translate the user sentence from English to French. Reply with only the translation."),
    ("human", "I love programming."),
]

ai_msg = llm.invoke(messages)
print(ai_msg.content)

We’ve created a simple conversation that asks the model to translate English to French. Now we can send our messages to the model and get the translation. The invoke() method handles the API call and returns the model’s response.

Resources

Last edited: Nov 12, 2026