LLM with Anthropic
QStash integrates smoothly with Anthropic’s API, allowing you to send LLM requests and leverage QStash features like retries, callbacks, and batching. This is especially useful when working in serverless environments where LLM response times vary and traditional timeouts may be limiting. QStash provides an HTTP timeout of up to 2 hours, which is ideal for most LLM cases.
Example: Publishing and Enqueueing Requests
Specify the api
as llm
with the provider set to anthropic()
when publishing requests. Use the Upstash-Callback
header to handle responses asynchronously, as streaming completions aren’t supported for this integration.
Publishing a Request
Enqueueing a Chat Completion Request
Use enqueueJSON
with Anthropic as the provider to enqueue requests for asynchronous processing.
Sending Chat Completion Requests in Batches
Use batchJSON
to send multiple requests at once. Each request in the batch specifies the same Anthropic provider and includes a callback URL.
Analytics with Helicone
To monitor usage, include Helicone analytics by passing your Helicone API key under analytics
:
With this setup, Anthropic can be used seamlessly in any LLM workflows in QStash.
Was this page helpful?