Registry / llm-agents / langchain-together

langchain-together

JSON →
library0.4.0pypypi✓ verified 84d ago

An integration package connecting Together AI's API with LangChain. Provides chat models and embeddings. Current version 0.4.0, requires Python >=3.10, <4.0. Release cadence is irregular; latest releases include security patches and MCP server features.

pip install langchain-together
INSTALL
IMPORT
SIG · LANGCHAIN-TOGETHER
L
langchain-together
llm-agentspythonv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChatTogether
from langchain_together import ChatTogether
from langchain_together.chat import ChatTogether
Incorrect: ChatTogether is exposed at the top-level package.
TogetherEmbeddings
from langchain_together import TogetherEmbeddings
from langchain_together.embeddings import TogetherEmbeddings
Incorrect: embeddings are also at top-level.

Basic usage: instantiate ChatTogether with API key and model, then invoke.

import os from langchain_together import ChatTogether chat = ChatTogether( together_api_key=os.environ.get("TOGETHER_API_KEY", ""), model="mistralai/Mixtral-8x7B-Instruct-v0.1" ) response = chat.invoke("Hello, how are you?") print(response.content)
Debug
Known issues
breakingVersion 0.2.0 introduced a new package structure. If you were using the old langchain_together from community, imports must be updated to 'from langchain_together import ...' instead of 'from langchain.llms import Together'
fix
Change imports to the new package: from langchain_together import ChatTogether
affects: <0.2.0
deprecatedThe 'model' parameter used to accept model IDs like 'togethercomputer/llama-2-70b-chat'. These legacy IDs are deprecated in favor of Together AI's new model format (e.g., 'mistralai/Mixtral-8x7B-Instruct-v0.1').
fix
Use the new model naming convention as documented by Together AI.
affects: <0.3.0
gotchaThe environment variable for the API key is 'TOGETHER_API_KEY', not 'TOGETHER_AI_KEY' or 'TOGETHER_AI_API_KEY'.
fix
Set the correct environment variable or pass directly via 'together_api_key' parameter.
affects: all
gotchaChatTogether does not support all models available via Together AI's API. Some models may require additional parameters like 'temperature' or 'max_tokens' which are not passed through by default.
fix
Check LangChain documentation for supported models and pass extra kwargs if needed.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langchain_together'
Package not installed or wrong import path (e.g., from langchain.llms import Together).
fix
Install with 'pip install langchain-together' and import as 'from langchain_together import ChatTogether'.
InvalidRequestError: 'model' is not a valid parameter
Passing the model name as a keyword argument 'model' when it should be passed as positional or via model_kwargs.
fix
Use the correct parameter name: ChatTogether(model='mistralai/Mixtral-8x7B-Instruct-v0.1') or ChatTogether(model_kwargs={'model': '...'}) – check the latest API.
AuthenticationError: 401 Unauthorized
API key missing or incorrect.
fix
Set the TOGETHER_API_KEY environment variable or pass the key via the 'together_api_key' parameter.
TypeError: __init__() got an unexpected keyword argument 'together_api_key'
Using an older version of langchain-together that expected the parameter name 'api_key' instead of 'together_api_key'.
fix
Upgrade to latest version: pip install --upgrade langchain-together
Upgrade
Version history
0.4.0latest on PyPI · released Mar 24, 2026
Audit
Dependencies
langchain-corerequiredRequired for base classes like BaseChatModel and embeddings interface.
togetherrequiredOfficial Together AI Python SDK, needed for API calls.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
langchain-together — pip install langchain-together · libregistry