Skip to Content
OverviewQuickstart

Get an API key

Go to the Account Management submenu on the console and open Interface Keys to create a key.

Environment setup

Install Python dependencies

Python users can reuse the OpenAI SDK:

pip install --upgrade 'openai>=1.0'

Install cURL

Install curl with your OS package manager:

  1. Debian/Ubuntu (apt):

    sudo apt-get update sudo apt-get install curl
  2. CentOS (yum or dnf; CentOS 8+ uses dnf):

    • With yum:
    sudo yum install curl
    • With dnf (CentOS 8):
    sudo dnf install curl
  3. macOS (brew; install Homebrew from brew.sh  if needed):

    brew install curl

Generate audio (TTS)

Use step-tts-2 to synthesize speech. See Generate audio for full parameters.

from pathlib import Path from openai import OpenAI client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1") speech_file_path = Path("step-tts.mp3") response = client.audio.speech.create( model="step-tts-2", voice="cixingnansheng", input="StepFun intelligence, 10x possibilities for everyone.", ) response.stream_to_file(speech_file_path)

Response

The response is an audio file. The SDK example writes step-tts.mp3, and the cURL example uses --output to save the audio locally.

Last updated on