Install libraries
TOGETHER_API_KEY and COMPOSIO_API_KEY environment variables.
Shell
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use Composio with Together AI.
pip install together composio-togetherai
npm install @composio/core @composio/vercel @ai-sdk/togetherai ai
TOGETHER_API_KEY and COMPOSIO_API_KEY environment variables.
export TOGETHER_API_KEY=***
export COMPOSIO_API_KEY=***
from composio_togetherai import ComposioToolSet, App
from together import Together
client = Together()
toolset = ComposioToolSet()
/*
We use the Vercel AI SDK with the Together provider to
enable type checking to work correctly for tools and
to simplify the Composio integration.
This flow enables us to directly execute tool calls
without having to use composio.provider.handleToolCalls.
*/
import { Composio } from "@composio/core";
import { VercelProvider } from "@composio/vercel";
import { createTogetherAI } from "@ai-sdk/togetherai";
import { generateText } from "ai";
export const together = createTogetherAI({
apiKey: process.env.TOGETHER_API_KEY ?? "",
});
const composio = new Composio({
apiKey: process.env.COMPOSIO_API_KEY ?? "",
provider: new VercelProvider(),
});
request = toolset.initiate_connection(app=App.GITHUB)
print(f"Open this URL to authenticate: {request.redirectUrl}")
composio login
composio add github
tools = toolset.get_tools(apps=[App.GITHUB])
const userId = "default"; // replace with user id from composio
const tools = await composio.tools.get(userId, {
toolkits: ['github'],
});
response = client.chat.completions.create(
tools=tools,
model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
messages=[
{
"role": "user",
"content": "Star the repo 'togethercomputer/together-cookbook'",
}
],
)
res = toolset.handle_tool_calls(response)
print(res)
const responseGithub = await generateText({
model: together("meta-llama/Llama-3.3-70B-Instruct-Turbo"),
messages: [
{
role: "user",
content: "Star the repo 'togethercomputer/together-cookbook'",
},
],
tools,
toolChoice: "required",
});
console.log(responseGithub);
Was this page helpful?