> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # ![Together AI ロゴ](https://models.dev/logos/togetherai.svg)Together AI Mastra のモデルルーターを通じて 35 個の Together AI モデルを利用できます。認証には `TOGETHER_API_KEY` 環境変数が自動的に使用されます。 詳しくは、[Together AI のドキュメント](https://docs.together.ai/docs/serverless-models)を参照してください。 ```bash TOGETHER_API_KEY=your-api-key ``` ```typescript import { Agent } from "@mastra/core/agent"; const agent = new Agent({ id: "my-agent", name: "My Agent", instructions: "You are a helpful assistant", model: "togetherai/LiquidAI/LFM2-24B-A2B" }); // Generate a response const response = await agent.generate("Hello!"); // Stream a response const stream = await agent.stream("Tell me a story"); for await (const chunk of stream) { console.log(chunk); } ``` ## モデル | Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M | | ----------------------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- | | `togetherai/deepcogito/cogito-v2-1-671b` | 164K | | | | | | $1 | $1 | | `togetherai/deepseek-ai/DeepSeek-V4-Flash-0731` | 1.0M | | | | | | $0.14 | $0.28 | | `togetherai/deepseek-ai/DeepSeek-V4-Pro` | 512K | | | | | | $2 | $3 | | `togetherai/google/gemma-3n-E4B-it` | 33K | | | | | | $0.06 | $0.12 | | `togetherai/google/gemma-4-31B-it` | 262K | | | | | | $0.39 | $0.97 | | `togetherai/LiquidAI/LFM2-24B-A2B` | 33K | | | | | | $0.03 | $0.12 | | `togetherai/meta-llama/Llama-3.3-70B-Instruct-Turbo` | 131K | | | | | | $1 | $1 | | `togetherai/meta-llama/Meta-Llama-3-8B-Instruct-Lite` | 8K | | | | | | $0.14 | $0.14 | | `togetherai/MiniMaxAI/MiniMax-M2.7` | 203K | | | | | | $0.30 | $1 | | `togetherai/MiniMaxAI/MiniMax-M3` | 524K | | | | | | $0.30 | $1 | | `togetherai/moonshotai/Kimi-K2.6` | 262K | | | | | | $1 | $5 | | `togetherai/moonshotai/Kimi-K2.7-Code` | 262K | | | | | | $0.95 | $4 | | `togetherai/moonshotai/Kimi-K3` | 1.0M | | | | | | $3 | $15 | | `togetherai/nvidia/nemotron-3-ultra-550b-a55b` | 512K | | | | | | $0.60 | $4 | | `togetherai/openai/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 | | `togetherai/openai/gpt-oss-20b` | 131K | | | | | | $0.05 | $0.20 | | `togetherai/pearl-ai/gemma-4-31b-it` | 32K | | | | | | $0.28 | $0.86 | | `togetherai/Qwen/Qwen2.5-7B-Instruct-Turbo` | 33K | | | | | | $0.30 | $0.30 | | `togetherai/Qwen/Qwen3.5-9B` | 262K | | | | | | $0.17 | $0.25 | | `togetherai/Qwen/Qwen3.6-Plus` | 1.0M | | | | | | $0.50 | $3 | | `togetherai/Qwen/Qwen3.7-Max` | 1.0M | | | | | | $1 | $4 | | `togetherai/thinkingmachines/Inkling` | 524K | | | | | | $1 | $4 | | `togetherai/zai-org/GLM-5.2` | 262K | | | | | | $1 | $4 | ## 高度な設定 ### カスタムヘッダー ```typescript const agent = new Agent({ id: "custom-agent", name: "custom-agent", model: { id: "togetherai/LiquidAI/LFM2-24B-A2B", apiKey: process.env.TOGETHER_API_KEY, headers: { "X-Custom-Header": "value" } } }); ``` ### 動的なモデル選択 ```typescript const agent = new Agent({ id: "dynamic-agent", name: "Dynamic Agent", model: ({ requestContext }) => { const useAdvanced = requestContext.task === "complex"; return useAdvanced ? "togetherai/zai-org/GLM-5.2" : "togetherai/LiquidAI/LFM2-24B-A2B"; } }); ``` ## Provider を直接インストールする この Provider はスタンドアロン package として直接インストールし、Mastra のモデルルーター文字列の代わりに使用することもできます。詳しくは、[package のドキュメント](https://www.npmjs.com/package/@ai-sdk/togetherai)を参照してください。 **npm**: ```bash npm install @ai-sdk/togetherai ``` **pnpm**: ```bash pnpm add @ai-sdk/togetherai ``` **Yarn**: ```bash yarn add @ai-sdk/togetherai ``` **Bun**: ```bash bun add @ai-sdk/togetherai ``` Provider 固有の詳細については、[AI SDK Together AI Provider のドキュメント](https://ai-sdk.dev/providers/ai-sdk-providers/togetherai)を参照してください。