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 capablemeta-llama/Meta-Llama-3.1-70B-Instruct-Turbo: 70B, balancedmeta-llama/Meta-Llama-3.1-8B-Instruct-Turbo: 8B, fast
Llama 3
meta-llama/Meta-Llama-3-70B-Instruct-Turbometa-llama/Meta-Llama-3-8B-Instruct-Turbo
Llama 2
togethercomputer/llama-2-7b-chat: Default modeltogethercomputer/llama-2-13b-chattogethercomputer/llama-2-70b-chat
Mixtral
mistralai/Mixtral-8x7B-Instruct-v0.1mistralai/Mixtral-8x22B-Instruct-v0.1
Qwen
Qwen/Qwen2.5-72B-Instruct-TurboQwen/Qwen2.5-7B-Instruct-Turbo
Embedding Models
togethercomputer/m2-bert-80M-32k-retrieval: Default, 32K contexttogethercomputer/m2-bert-80M-8k-retrieval: 8K contextWhereIsAI/UAE-Large-V1: 512 dimensionsBAAI/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
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
- Use Turbo models: Better performance for production
- Match embedding context: Use 32K model for long documents
- Enable streaming: Better UX for chat applications
- Choose right model size: Balance cost vs. quality needs
- Set appropriate tokens: Control response length and costs