Grok API
  1. Guides
Grok API
  • Getting started
    • Introduction
    • Models and Pricing
    • Billing
    • Consumption and Rate Limits
    • Usage Explorer
    • Free Credits
  • Guides
    • Asynchronous Requests
    • Image Understanding
    • Structured Outputs
    • Migration from Other Providers
    • Chat
      POST
    • Reasoning
      POST
    • Streaming Response
      POST
    • Deferred Chat Completions
      POST
    • Image Generations
      POST
    • Fingerprint
      POST
  1. Guides

Asynchronous Requests

When working with the xAI API, you may need to process hundreds or even thousands of requests. Sending these requests sequentially can be extremely time-consuming.
To improve efficiency, you can use AsyncOpenAI from the openai SDK, which allows you to send multiple requests concurrently. The example below is a Python script demonstrating how to use AsyncOpenAI to batch and process requests asynchronously, significantly reducing the overall execution time:
The xAI API does not currently offer a batch API.

Rate Limits#

Adjust the max_concurrent param to control the maximum number of parallel requests.You are unable to concurrently run your requests beyond the rate limits shown in the API console.
Modified at 2025-04-10 09:08:00
Previous
Free Credits
Next
Image Understanding
Built with