Integration details
| Class | Package | Local | Serializable | JS support | Downloads | Version |
|---|---|---|---|---|---|---|
| ChatAI21 | langchain-ai21 | ❌ | beta | ✅ |
Model features
| Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
Setup
Credentials
We’ll need to get an AI21 API key and set theAI21_API_KEY environment variable:
Installation
!pip install -qU langchain-ai21Instantiation
Now we can instantiate our model object and generate chat completions:Invocation
Tool Calls / Function Calling
This example shows how to use tool calling with AI21 models:API reference
For detailed documentation of all ChatAI21 features and configurations head to the API reference: python.langchain.com/api_reference/ai21/chat_models/langchain_ai21.chat_models.ChatAI21.htmlConnect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.