Together.ai 프로바이더
Together.ai 프로바이더
Together.ai API를 통해 200개 이상의 오픈소스 모델을 AI SDK에서 쓸 수 있게 해주는 프로바이더예요.
출처: 문서
본문
Together.ai 프로바이더는 Together.ai API를 통해 200개 이상의 오픈소스 모델을 지원해요.
설정 (Setup)
Together.ai 프로바이더는 @ai-sdk/togetherai 모듈로 제공돼요. 다음과 같이 설치할 수 있어요:
프로바이더 인스턴스 (Provider Instance)
@ai-sdk/togetherai에서 기본 프로바이더 인스턴스 togetherai를 불러올 수 있어요:
import { togetherai } from '@ai-sdk/togetherai';
커스터마이즈가 필요하다면 @ai-sdk/togetherai에서 createTogetherAI를 불러와 원하는 설정으로 프로바이더 인스턴스를 만들 수 있어요:
import { createTogetherAI } from '@ai-sdk/togetherai';
const togetherai = createTogetherAI({
apiKey: process.env.TOGETHER_API_KEY ?? '',
});
Together.ai 프로바이더 인스턴스를 커스터마이즈할 때 사용할 수 있는 선택적 설정은 다음과 같아요:
-
baseURL string
API 호출에 다른 URL 접두사를 사용해요. 예를 들어 프록시 서버를 쓸 때 유용해요. 기본 접두사는
https://api.together.xyz/v1이에요. -
apiKey string
Authorization헤더로 보내는 API 키예요. 기본값은TOGETHER_API_KEY환경 변수예요. -
headers Record<string,string>
요청에 포함할 커스텀 헤더예요.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
커스텀 fetch 구현이에요. 기본값은 전역
fetch함수예요. 요청을 가로채는 미들웨어로 쓸 수도 있고, 예를 들어 테스트용으로 커스텀 fetch 구현을 제공할 수도 있어요.
언어 모델 (Language Models)
프로바이더 인스턴스로 Together.ai 모델을 만들 수 있어요. 첫 번째 인자는 모델 id예요. 예: google/gemma-2-9b-it.
const model = togetherai('google/gemma-2-9b-it');
추론 모델 (Reasoning Models)
Together.ai는 deepseek-ai/DeepSeek-R1의 thinking을 생성된 텍스트에서 thinking 태그로 노출해요. extractReasoningMiddleware를 사용해 이 추론을 추출하고 결과에 reasoning 속성으로 노출할 수 있어요:
import { togetherai } from '@ai-sdk/togetherai';
import { wrapLanguageModel, extractReasoningMiddleware } from 'ai';
const enhancedModel = wrapLanguageModel({
model: togetherai('deepseek-ai/DeepSeek-R1'),
middleware: extractReasoningMiddleware({ tagName: 'think' }),
});
그런 다음 generateText와 streamText 같은 함수에서 그 향상된 모델을 사용할 수 있어요.
예시 (Example)
generateText 함수로 Together.ai 언어 모델을 사용해 텍스트를 생성할 수 있어요:
import { togetherai } from '@ai-sdk/togetherai';
import { generateText } from 'ai';
const { text } = await generateText({
model: togetherai('meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'),
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
Together.ai 언어 모델은 streamText 함수에서도 사용할 수 있어요 (AI SDK Core 참고).
Together.ai 프로바이더는 (위 예시 코드에 이어) togetherai.completionModel()을 통한 완성 모델과 togetherai.embeddingModel()을 통한 임베딩 모델도 지원해요.
모델 기능 (Model Capabilities)
| 모델 | 이미지 입력 | 객체 생성 | 툴 사용 | 툴 스트리밍 |
|---|---|---|---|---|
moonshotai/Kimi-K2.5 |
||||
Qwen/Qwen3.5-397B-A17B |
||||
MiniMaxAI/MiniMax-M2.5 |
||||
zai-org/GLM-5 |
||||
deepseek-ai/DeepSeek-V3.1 |
||||
openai/gpt-oss-120b |
||||
openai/gpt-oss-20b |
||||
meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 |
이미지 모델 (Image Models)
.image() 팩토리 메서드로 Together.ai 이미지 모델을 만들 수 있어요.
AI SDK에서 이미지 생성에 대해 더 알고 싶다면 generateImage()를 참고하세요.
import { togetherai } from '@ai-sdk/togetherai';
import { generateImage } from 'ai';
const { images } = await generateImage({
model: togetherai.image('black-forest-labs/FLUX.1-dev'),
prompt: 'A delighted resplendent quetzal mid flight amidst raindrops',
});
providerOptions 인자로 선택적 프로바이더별 요청 파라미터를 전달할 수 있어요.
import {
togetherai,
type TogetherAIImageModelOptions,
} from '@ai-sdk/togetherai';
import { generateImage } from 'ai';
const { images } = await generateImage({
model: togetherai.image('black-forest-labs/FLUX.1-dev'),
prompt: 'A delighted resplendent quetzal mid flight amidst raindrops',
size: '512x512',
// Optional additional provider-specific request parameters
providerOptions: {
togetherai: {
steps: 40,
} satisfies TogetherAIImageModelOptions,
},
});
다음 프로바이더 옵션을 사용할 수 있어요:
-
steps number
생성 스텝 수. 값이 높을수록 품질이 좋아질 수 있어요.
-
guidance number
이미지 생성을 위한 가이던스 스케일.
-
negative_prompt string
피하고 싶은 것을 안내하는 네거티브 프롬프트.
-
disable_safety_checker boolean
이미지 생성을 위한 안전 검사기를 비활성화해요. true이면 API가 잠재적으로 NSFW로 표시된 이미지를 거부하지 않아요. Flux Schnell Free 및 Flux Pro 모델에서는 사용할 수 없어요.
이미지 편집 (Image Editing)
Together AI는 FLUX Kontext 모델을 통한 이미지 편집을 지원해요. prompt.images로 입력 이미지를 전달해 기존 이미지를 변형하거나 편집할 수 있어요.
기본 이미지 편집 (Basic Image Editing)
텍스트 프롬프트로 기존 이미지를 변형해요:
const imageBuffer = readFileSync('./input-image.png');
const { images } = await generateImage({
model: togetherai.image('black-forest-labs/FLUX.1-kontext-pro'),
prompt: {
text: 'Turn the cat into a golden retriever dog',
images: [imageBuffer],
},
size: '1024x1024',
providerOptions: {
togetherai: {
steps: 28,
} satisfies TogetherAIImageModelOptions,
},
});
URL 참조로 편집 (Editing with URL Reference)
이미지 URL을 직접 전달할 수도 있어요:
const { images } = await generateImage({
model: togetherai.image('black-forest-labs/FLUX.1-kontext-pro'),
prompt: {
text: 'Make the background a lush rainforest',
images: ['https://example.com/photo.png'],
},
size: '1024x1024',
providerOptions: {
togetherai: {
steps: 28,
} satisfies TogetherAIImageModelOptions,
},
});
지원되는 이미지 편집 모델 (Supported Image Editing Models)
| 모델 | 설명 |
|---|---|
black-forest-labs/FLUX.1-kontext-pro |
Production quality, balanced speed |
black-forest-labs/FLUX.1-kontext-max |
Maximum image fidelity |
black-forest-labs/FLUX.1-kontext-dev |
Development and experimentation |
모델 기능 (Model Capabilities)
Together.ai 이미지 모델은 모델에 따라 다양한 이미지 크기를 지원해요. 일반적인 크기는 512x512, 768x768, 1024x1024이며 일부 모델은 최대 1792x1792를 지원해요. 기본 크기는 1024x1024예요.
| 사용 가능한 모델 |
|---|
stabilityai/stable-diffusion-xl-base-1.0 |
black-forest-labs/FLUX.1-dev |
black-forest-labs/FLUX.1-dev-lora |
black-forest-labs/FLUX.1-schnell |
black-forest-labs/FLUX.1-canny |
black-forest-labs/FLUX.1-depth |
black-forest-labs/FLUX.1-redux |
black-forest-labs/FLUX.1.1-pro |
black-forest-labs/FLUX.1-pro |
black-forest-labs/FLUX.1-schnell-Free |
black-forest-labs/FLUX.1-kontext-pro |
black-forest-labs/FLUX.1-kontext-max |
black-forest-labs/FLUX.1-kontext-dev |
임베딩 모델 (Embedding Models)
.embeddingModel() 팩토리 메서드로 Together.ai 임베딩 모델을 만들 수 있어요.
AI SDK 임베딩 모델에 대해 더 알고 싶다면 embed()를 참고하세요.
import { togetherai } from '@ai-sdk/togetherai';
import { embed } from 'ai';
const { embedding } = await embed({
model: togetherai.embeddingModel('togethercomputer/m2-bert-80M-2k-retrieval'),
value: 'sunny day at the beach',
});
모델 기능 (Model Capabilities)
| 모델 | 차원 | 최대 토큰 |
|---|---|---|
BAAI/bge-large-en-v1.5 |
1024 | 512 |
Alibaba-NLP/gte-modernbert-base |
768 | 8192 |
intfloat/multilingual-e5-large-instruct |
1024 | 514 |
리랭킹 모델 (Reranking Models)
.reranking() 팩토리 메서드로 Together.ai 리랭킹 모델을 만들 수 있어요.
AI SDK 리랭킹에 대해 더 알고 싶다면 rerank()를 참고하세요.
import { togetherai } from '@ai-sdk/togetherai';
import { rerank } from 'ai';
const documents = [
'sunny day at the beach',
'rainy afternoon in the city',
'snowy night in the mountains',
];
const { ranking } = await rerank({
model: togetherai.reranking('mixedbread-ai/Mxbai-Rerank-Large-V2'),
documents,
query: 'talk about rain',
topN: 2,
});
console.log(ranking);
// [
// { originalIndex: 1, score: 0.9, document: 'rainy afternoon in the city' },
// { originalIndex: 0, score: 0.3, document: 'sunny day at the beach' }
// ]
Together.ai 리랭킹 모델은 객체 문서에 대한 추가 프로바이더 옵션을 지원해요. 랭킹에 사용할 필드를 지정할 수 있어요:
import {
togetherai,
type TogetherAIRerankingModelOptions,
} from '@ai-sdk/togetherai';
import { rerank } from 'ai';
const documents = [
{
from: 'Paul Doe',
subject: 'Follow-up',
text: 'We are happy to give you a discount of 20%.',
},
{
from: 'John McGill',
subject: 'Missing Info',
text: 'Here is the pricing from Oracle: $5000/month',
},
];
const { ranking } = await rerank({
model: togetherai.reranking('mixedbread-ai/Mxbai-Rerank-Large-V2'),
documents,
query: 'Which pricing did we get from Oracle?',
providerOptions: {
togetherai: {
rankFields: ['from', 'subject', 'text'], // Specify which fields to rank by
} satisfies TogetherAIRerankingModelOptions,
},
});
다음 프로바이더 옵션을 사용할 수 있어요:
-
rankFields string[]
문서가 JSON 객체일 때 랭킹에 사용할 필드 이름 배열이에요. 지정하지 않으면 모든 필드가 사용돼요.
모델 기능 (Model Capabilities)
| 모델 |
|---|
mixedbread-ai/Mxbai-Rerank-Large-V2 |
더 알아보기 (Learn more)
- AI Gateway
- xAI Grok
- OpenAI
- Azure OpenAI
- Anthropic
- Open Responses
- Claude Platform on AWS
- Amazon Bedrock
- Groq
- Fal
- AssemblyAI
- GMI Cloud
- TypeSafe
- DeepInfra
- Deepgram
- Black Forest Labs
- Gladia
- Hume
- Google Vertex AI
- Rev.ai
- Baseten
- Hugging Face
- QuiverAI
- Fish Audio
- Mistral AI
- Z.AI
- Together.ai
- Cohere
- Fireworks
- Voyage AI
- DeepSeek
- Moonshot AI
- Alibaba
- MiniMax
- Cerebras
- Replicate
- Prodia
- Perplexity
- Luma
- ByteDance
- Kling AI
- ElevenLabs
- Cartesia