Skip to main content
Together AI provides access to a wide range of open-source models including Llama, Mistral, and Qwen.
from agno.agent import Agent
from agno.models.together import Together

agent = Agent(
    model=Together(id="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"),
    markdown=True,
)

agent.print_response("Explain the CAP theorem", stream=True)

Tool Use

from agno.agent import Agent
from agno.models.together import Together
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=Together(id="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"),
    tools=[YFinanceTools(stock_price=True)],
    markdown=True,
)

agent.print_response("What's TSLA's stock price?", stream=True)

Structured Output

from pydantic import BaseModel, Field
from agno.agent import Agent
from agno.models.together import Together

class Analysis(BaseModel):
    summary: str = Field(..., description="Brief summary")
    sentiment: str = Field(..., description="Sentiment")

agent = Agent(
    model=Together(id="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"),
    output_schema=Analysis,
)

agent.print_response("Analyze the future of AI")

Run Examples

export TOGETHER_API_KEY=xxx

git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/92_models/together

python basic.py
python tool_use.py
python structured_output.py