Uses TogetherAI-hosted models with Metorial MCP tools. TogetherAI provides an OpenAI-compatible API, so the code uses the openai package.
METORIAL_API_KEY— get one at platform.metorial.comTOGETHERAI_API_KEYorTOGETHER_API_KEY— from api.together.ai
bun install
bun startimport { metorialTogetherAi } from '@metorial/togetherai';
import { Metorial } from 'metorial';
import OpenAI from 'openai';
// Initialize the TogetherAI client as an OpenAI client with Together's base URL.
let metorial = new Metorial({ apiKey: process.env.METORIAL_API_KEY! });
let togetherai = new OpenAI({
apiKey: process.env.TOGETHERAI_API_KEY || process.env.TOGETHER_API_KEY!,
baseURL: 'https://api.together.xyz/v1'
});
// The session and tool call loop follow the same pattern as OpenAI. The `metorialTogetherAi`
// adapter formats tools for Together's API. This example uses `Qwen/Qwen3.5-397B-A17B`,
// but you can swap in any Together-hosted model that supports function calling.
let response = await togetherai.chat.completions.create({
model: 'Qwen/Qwen3.5-397B-A17B',
messages,
tools: session.tools()
});Uncomment the OAuth section in src/index.ts to add providers like GitHub or Slack. See the main README for details.