Get up to speed with our API in one minute.

Together AI makes it easy to run leading open-source models using only a few lines of code.

1. Register for an account

First, register for an account to get an API key. New accounts come with $5 to get started.

Once you've registered, set your account's API key to an environment variable named TOGETHER_API_KEY:

export TOGETHER_API_KEY=xxxxx

2. Install your preferred library

Together provides an official library for Python:

pip install together

As well as an official library for TypeScript/JavaScript:

npm install together-ai

You can also call our HTTP API directly using any language you like.

3. Run your first query against a model

Choose a model to query. In this example, we'll use Meta Llama 3.

With your selected model, use your preferred library to query one of Together's APIs – for example, to run a chat completion with streaming:

import os
from together import Together

client = Together(api_key=os.environ.get("TOGETHER_API_KEY"))

stream = client.chat.completions.create(
  messages=[{"role": "user", "content": "What are some fun things to do in New York?"}],

for chunk in stream:
  print(chunk.choices[0].delta.content or "", end="", flush=True)
import Together from 'together-ai';

const together = new Together({
  apiKey: process.env['TOGETHER_API_KEY'],

const stream = await together.chat.completions.create({
  model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
  messages: [
    { role: 'user', content: 'What are some fun things to do in New York?' },
  stream: true,

for await (const chunk of stream) {
  // use process.stdout.write instead of console.log to avoid newlines
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
curl -X POST "https://api.together.xyz/v1/chat/completions" \
     -H "Authorization: Bearer $TOGETHER_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
     	"model": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
     	"messages": [
          {"role": "user", "content": "What are some fun things to do in New York?"}

Congratulations – you've just made your first query to Together AI!

Next steps

You can choose from any of our many supported models to generate chat, images, language, or code.