@ai-sdk/togetherai provider gives it native access to Together AI models.
Quickstart
- Install the Vercel AI SDK and the Together AI provider package.
- Import the Together AI provider and call
generateTextwith Kimi K3.
TypeScript
providerOptions.togetherai is passed through to the Together API as request body fields, so you can set Together-specific parameters the AI SDK doesn’t model itself. Kimi K3 reasons by default, and reasoning: { enabled: false } turns that off for tasks that don’t need it.
Streaming
To stream responses, usestreamText:
TypeScript
Tool use
Define tools with thetool helper and a Zod schema. The SDK calls your execute function and feeds the result back to the model. Use stopWhen to let the model take the follow-up step after the tool result arrives:
TypeScript
Structured outputs
To get a typed object back instead of free text, pass anOutput.object with a Zod schema to generateText:
TypeScript
Use
generateText with Output.object rather than generateObject. The Together provider doesn’t support the AI SDK’s JSON schema response format, so generateObject fails with a schema validation error.Image generation
To generate images with Together AI models, use the.image() factory method. For more on image generation with the AI SDK see generateImage().
TypeScript
providerOptions argument.
TypeScript