> ## Documentation Index
> Fetch the complete documentation index at: https://docs.together.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Make your first request to Together AI in a few minutes.

Run leading open-source models on Together AI with a few lines of code. Follow the steps below to get started.

## Step 1: Create an API key

[Register for an account](https://api.together.ai/) if you don't have one. Then go to your project's [API keys page](https://api.together.ai/settings/projects/~current/api-keys), select **Create key**, give it a name, and copy the value.

<Warning>
  New keys are only shown once, so make sure to save it somewhere safe.
</Warning>

Next, export the key as an environment variable in your terminal:

```bash theme={null}
export TOGETHER_API_KEY="your_api_key"
```

The SDK reads `TOGETHER_API_KEY` automatically when you call `Together()`. Pass `api_key=` to the constructor to override it.

## Step 2: Install the SDK

Together AI publishes official SDKs for Python and TypeScript. Install the SDK with your preferred package manager:

<CodeGroup>
  ```bash Python (uv) theme={null}
  uv init # optional
  uv add together
  ```

  ```bash Python (pip) theme={null}
  pip install together
  ```

  ```bash TypeScript (npm) theme={null}
  npm install together-ai
  ```
</CodeGroup>

You can also call the REST API directly from any language.

## Step 3: Run your first query

The example below sends a chat completion request and prints the response:

<CodeGroup>
  ```python Python theme={null}
  from together import Together

  client = Together()  # reads TOGETHER_API_KEY from environment

  response = client.chat.completions.create(
      model="openai/gpt-oss-20b",
      messages=[
          {
              "role": "user",
              "content": "What are the top 3 things to do in New York?",
          }
      ],
  )

  print(response.choices[0].message.content)
  ```

  ```typescript TypeScript theme={null}
  import Together from "together-ai";

  const together = new Together(); // reads TOGETHER_API_KEY from environment

  async function main() {
    const response = await together.chat.completions.create({
      model: "openai/gpt-oss-20b",
      messages: [{ role: "user", content: "What are the top 3 things to do in New York?" }],
    });

    console.log(response.choices[0].message.content);
  }

  main();
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.together.ai/v1/chat/completions" \
    -H "Authorization: Bearer $TOGETHER_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-oss-20b",
      "messages": [
        {"role": "user", "content": "What are the top 3 things to do in New York?"}
      ]
    }'
  ```
</CodeGroup>

To stream tokens as they arrive, add `stream=True` (Python) or `stream: true` (TypeScript/cURL) and iterate over the response chunks:

<CodeGroup>
  ```python Python theme={null}
  stream = client.chat.completions.create(
      model="openai/gpt-oss-20b",
      messages=[
          {
              "role": "user",
              "content": "What are the top 3 things to do in New York?",
          }
      ],
      stream=True,
  )

  for chunk in stream:
      if chunk.choices:
          print(chunk.choices[0].delta.content or "", end="", flush=True)
  ```

  ```typescript TypeScript theme={null}
  const stream = await together.chat.completions.create({
    model: "openai/gpt-oss-20b",
    messages: [{ role: "user", content: "What are the top 3 things to do in New York?" }],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || "");
  }
  ```

  ```bash cURL theme={null}
  curl -N -X POST "https://api.together.ai/v1/chat/completions" \
    -H "Authorization: Bearer $TOGETHER_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "openai/gpt-oss-20b",
      "messages": [
        {"role": "user", "content": "What are the top 3 things to do in New York?"}
      ],
      "stream": true
    }'
  ```
</CodeGroup>

<Check>
  Congrats! You just made your first request to Together AI. The same client works for multi-turn conversations, function calling, structured outputs, image generation, and audio transcription.
</Check>

## Next steps

<CardGroup cols={2}>
  <Card title="Choose a model" icon="sparkles" href="/docs/serverless/models">
    Browse the catalog of models for chat, coding, vision, and reasoning.
  </Card>

  <Card title="Dedicated endpoints" icon="server-2" href="/docs/dedicated-endpoints/overview">
    Reserve GPUs for steady traffic or fine-tuned models.
  </Card>

  <Card title="Fine-tune a model" icon="adjustments-horizontal" href="/docs/fine-tuning-overview">
    Train a model on your own data with LoRA, DPO, or full fine-tuning.
  </Card>

  <Card title="GPU clusters" icon="cpu" href="/docs/gpu-clusters-overview">
    Run large-scale training and custom workloads on dedicated GPU clusters.
  </Card>
</CardGroup>
