> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cartesia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Make api request sonic3 bytes python async steps

<>
  <Step title="API を呼び出す">
    ```python lines theme={null}
    import asyncio
    from cartesia import AsyncCartesia
    import os
    import subprocess

    client = AsyncCartesia(
        api_key=os.environ["CARTESIA_API_KEY"],
    )


    async def main():
        with open("sonic-3.wav", "wb") as f:
            bytes_iter = client.tts.bytes(
                model_id="sonic-3.5",
                transcript="Welcome to Cartesia Sonic!",
                voice={
                    "mode": "id",
                    "id": "6ccbfb76-1fc6-48f7-b71d-91ac6298247b",
                },
                language="en",
                output_format={
                    "container": "wav",
                    "sample_rate": 44100,
                    "encoding": "pcm_s16le",
                },
            )

            async for chunk in bytes_iter:
                f.write(chunk)


    if __name__ == "__main__":
        asyncio.run(main())

    # Play the file
    subprocess.run(["ffplay", "-autoexit", "-nodisp", "sonic-3.wav"])
    ```
  </Step>

  <Step title="スクリプトを実行する">
    ```sh lines theme={null}
    env CARTESIA_API_KEY=YOUR_API_KEY python cartesia.py

    # Or, if you're using uv
    env CARTESIA_API_KEY=YOUR_API_KEY uv run cartesia.py
    ```
  </Step>
</>
