0

Together AI Provider

Together AI Provider explains the cloud layer of MTPX with practical guidance for building inspectable, tool-using agents.

To
Together AI Provider
Chapter 041ProvidersCloudIndex
01Orientation

Together AI Provider belongs to the providers track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how together ai provider affects a real MTPX agent before you wire it into an application.

  • What together ai provider owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
from mtp import Agent
from mtp.providers import Groq

agent = Agent.MTPAgent(
    provider=Groq(model="llama-3.3-70b-versatile"),
    tools=tools,
)
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

Together AI hosts 200+ open-source models with an OpenAI-compatible API. Great for running large open models without vendor lock-in.

Install

bashpip install "mtpx[togetherai]"

This installs the openai SDK. Alternatively, install the native Together SDK:

bashpip install together

API Key Setup

  1. Install dotenv support:
bash   pip install python-dotenv

Or with the MTP extra:

bash   pip install "mtpx[dotenv]"
  1. Create a .env file in your project root:
text   TOGETHER_API_KEY=your_key_here
  1. Load it in your code before creating the provider:
python   from mtp import Agent

   Agent.load_dotenv_if_available()  # reads .env file

Get a free API key at api.together.ai ($1 credit on signup).

Option 2: System environment variable

bash# Linux/macOS
export TOGETHER_API_KEY="..."

# Windows PowerShell
$env:TOGETHER_API_KEY="..."

Quick Start

pythonfrom mtp import Agent
from mtp.providers import TogetherAI

Agent.load_dotenv_if_available()  # loads TOGETHER_API_KEY from .env

provider = TogetherAI(model="meta-llama/Llama-4-Scout-17B-16E-Instruct")
tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools)

reply = agent.run_loop("What is 25 * 4 + 10?")
print(reply)

Parameters

ParameterTypeDefaultDescription
modelstr"meta-llama/Llama-4-Scout-17B-16E-Instruct"Together AI model ID (format: org/model)
api_keystr | NoneNoneAPI key (falls back to TOGETHER_API_KEY env var)
temperaturefloat0.0Sampling temperature
tool_choicestr | dict"auto"Tool selection strategy
parallel_tool_callsboolTrueAllow parallel tool calls
max_tokensint4096Maximum response tokens
clientAny | NoneNonePre-configured client instance

Capabilities

CapabilityValue
Tool callingYes (model-dependent)
Parallel tool callsYes (configurable)
Input modalitiestext, image
StreamingFallback
Usage metricsRich
Reasoning metadataNo
Native asyncNo (uses thread fallback)
  • meta-llama/Llama-4-Scout-17B-16E-Instruct — Best tool use (default)
  • meta-llama/Llama-3.3-70B-Instruct-Turbo — Fast, reliable
  • Qwen/Qwen2.5-72B-Instruct-Turbo — Excellent reasoning
  • deepseek-ai/DeepSeek-V3 — Top-tier reasoning
  • mistralai/Mixtral-8x22B-Instruct-v0.1 — Strong + fast

Full Example

pythonfrom mtp import Agent
from mtp.providers import TogetherAI

Agent.load_dotenv_if_available()

provider = TogetherAI(
    model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
    temperature=0.0,
    max_tokens=4096,
)

tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools, debug_mode=True)

reply = agent.run_loop(
    "Calculate (25 * 4) + 10",
    max_rounds=3,
)
print(reply)

Notes

  • Together AI prefers the native together SDK when available, falls back to OpenAI client at https://api.together.xyz/v1.
  • Model IDs use the format org/model-name (e.g., meta-llama/Llama-4-Scout-17B-16E-Instruct).
  • Widest model selection of any provider — great for comparing model performance on the same task.
  • Competitive pricing (~$0.18/1M tokens for 70B models).

Source

src/mtp/providers/together_provider.py

01

Read

Understand where Together AI Provider sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docXiaomi MiMo Provider