Together AI
Run batches on Together AI's Batch API — a leaner line shape and a presigned-URL upload.
Together AI's Batch API mirrors OpenAI's (Files API + /batches) with two twists: a leaner { custom_id, body } line shape with the endpoint declared on the batch, and a presigned-URL file upload in place of OpenAI's direct multipart POST. Batchwork handles both.
| Property | Value |
|---|---|
| Shape | JSONL file upload (body-only) |
| Endpoint | /v1/chat/completions |
| Results | Output + error files (JSONL) |
| Webhooks | Poll-only (managed by the server) |
| Env var | TOGETHER_API_KEY |
| Package | @ai-sdk/togetherai |
| Base URL | https://api.together.xyz/v1 |
Example
import { batch } from "batchwork";
import { togetherai } from "@ai-sdk/togetherai";
const job = await batch({
model: togetherai("meta-llama/Llama-3.3-70B-Instruct-Turbo"),
requests: [
{ customId: "fr", prompt: "Capital of France? One word." },
{ customId: "jp", prompt: "Capital of Japan? One word." },
],
});The "together/…" and "togetherai/…" string forms both resolve here — see Models.
How it works
- Build — each request becomes a leaner
{ custom_id, body }line; the endpoint is declared on the batch rather than per line. - Upload — Together uses a presigned URL:
POST /fileswith metadata only returns a302with a signedLocationand file id, the raw bytes arePUTto that URL, thenPOST /files/{id}/preprocessfinalizes it (purpose=batch-api). - Create — the batch references the uploaded file id.
- Poll & read — Batchwork polls
status, then downloads the OpenAI-shaped output/error files.
Presigned upload Location values must be HTTPS and cannot target localhost or private-network URL literals.
Notes
Together has no native batch webhook, so it is poll-only. Use the server layer for unified completion events.
Credentials
Set TOGETHER_API_KEY, or pass apiKey / baseURL / headers to batch(). Install the peer dependency:
bun add @ai-sdk/togetherai