Skip to main content

Overview

Together AI provides fast inference for open-source LLMs and embedding models. The provider extends OpenAI’s interface with Together AI’s API endpoints.

Installation

Basic Usage

LLM

Embeddings

Constructor Options

TogetherLLM

string
default:"togethercomputer/llama-2-7b-chat"
Together AI model name
string
Together AI API key (defaults to TOGETHER_API_KEY env variable)
number
Sampling temperature
number
Maximum tokens in response
number
Nucleus sampling parameter
object
Additional OpenAI client options (e.g., custom baseURL)

TogetherEmbedding

string
default:"togethercomputer/m2-bert-80M-32k-retrieval"
Together AI embedding model name
string
Together AI API key (defaults to TOGETHER_API_KEY env variable)
object
Additional OpenAI client options

Supported Models

Chat Models

Llama 3.1

  • meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo: 405B, most capable
  • meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo: 70B, balanced
  • meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo: 8B, fast

Llama 3

  • meta-llama/Meta-Llama-3-70B-Instruct-Turbo
  • meta-llama/Meta-Llama-3-8B-Instruct-Turbo

Llama 2

  • togethercomputer/llama-2-7b-chat: Default model
  • togethercomputer/llama-2-13b-chat
  • togethercomputer/llama-2-70b-chat

Mixtral

  • mistralai/Mixtral-8x7B-Instruct-v0.1
  • mistralai/Mixtral-8x22B-Instruct-v0.1

Qwen

  • Qwen/Qwen2.5-72B-Instruct-Turbo
  • Qwen/Qwen2.5-7B-Instruct-Turbo

Embedding Models

  • togethercomputer/m2-bert-80M-32k-retrieval: Default, 32K context
  • togethercomputer/m2-bert-80M-8k-retrieval: 8K context
  • WhereIsAI/UAE-Large-V1: 512 dimensions
  • BAAI/bge-large-en-v1.5: BGE large English

Streaming

Function Calling

Together AI supports function calling on compatible models:

With LlamaIndex

Convenience Functions

Configuration

Environment Variables

Custom Base URL

Default base URL: https://api.together.xyz/v1

Model Selection Guide

Performance

Together AI offers competitive inference speeds:
  • Turbo models: Optimized for low latency
  • Batch processing: Efficient for high throughput
  • Streaming: Real-time token generation

Error Handling

Best Practices

  1. Use Turbo models: Better performance for production
  2. Match embedding context: Use 32K model for long documents
  3. Enable streaming: Better UX for chat applications
  4. Choose right model size: Balance cost vs. quality needs
  5. Set appropriate tokens: Control response length and costs

Pricing

Together AI offers competitive pricing for open-source models. Check Together AI pricing for current rates.

See Also