skillfed

langchain-xai

An integration package connecting xAI and LangChain

langchain-xai v1.3.0 1.1M downloads/30d#4,356 on PyPI144,267
Permissive license MIT Active released

What it is and what it does

langchain-xai is a LangChain integration package that bridges xAI's language models to the LangChain ecosystem. It provides a ChatXAI class and related components that allow developers to use xAI models within LangChain applications, enabling access to xAI's APIs through the standard LangChain interface.

The package depends on langchain-core for base abstractions, langchain-openai for compatible model patterns, and standard HTTP libraries (aiohttp, requests) for API communication. It targets modern Python versions (3.10 through 3.14) and is actively maintained by the LangChain team. Use it when you want to incorporate xAI models into a LangChain application without writing custom API integration code.

Use it for:

  • Build a chatbot or conversational agent using xAI models within a LangChain application.
  • Chain xAI model calls with other LangChain tools, retrievers, or agents in a multi-step workflow.
  • Migrate or extend an existing LangChain application to include xAI as an alternative model provider.
  • Prototype or experiment with xAI models alongside other LLM providers in a unified LangChain interface.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Connects xAI's language models to LangChain applications through their APIs, enabling integration of xAI models into LangChain workflows.

Yes, if you are building a LangChain application and want to use xAI models. The package is actively maintained, has no known vulnerabilities, low install friction, and permissive licensing. Install it when you have an xAI API key and need xAI model access within LangChain; skip it if you do not plan to use xAI models or are not using LangChain.

Install

langchain-xai on PyPI

pip

pip install langchain-xai

uv

uv add langchain-xai

poetry

poetry add langchain-xai

Installing langchain-xai

Before you install

Low install friction with a pure Python wheel. Actively maintained as of 24 days ago with a recent release on 2026-07-21. Depends on langchain-core, langchain-openai, aiohttp, and requests—all stable, widely-used libraries.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.

Quickstart

pip install langchain-xai

from langchain_xai import ChatXAI

chat = ChatXAI(api_key="your-xai-api-key")
response = chat.invoke("Hello")

Requires a valid xAI API key from https://console.x.ai and Python >= 3.10.0, < 4.0.0.

Verify before relying

  • Whether xAI model names and capabilities are documented in the package or require external reference.
  • Whether the package supports streaming, tool use, or other advanced LangChain features.
  • Cost and rate-limit behavior of xAI API calls through this integration.

Package facts

License MIT (permissive)
Python support supports the current Python release (<4.0.0,>=3.10.0)
Install friction low — pure-Python wheel
Runtime dependencies 4 — aiohttp, langchain-core, langchain-openai, requests
Maintenance actively maintained — 24 days since the last release
Last repo commit
First released
Downloads 1,109,895/month — #4,356 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: langchain_xai-1.3.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

xai langchain integrationxai language model apilangchain xai connectorxai grok integrationlangchain provider xaixai llm integrationlangchain xai models
llm-integrationlangchain-provider

More Artificial Intelligence packages

litellm

LiteLLM provides a unified Python interface to…

permissive · top 100 on PyPI

huggingface-hub

Client library and CLI tool for downloading,…

permissive · top 100 on PyPI

langchain

LangChain provides a framework for building…

permissive · top 1,000 on PyPI

hf-xet

hf-xet provides chunk-based deduplication and…

permissive · top 1,000 on PyPI

tokenizers

Tokenizers converts raw text into token…

permissive · top 1,000 on PyPI

transformers

Transformers provides a unified framework for…

permissive · top 1,000 on PyPI

langchain-aws

Connects LangChain applications to AWS services…

permissive · top 5,000 on PyPI

langchain-openai

Provides LangChain integrations for OpenAI's…

permissive · top 1,000 on PyPI

langchain-ollama

Connects LangChain applications to Ollama,…

permissive · top 5,000 on PyPI

langchain-mistralai

Connects Mistral AI language models to…

permissive · top 5,000 on PyPI

langchain-openrouter

Connects LangChain applications to OpenRouter,…

permissive · top 15,000 on PyPI

langchain-anthropic

Provides LangChain integration for Anthropic's…

permissive · top 1,000 on PyPI

langchain-fireworks

Integrates Fireworks.ai language models with…

permissive · top 5,000 on PyPI

langchain-perplexity

Integrates Perplexity AI models into LangChain…

permissive · top 15,000 on PyPI

langchain-deepseek

Integrates DeepSeek language models into…

permissive · top 5,000 on PyPI

langchain-groq

Connects Groq's inference API to LangChain,…

permissive · top 5,000 on PyPI