Text generation
Generate text with an open-source Together.ai model through AI SDK Core.
AI Tools · Const
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.
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.
togetherai(modelId)| Name | Type | Description |
|---|---|---|
modelId | string | Together.ai model identifier, for example google/gemma-2-9b-it. |
A Together.ai language model instance suitable for use with AI SDK generation functions.
@ai-sdk/togetherai to add Together.ai provider support to an AI SDK application.togetherai, which is the ready-to-use default provider instance.google/gemma-2-9b-it.createTogetherAI rather than the default instance when configuring provider settings such as a custom API key.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.
Generate text with an open-source Together.ai model through AI SDK Core.
Select a specific Together.ai model by passing its provider model ID.
Use a configured provider instance when the default settings are insufficient.
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.
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.
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.
createTogetherAIgenerateText@ai-sdk/togetheraiTogether.ai models