Skip to main content

Logo

MythicInfinity Python Client

pypi version supported python versions license

Up to 100x Cheaper, High Quality, Realtime Text-to-Speech
Sign Up for an API Key »

Read the docs · Report Bug

Overview

  • Easy installation with pip.
  • Streaming audio bytes and non-streaming both supported.
  • Async/await and standard sync code both supported.
  • Full IDE support with autocomplete, type-hinting, and in-code documentation.

Table of Contents

Installation

Install the python package as a dependency of your application.

$ pip install mythicinfinity

Basic Example

from mythicinfinity import MythicInfinityClient


def main():
    # Instantiate the client with your api key
    client = MythicInfinityClient(api_key="YOUR_API_KEY")
    
    # Call the TTS API. By default, stream is False.
    audio_bytes = client.tts.generate(text="Hello world.")
    
    with open('my_audio.wav', 'wb') as f:
        f.write(audio_bytes)

if __name__ == "__main__":
    main()

This sample calls the Text-To-Speech service and saves the resultant audio bytes to a file.

Environment Variables

Name Description
MYTHICINFINITY_API_KEY Sets the api key. There is no need to pass api_key="YOUR_API_KEY" to the client constructor when using the environment variable.

Streaming Example

from mythicinfinity import MythicInfinityClient


def main():
    # Instantiate the client with your api key
    client = MythicInfinityClient(api_key="YOUR_API_KEY")
    
    # Call the TTS API with stream=True.
    # This will stream the audio bytes in real-time, 
    #   as they become available from the AI model.
    audio_bytes_generator = client.tts.generate(text="Hello world.", stream=True)
    
    with open('my_audio.wav', 'wb') as f:
        for audio_bytes in audio_bytes_generator:
            f.write(audio_bytes)

if __name__ == "__main__":
    main()

Async Support

  • Code relying on async / await patterns is fully supported.
import asyncio
from mythicinfinity import AsyncMythicInfinityClient


async def main():
    # Instantiate the client with your api key
    client = AsyncMythicInfinityClient(api_key="YOUR_API_KEY")
    
    # Call the TTS API with stream=False.
    audio_bytes = await client.tts.generate(text="Hello world.")
    
    with open('my_async_audio_1.wav', 'wb') as f:
        f.write(audio_bytes)
    
    # Call the TTS API with stream=True.
    # This will stream the audio bytes in real-time, 
    #   as they become available from the AI model.
    audio_bytes_generator = await client.tts.generate(text="Hello world.", stream=True)
    
    with open('my_async_audio_2.wav', 'wb') as f:
        async for audio_bytes in audio_bytes_generator:
            f.write(audio_bytes)

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

This sample first calls the client.tts.generate method without streaming using await and then does the same with streaming enabled.

Voice Options

The voice_id parameter controls which voice is used for the generated audio.

You can use the Voice API to list all available voice ids and get their related metadata.

The model supports various options which can be set to adjust the way audio is generated with the voice in various ways.

Each voice may specify its own default values for these parameters.

Voice Option Parameters:

  • consistency - The recommended value is 2.0. Higher values tend to follow text more reliably, and pronounce words with more accuracy, but alters the way speech is spoken and may increase the speaking rate.
from mythicinfinity import MythicInfinityClient, VoiceOptions

def main():
    # Instantiate the client with your api key
    client = MythicInfinityClient(api_key="YOUR_API_KEY")
    
    # Call the API setting the consistency VoiceOption
    audio_bytes_generator = client.tts.generate(
        text="Hello world.", stream=True,
        voice_id="",
        voice_options=VoiceOptions(
            consistency=2.4,
        )
    )
    
    with open('my_audio.wav', 'wb') as f:
        for audio_bytes in audio_bytes_generator:
            f.write(audio_bytes)

if __name__ == "__main__":
    main()

Output Formats

By default, outputs are in the wav format.

The currently supported output formats are:

  • wav - 24khz 16 bit WAV
  • pcm - 24khz 16 bit raw PCM data
  • mp3 - 24khz 192kbps MP3
  • webm_opus - 24khz 128kbps OPUS inside a WEBM container (saved as a .webm file)

For streaming playback (that starts before the whole audio is done generating), usually mp3 or webm_opus are used.

For the highest output quality, we recommend wav.

Specifying Output Format

To specify the output format, simply set the format parameter in the .generate() call.

Valid values are wav, pcm, mp3 and webm_opus.

from mythicinfinity import MythicInfinityClient

def main():
    # Instantiate the client with your api key
    client = MythicInfinityClient(api_key="YOUR_API_KEY")
    
    # Call the API setting format=mp3
    audio_bytes_generator = client.tts.generate(text="Hello world.", stream=True, format="mp3")
    
    # Save the audio as a .mp3 file
    with open('my_audio.mp3', 'wb') as f:
        for audio_bytes in audio_bytes_generator:
            f.write(audio_bytes)

if __name__ == "__main__":
    main()

Voice API

Voice Object
class Voice:
    name: str
    voice_id: str
    model_ids: typing.List[str]
    """
    Model IDs that this voice is compatible with.
    """

    preview_urls_by_model_id: typing.Dict[str, str]
    """
    Preview urls for this voice per model id.
    """

The voice objects returned by this api will have this structure.

List Voices

Sync

all_voices = client.tts.voices.list()

Async

all_voices = await async_client.tts.voices.list()
Get Voice Data

Sync

voice = client.tts.voices.get("kiera")

Async

voice = await async_client.tts.voices.get("kiera")

Metadata

Release files for mythicinfinity 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mythicinfinity 0.1.6
File Size Uploaded
mythicinfinity-0.1.6.tar.gz 25.6 kB Details

Release files / mythicinfinity-0.1.6.tar.gz

Download URL mythicinfinity-0.1.6.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
80b1afeb91c2bc532830da65fd87e1755a99f6514424dce41a1cb02decf17695
BLAKE2b-256 checksum
How to use checksums
53149d36b88932bd17f72df0db315c97e9285da7720241e0c15eb05c2f913cff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.6 This release

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page