Use async invocation for long-running or batch requests. TIR queues the call and processes it in the background. The call answers at once with a request ID and a response location. TIR stores the answer in a dataset you choose, so your application can carry on while the result is prepared. Async works on an endpoint on any plan except Multi Node, and you set it up once the endpoint exists. A queued route must accept only the POST and OPTIONS methods.
Set up the queues
Section titled “Set up the queues”- Open the endpoint and select the Async Invocations tab.
- Select Setup Queues.
- Under Source, select Add Queue for each route. Each queue has a fixed name, QUEUE_1, QUEUE_2, and so on, and an Application Route. Type the route without a leading slash and without spaces, for example
api/v1/chat/completion. Each queue needs its own route. - Under Target, leave Destination Type on Dataset and choose one of the project’s ready Object Storage datasets under Destination, or create a new one from the same list. The dataset is in the endpoint’s region; see TIR Object Storage. A new one is an Object Storage bucket that TIR names
async-invocations-<random>. - Choose Concurrency, the number of requests processed in parallel: 1, 2, 4, 8, 16, 32, or 64. It starts at 4.
- Select Submit.
A small CPU machine handles the queue. You pay for it only while the queue has requests, and it scales down to zero when the queue is empty. The endpoint’s own workers are billed as usual.
Send an async request
Section titled “Send an async request”With async on, each queue has its own samples under API Request on its row. The cURL call goes to the root endpoint, the route, and async/ after it, with your token in the Authorization: Bearer header. For OpenAI-style routes, the Python sample uses <root-endpoint>/async/v1/ as the base URL. See Call an endpoint with a token.
Check a request
Section titled “Check a request”Select Request Status on a queue to follow its requests; search by request ID to find one. A request’s Status is Received, Queued, Processing, Completed, Failed, or Canceled. For a Failed request, you can copy the error message.
The saved answer is a JSON file in the dataset. Use the response location from the call to find it. The tab also lists the steps to read a response from an application with the TIR SDK.
Change or stop async
Section titled “Change or stop async”- Modify Queues changes the routes and destination.
- Disable Async Invocations turns async off after you confirm.
Your application now gets an answer to each queued call at once and picks up the result from the dataset when it is ready. If a request stays Queued or never completes, see Troubleshooting Model Endpoints.
Was this page helpful?