Developers

Quickstart

Install the SDK, restore audio in one call, and save the output.

Restore speech audio by creating a project with your media file, running multiple generations, and downloading results. This quickstart sets your API key, installs the SDK, and walks through each step.

Prerequisites

Before you start, have these ready.

  • A Diffio API key with read and write permissions.
  • A speech focused audio file, for example sample.wav.
  • Python 3.8 or later, or Node 18 or later.

Workflow overview

Projects hold your media. Each project can have multiple generations, often one per model, and you can download each result.

Diffio restoration workflowCreate a project with a media file, run multiple generations with different models, then download the results.Create projectwith mediadiffio-2-flashdiffio-2diffio-3.4GenerationsDownload results
A project contains your media. Create multiple generations under it, then download each restored file.

Using the Diffio SDK

  1. 1

    Create an API key

    Create an API key in the developer dashboard and store it as a secret. Pass the key on every request using the Authorization header (X-Api-Key and Xi-Api-Key also work).

    .env
    DIFFIO_API_KEY=diffio_live_...
  2. 2

    Install the SDK

    Install the Diffio SDK for Python or Node, then load the API key from the environment.

    Python
    pip install diffio python-dotenv
    SDK source code

    Browse the SDK repositories on GitHub: diffio-js and diffio-python .

  3. 3

    Create a project

    Create a file named example.py or example.mjs. Then create a project for your media file. The SDK uploads the file as part of project creation.

    Python
    from dotenv import load_dotenvfrom diffio import DiffioClientimport osload_dotenv()client = DiffioClient(apiKey=os.getenv("DIFFIO_API_KEY"))file_path = "sample.wav"project = client.create_project(    filePath=file_path,)
  4. 4

    Run multiple generations

    Create three generations, one per model, so you can compare the results.

    Python
    models = ["diffio-2-flash", "diffio-2", "diffio-3.4"]generations = []for model in models:    generation = client.create_generation(        apiProjectId=project.apiProjectId,        model=model,    )    generations.append({"model": model, "generation": generation})
  5. 5

    Download each result

    Add this block near the end of the file, then poll each generation and download results. Move the node:fs import to the top of the file with the other imports.

    Python
    import timefor item in generations:    status = "queued"    while status not in ("complete", "failed"):        progress = client.generations.get_progress(            generationId=item["generation"].generationId,            apiProjectId=project.apiProjectId,        )        status = progress.status        print(item["model"], "status:", status)        if status not in ("complete", "failed"):            time.sleep(5)    if status != "complete":        raise SystemExit(f"Generation failed for {item['model']}")    output_name = f"restored-{item['model']}.mp3"    client.generations.download(        generationId=item["generation"].generationId,        apiProjectId=project.apiProjectId,        downloadFilePath=output_name,        downloadType="mp3",    )
    Troubleshooting

    If you receive 401Unauthorized, treated as auth error. or 403Forbidden, treated as permission error., confirm the API key is valid and has read and write permissions. A 402Payment required, billing issue such as paymentFailed. API usage can be blocked until billing is updated. error indicates a billing issue such as a spend limit or a paymentFailed billing hold. API usage can be blocked until billing is updated. A 409Conflict, treated as not ready yet. error indicates the generation is not complete yet, poll progress and retry the download.