跳到主要内容
您目前所在的页面记录了 Together AI 模型作为文本补全模型的使用。Together AI 上许多流行的模型都是聊天补全模型您可能在寻找这个页面
Together AI 提供了一个 API,只需几行代码即可查询 50 多个领先的开源模型 这将帮助您开始使用 LangChain 的 Together AI 文本补全模型(LLMs)。有关 TogetherAI 功能和配置选项的详细文档,请参阅API 参考

概览

集成详情

类别本地可序列化PY 支持下载量版本
TogetherAI@langchain/communityNPM - DownloadsNPM - Version

设置

要访问 ChatTogetherAI 模型,您需要创建一个 Together 帐户,在此处获取 API 密钥,并安装 @langchain/community 集成包。

凭据

前往 api.together.ai 注册 TogetherAI 并生成一个 API 密钥。完成此操作后,设置 TOGETHER_AI_API_KEY 环境变量
export TOGETHER_AI_API_KEY="your-api-key"
如果您想获取模型调用的自动化跟踪,您还可以通过取消注释下方来设置您的 LangSmith API 密钥
# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"

安装

LangChain TogetherAI 集成位于 @langchain/community 包中
npm install @langchain/community @langchain/core

实例化

现在我们可以实例化我们的模型对象并生成聊天完成
import { TogetherAI } from "@langchain/community/llms/togetherai";

const llm = new TogetherAI({
  model: "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
  maxTokens: 256,
});

调用

const inputText = "Together is an AI company that "

const completion = await llm.invoke(inputText)
completion
 offers a range of AI-powered solutions to help businesses and organizations improve their customer service, sales, and marketing efforts. Their platform uses natural language processing (NLP) and machine learning algorithms to analyze customer interactions and provide insights and recommendations to help businesses improve their customer experience.
Together's solutions include:
1. Customer Service: Together's customer service solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their customer experience. This includes analyzing customer feedback, sentiment analysis, and predictive analytics to identify areas for improvement.
2. Sales: Together's sales solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their sales efforts. This includes analyzing customer behavior, sentiment analysis, and predictive analytics to identify opportunities for upselling and cross-selling.
3. Marketing: Together's marketing solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their marketing efforts. This includes analyzing customer behavior, sentiment analysis, and predictive analytics to identify areas for improvement.
Together's platform is designed to be easy to use and integrates with a range of popular CRM and marketing automation tools. Their solutions are available as a cloud-based subscription service, making it easy for businesses to get started with AI-powered customer service, sales, and marketing.
Overall,

API 参考

有关所有 TogetherAi 功能和配置的详细文档,请参阅API 参考
以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.