Soniox
SDKsPython

Handling files with Python SDK

Upload audio files and manage them with the Soniox Python SDK

Use the Files API to upload audio for async transcription or to reuse files across multiple jobs.

Upload

upload() accepts bytes, file paths (str or Path), or a file-like object (BinaryIO).

from soniox import SonioxClient

client = SonioxClient()

file = client.files.upload("audio.mp3")
print(file.id, file.filename, file.size)

Read more about Supported audio formats.

Get file

Get a file by ID, throws SonioxNotFoundError if file does not exist:

file = client.files.get("file-id")
print(file.id, file.filename)

Get file or none:

file = client.files.get_or_none("file-id")
if file is None:
    print("File not found")

List files

List files returns a paginated response. Use next_page_cursor to fetch additional pages until it is None.

from soniox import SonioxClient

client = SonioxClient()

response = client.files.list(limit=100)
for file in response.files:
    print(file.id, file.filename)

# Pagination
while response.next_page_cursor:
    response = client.files.list(limit=100, cursor=response.next_page_cursor)
    for file in response.files:
        print(file.id, file.filename)

Delete file

Delete file by ID, throws SonioxNotFoundError if file does not exist:

client.files.delete("file-id")

Delete file only if exists:

client.files.delete_if_exists("file-id")

Delete all files

Delete all files iterates through every page and removes each file.

client.files.delete_all()