Using Python Methods

Make use of the Python methods included in the deepset Cloud SDK. Learn about synchronous and asynchronous client and when to use each.



When using Python methods, you can first configure the API key and default workspace for all operations using the CLI. You won't need to pass this information in your scripts if you do that.

Synchronous and Asynchronous Client

deepset Cloud SDK includes a synchronous and an asynchronous client. The synchronous client blocks execution until it receives a response from the server. This means the code pauses after sending a request and waits for the server's reply before continuing. This approach is easier to understand and debug because it follows a straightforward, linear execution path. However, it may not be the most resource-efficient method if your application needs to manage multiple tasks at the same time, particularly in operations that are bound by input/output limitations.

The asynchronous client allows the code to run continuously while waiting for the server's response. This functionality is enabled by Python's asyncio library, which supports executing multiple operations concurrently. Instead of pausing to wait for one operation to finish before starting the next, this method handles several tasks simultaneously. It's particularly useful for I/O-bound tasks like network requests.

Running the Asynchronous Client

To run asynchronous code, you typically define functions with async def and use await to call them. For example:

import asyncio
from deepset_cloud_sdk.workflows.async_client.files import list_files

async def my_async_context() -> None:
    async for file_batch in list_files(
        api_key="<deepset Cloud API key>",
        for file in file_batch:

# Run the async function
if __name__ == "__main__":

See also:

Upload Files with Python

List Existing Files with Python

Get Upload Sessions Details

Download Files with Python

Related Links