Skip to main content
You are currently on a page documenting the use of Together AI models as text completion models. Many popular models available on Together AI are chat completion models.You may be looking for this page instead.
Together AI offers an API to query 50+ leading open-source models in a couple lines of code. This will help you get started with Together AI text completion models (LLMs) using LangChain. For detailed documentation on TogetherAI features and configuration options, please refer to the API reference.

Overview

Integration details

Setup

To access the legacy TogetherAI completions class, create a Together account, get an API key, and install the @langchain/together-ai integration package. For chat and instruct models, prefer ChatTogetherAI.

Credentials

Head to api.together.ai to sign up to Together AI and generate an API key. Set the TOGETHER_AI_API_KEY environment variable:
If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

Installation

The LangChain TogetherAI integration lives in the @langchain/together-ai package:

Instantiation

Instantiate the completions model:

Invocation


API reference

For detailed documentation of all TogetherAI features and configurations head to the API reference.