Partner Integration Packages
Relevant source files
The following files were used as context for generating this wiki page:
Partner Integration Packages are a core feature of the LangChain framework, designed to connect Large Language Models (LLMs) with a vast ecosystem of third-party data sources, tools, and services. The real power of LLMs is realized when they are combined with other sources of computation or knowledge, and these packages provide the necessary components to build such applications. They offer a standard, interoperable interface for everything from model providers and vector stores to external APIs, allowing developers to easily swap components and future-proof their applications as the underlying technology evolves.
The architecture is built upon the base abstractions defined in langchain-core, which ensures that any partner can implement a required interface (like BaseChatModel or BaseEmbeddings) and be seamlessly used within the broader LangChain ecosystem. This modularity is key to building complex systems like Retrieval Augmented Generation (RAG), agents, and chains.
Sources: README.md:17-23, libs/langchain/README.md:20-23, libs/core/README.md:9-15
Core Architecture and Principles
The integration architecture relies on the langchain-core package, which provides the base abstractions and the Runnable interface. Partner packages implement these interfaces to make their services compatible with LangChain.
Sources: libs/core/README.md:9-15, CLAUDE.md:155-157
Integration Flow
The following diagram illustrates how a request in a LangChain application flows from the core framework to a specific partner integration.
This diagram shows that a user's request is processed by a LangChain Expression Language (LCEL) chain, which invokes components through the standard Runnable interface. LangChain Core then directs the call to the appropriate partner package, which handles the specific API communication with the external service.
Sources: libs/core/README.md:21-25, libs/core/README.md:46-48
Development Guidelines for Partners
To ensure consistency and quality, all partner integrations must adhere to specific development guidelines.
- Implement Standard Interfaces: Partner packages must implement the standard base abstractions from
langchain-core, such asBaseChatModel,BaseEmbeddings, etc. - Preserve Public Interfaces: Function signatures, argument positions, and names for exported/public methods must be preserved to avoid breaking changes.
- Testing: Every new feature or bugfix must be covered by comprehensive integration tests.
- Documentation: API key requirements and authentication methods must be clearly documented.
Sources: CLAUDE.md:5-7, CLAUDE.md:155-159
This class diagram shows the relationship between the core abstraction and a partner implementation.
Installation and Configuration
Each partner package is installed separately via pip. This modular approach keeps the core LangChain library lightweight.
General Installation
To install a partner package, you use its specific package name. For example, for Fireworks.ai:
pip install langchain-fireworks
Sources: libs/partners/fireworks/README.md:8-10
Environment Setup
Most partner integrations require an API key for authentication. These are typically configured as environment variables.
| Variable | Description | Example Partner |
|---|---|---|
FIREWORKS_API_KEY | API key for Fireworks.ai services. | langchain-fireworks |
OPENAI_API_KEY | API key for OpenAI services. | langchain-openai |
ANTHROPIC_API_KEY | API key for Anthropic services. | langchain-anthropic |
To set an environment variable:
# Linux/macOS
export FIREWORKS_API_KEY='your_api_key'
# Windows
set FIREWORKS_API_KEY=your_api_key
Sources: libs/partners/fireworks/README.md:14-25
Basic Usage
Once installed and configured, a partner model can be initialized and invoked directly in Python.
from langchain_fireworks import Fireworks
# Initialize a Fireworks model
llm = Fireworks(
model="accounts/fireworks/models/llama-v3p1-8b-instruct",
base_url="https://api.fireworks.ai/inference/v1/completions",
)
# Single prompt
output = llm.invoke("Who's the best quarterback in the NFL?")
print(output)
Sources: libs/partners/fireworks/README.md:27-37
Example Integration: Zapier NLA
A powerful example of a partner integration is the Zapier Natural Language Actions (NLA) API. It allows a LangChain application to interact with over 5,000 apps (like Slack, Google Sheets, and Gmail) using natural language instructions.
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:11-20
Zapier NLA Features
- Universal API: Provides a single, natural language API to perform actions across thousands of applications.
- Auth Handling: Automatically handles various authentication types (OAuth, API Key, etc.) for the underlying apps.
- AI-Powered Guessing: Interprets natural language
instructionsto fill in required parameters for an action, which can be overridden by the user or developer. - User-Facing Configuration: Users can enable and configure actions through a simple, OAuth-like popup window.
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:22-31, libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:96-118
Authentication
Zapier NLA supports two primary authentication modes for developers to use its API.
| Mode | Method | Use Case |
|---|---|---|
| Server-side only | API Key (x-api-key header) | For testing, or when the app uses actions from the developer's own Zapier account. |
| User-facing | OAuth 2.0 | For production apps where the application needs to access each end-user's exposed actions and connected accounts. |
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:33-39, libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:57-65, libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:71-75
The OAuth 2.0 flow for user-facing applications is a standard authorization code grant flow.
This diagram shows the sequence of events for a user authorizing an application to use their Zapier actions.
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:77-107
API Endpoints
The Zapier NLA integration exposes several key endpoints defined in its OpenAPI specification.
| Endpoint | Method | Description |
|---|---|---|
/api/v1/exposed/ | GET | Lists all currently exposed actions for the authenticated user. |
/api/v1/dynamic/exposed/{ACTION_ID}/execute/ | POST | Executes a specific action. |
/api/v1/check/ | GET | Checks if the current API key or access token is valid. |
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:67-70, libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:141-144, libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:173-176
Executing an action requires a JSON body with an instructions field. Optional "hint parameters" can be provided to override the AI's guessing.
{
"instructions": "Send a short poem about automation to slack",
"channel": "#fun-zapier"
}
Sources: libs/langchain/tests/unit_tests/examples/test_specs/zapier/apispec.json:49-54
Conclusion
Partner Integration Packages are fundamental to the LangChain philosophy of composability and modularity. They provide the essential "plumbing" that allows developers to build powerful, data-aware applications by connecting LLMs to a wide array of external tools and services. By adhering to a set of core abstractions and development guidelines, the ecosystem enables rapid innovation and ensures that applications can adapt as new models and platforms emerge.
Sources: README.md:17-23, CLAUDE.md:155-159