Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Const

Together AI

togetherai is the default Together.ai provider exported by @ai-sdk/togetherai. Call it with a Together.ai model ID to create a model for use with AI SDK generation APIs.

How it works

The togetherai constant is the default provider instance exported by @ai-sdk/togetherai. Pass it a Together.ai model identifier to obtain a language model for AI SDK operations; use createTogetherAI instead when custom provider settings such as an API key are required.

Syntax

togetherai(modelId)

Parameters

NameTypeDescription
modelIdstringTogether.ai model identifier, for example google/gemma-2-9b-it.

Returns

A Together.ai language model instance suitable for use with AI SDK generation functions.

Key points

  • Install @ai-sdk/togetherai to add Together.ai provider support to an AI SDK application.
  • The package exports togetherai, which is the ready-to-use default provider instance.
  • Invoke the provider with a model identifier to create a model object for AI SDK calls.
  • The provider's first argument selects the Together.ai model, such as google/gemma-2-9b-it.
  • Together.ai integration exposes a broad collection of open-source models through the provider.

Common mistakes

  • The provider function requires a valid Together.ai model identifier; model availability and identifiers come from Together.ai.
  • Use createTogetherAI rather than the default instance when configuring provider settings such as a custom API key.

Example: Generate text with Together.ai

import { togetherai } from '@ai-sdk/togetherai';
import { generateText } from 'ai';

const result = await generateText({
  model: togetherai('meta-llama/Llama-3.3-70B-Instruct-Turbo'),
  prompt: 'Explain dependency injection in one sentence.',
});

console.log(result.text);

Creates text with a Together.ai model through the AI SDK.

When to use it

Text generation

Generate text with an open-source Together.ai model through AI SDK Core.

Model selection

Select a specific Together.ai model by passing its provider model ID.

Custom provider setup

Use a configured provider instance when the default settings are insufficient.

Interview questions

QWhat is togetherai and how is it used?

togetherai is the default provider instance imported from @ai-sdk/togetherai. Calling it with a model ID creates a Together.ai language model that can be passed to AI SDK functions.

Follow-up: How would you supply custom provider configuration? Import createTogetherAI and call it with settings such as apiKey, then use the returned provider instance.

QHow do you generate text with Together.ai through the AI SDK?

Install the provider package, import togetherai, and pass togetherai('model-id') as the model to an AI SDK operation such as generateText. The model ID identifies the Together.ai model to invoke.

Follow-up: How can the provider target a proxy? Configure a provider instance with a different base URL or URL prefix when supported by the current provider API.

QWhy use the Together.ai provider?

The provider supports Together.ai's catalog of open-source models through the Together.ai API. The same AI SDK model interface lets application code use those models with core generation functions.

Follow-up: What should be checked before deployment? Verify the selected model ID, credentials, provider package version, and the model's capabilities for the requested operation.

  • createTogetherAI
  • generateText
  • @ai-sdk/togetherai
  • Together.ai models

Source: Together.ai. Checked 2026-10-15.