aito.api.batch

aito.api.batch(client: AitoClient, queries: List[Dict], raise_for_status: bool | None = None) BatchResponse | RequestError

execute multiple queries in a single request using the Batch API

The batch endpoint allows executing multiple queries (predict, similarity, search, etc.) in a single HTTP request for improved performance.

Example:

import aito.api as api

# Execute multiple queries in one request
results = api.batch(client, [
    {"from": "products", "where": {"name": "rye bread"}, "predict": "category"},
    {"from": "products", "similarity": {"name": "rye bread"}, "limit": 5}
])

# Access individual results
predict_result = results[0]  # First query result
similarity_result = results[1]  # Second query result
Parameters:
  • client (AitoClient) – the AitoClient instance

  • queries (List[Dict]) – a list of query dictionaries to execute in batch

  • raise_for_status (Optional[bool]) – raise RequestError if the request fails instead of returning the error If set to None, value from Client will be used. Defaults to None

Returns:

BatchResponse containing results for each query, or RequestError if an error occurred

Return type:

Union[BatchResponse, RequestError]