curl https://api.naga.ac/v1/audio/speech \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Hello from NagaAI.",
"voice": "alloy",
"response_format": "mp3"
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.audio.speech.create(
model="tts-1",
input="Hello from NagaAI.",
voice="alloy",
response_format="mp3",
)
print(result)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.audio.speech.create({
model: "tts-1",
input: "Hello from NagaAI.",
voice: "alloy",
response_format: "mp3",
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/audio/speech"
payload := strings.NewReader("{\n \"model\": \"tts-1\",\n \"input\": \"Hello from NagaAI.\",\n \"voice\": \"alloy\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"title": "speech",
"description": "The body is the audio file itself. Write it to disk or hand it to a player; there is no JSON around it."
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_api_key",
"message": "The provided API key is invalid. Please ensure your API key is correct and active. You can find more information about obtaining a key on our website: https://naga.ac If you just created this key, wait a few minutes and try again."
}
}{
"error": {
"type": "insufficient_quota",
"message": "More credits required to process this request. Visit https://naga.ac/dashboard/credits to add credits."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit reached. Please try again in 3s."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}Create speech
Converts text into spoken audio and charges the account for what it counted. Requires an API key.
curl https://api.naga.ac/v1/audio/speech \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Hello from NagaAI.",
"voice": "alloy",
"response_format": "mp3"
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.audio.speech.create(
model="tts-1",
input="Hello from NagaAI.",
voice="alloy",
response_format="mp3",
)
print(result)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.audio.speech.create({
model: "tts-1",
input: "Hello from NagaAI.",
voice: "alloy",
response_format: "mp3",
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/audio/speech"
payload := strings.NewReader("{\n \"model\": \"tts-1\",\n \"input\": \"Hello from NagaAI.\",\n \"voice\": \"alloy\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"title": "speech",
"description": "The body is the audio file itself. Write it to disk or hand it to a player; there is no JSON around it."
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_api_key",
"message": "The provided API key is invalid. Please ensure your API key is correct and active. You can find more information about obtaining a key on our website: https://naga.ac If you just created this key, wait a few minutes and try again."
}
}{
"error": {
"type": "insufficient_quota",
"message": "More credits required to process this request. Visit https://naga.ac/dashboard/credits to add credits."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "rate_limit_exceeded",
"message": "Rate limit reached. Please try again in 3s."
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
An account API key. Send it as Authorization: Bearer <key>.
Body
The request body of POST /v1/audio/speech, answered with audio.
The speech model to synthesise with, named by its id or alias.
The text to read aloud, at most 32768 Unicode characters.
The voice to read in, by the name the model knows it under.
How fast to read, as a multiplier of the model's normal pace. Zero or less draws a 400.
Free-form direction for how the text should be delivered.
The audio container to synthesise into, which also sets the answer's Content-Type.
mp3, opus, aac, flac, wav, pcm Response
The synthesised audio itself, streamed as it is produced. Content-Type names the container response_format asked for, or audio/mpeg when the key was left out and the provider named none of its own.