Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create voice

Voice audio().voices().create(VoiceCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/audio/voices

Creates a voice from a text prompt or from a consent recording and an audio sample.

For prompt-based creation, send type: "prompt" with a name and prompt as JSON or multipart form data. For creation from an audio sample, send type: "audio_sample" with a name, audio_sample, and consent recording ID as multipart form data. The type defaults to audio_sample when omitted.

Returns the saved voice’s metadata. Voices created from text prompts are supported only in Live, not in Realtime or the speech endpoint. The response does not include preview audio.

ParametersExpand Collapse
VoiceCreateParams params
Body body

Creates a voice from a consent recording and an audio sample. Requires multipart/form-data.

ReturnsExpand Collapse
class Voice:

A custom voice that can be used for audio output. Voices created from text prompts are supported only in Live.

String id

The voice identifier, which can be referenced in API endpoints.

long createdAt

The Unix timestamp (in seconds) for when the voice was created.

formatunixtime
String name

The name of the voice.

JsonValue; object_ "audio.voice"constant"audio.voice"constant

The object type, which is always audio.voice.

Type type

How the voice was created. Voices created from text prompts are supported only in Live.

Create voice

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.voices.Voice;
import com.openai.models.audio.voices.VoiceCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        VoiceCreateParams params = VoiceCreateParams.builder()
            .body(VoiceCreateParams.Body.AudioSample.builder()
                .audioSample(new ByteArrayInputStream("Example data".getBytes()))
                .consent("consent")
                .name("x")
                .build())
            .build();
        Voice voice = client.audio().voices().create(params);
    }
}
{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "audio.voice",
  "type": "audio_sample"
}
Returns Examples
{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "audio.voice",
  "type": "audio_sample"
}