Repository navigation
Feature request: provider batch APIs (Anthropic Message Batches, OpenAI Batch, etc.) #2054
husseinraoouf
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The gap
Several providers TanStack AI already supports have a batch API: you submit many requests at once and collect the results later, at a lower price. Anthropic's Message Batches, for example, cost 50% of the standard price and return results within 24 hours. OpenAI, Gemini and Bedrock each offer a similar batch mode.
As far as I can tell, TanStack AI has no way to use these today. Searching the repo turns up nothing for
messages.batchesorbatches.create, and the batch mentions in the docs are about stream chunking and Bedrock embeddings. So an app that wants batch pricing has to drop down to each provider's own SDK for that one path. It then loses what it uses TanStack AI for: the same request shape across providers, typedoutputSchemaresults, image input, and provider switching.Our use case
We use TanStack AI with Claude (via
@tanstack/ai-anthropic) to turn messy shop data, such as social-media posts with images and captions, into structured products usingoutputSchema. A large import can mean hundreds of independent requests that don't need to finish in real time. These requests are a natural fit for batch pricing. Today the batch path has to be written separately for each provider, with its own request and result types.Rough idea
This is only a sketch; the maintainers will know the right shape far better. It's an activity that takes the same request options as
chat(), minus streaming, and splits submitting and collecting into two steps, so it fits durable or long-running workflows:Useful properties:
chat(). Typed output and usage work the same way for batched requests.Happy to give more detail or test an early version with Anthropic.
All reactions