---
title: OpenAI TTS Testo in voce | RunAPI
description: Usa l'endpoint da testo a voce per ricevere un risultato nella stessa
  risposta.
url: https://runapi.ai/it/docs/api/openai-tts/text-to-speech.md
canonical: https://runapi.ai/it/docs/api/openai-tts/text-to-speech
locale: it
---

> Versione HTML: https://runapi.ai/it/docs/api/openai-tts/text-to-speech
> Indice del sito per gli agenti: https://runapi.ai/llms.txt

# OpenAI TTS Testo in voce

## Panoramica

Usa l'endpoint da testo a voce e leggi il risultato dalla stessa risposta.

### Avvio rapido

1. Crea una Chiave API e impostala come RUNAPI_API_KEY.
2. Invia una richiesta POST il cui corpo corrisponde allo schema della richiesta.
3. Leggi il risultato dal corpo della risposta positiva.

## Endpoint

POST /api/v1/openai_tts/text_to_speech

URL di base: https://runapi.ai

Versione API: v1

Autenticazione: Authorization: Bearer YOUR_API_TOKEN

## Modelli supportati

Apri la pagina di un modello per i prezzi correnti, i limiti di frequenza e i dettagli sull'uso commerciale.

- [tts-1](https://runapi.ai/it/models/openai-tts/tts-1)
- [tts-1-hd](https://runapi.ai/it/models/openai-tts/tts-1-hd)

## Schema della richiesta

Invia solo i campi dichiarati per questo endpoint.

### tts-1

```json
{
  "model": {
    "description": "Slug del modello.",
    "required": true,
    "type": "string"
  },
  "text": {
    "length": true,
    "max": 4096,
    "required": true,
    "type": "string"
  }
}
```

### tts-1-hd

```json
{
  "model": {
    "description": "Slug del modello.",
    "required": true,
    "type": "string"
  },
  "text": {
    "length": true,
    "max": 4096,
    "required": true,
    "type": "string"
  }
}
```

## Risposta di successo

HTTP 200 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "audios": {
      "items": {
        "properties": {
          "format": {
            "type": "string"
          },
          "mime_type": {
            "type": "string"
          },
          "size_bytes": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "x-runapi-generated-media": true
          }
        },
        "required": [
          "url",
          "format",
          "mime_type",
          "size_bytes"
        ],
        "type": "object",
        "unevaluatedProperties": false
      },
      "type": "array"
    },
    "billing": {
      "properties": {
        "refund": {
          "oneOf": [
            {
              "properties": {
                "refunded_at": {
                  "type": "string"
                }
              },
              "required": [
                "refunded_at"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "reservation": {
          "oneOf": [
            {
              "properties": {
                "amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "amount_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        },
        "settlement": {
          "oneOf": [
            {
              "properties": {
                "amount_micro_cents": {
                  "type": "integer"
                },
                "charged_amount_cents": {
                  "type": "integer"
                }
              },
              "required": [
                "charged_amount_cents",
                "amount_micro_cents"
              ],
              "type": "object",
              "unevaluatedProperties": false
            },
            {
              "enum": [
                null
              ]
            }
          ]
        }
      },
      "required": [
        "reservation",
        "settlement",
        "refund"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    "id": {
      "type": "string"
    },
    "status": {
      "enum": [
        "completed"
      ],
      "type": "string"
    }
  },
  "required": [
    "id",
    "status",
    "audios",
    "billing"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "audios": [
    {
      "format": "mp3",
      "mime_type": "audio/mpeg",
      "size_bytes": 128,
      "url": "https://file.runapi.ai/reference-audio.mp3"
    }
  ],
  "billing": {
    "refund": null,
    "reservation": null,
    "settlement": null
  },
  "id": "tsk_reference_demo",
  "status": "completed"
}
```

## Errori

HTTP 401 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Authentication required"
}
```

## Errori

HTTP 400 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Messaggio di errore leggibile.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Riepilogo di convalida leggibile dall'utente.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Messaggi di convalida con chiave per campo della richiesta pubblica, con un array di stringhe leggibili dall'utente per ogni campo.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### Esempio di risposta

```json
{
  "error": "model must be one of: tts-1, tts-1-hd"
}
```

## Errori

HTTP 402 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Insufficient balance"
}
```

## Errori

HTTP 429 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "API key credit limit exceeded"
}
```

## Errori

HTTP 409 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "The request uses features that are not supported for the selected model"
}
```

## Errori

HTTP 429 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Rate limit reached. Please retry later."
}
```

## Errori

HTTP 503 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "Service under maintenance, please try again later"
}
```

## Errori

HTTP 504 - POST /api/v1/openai_tts/text_to_speech

### Schema della risposta

```json
{
  "properties": {
    "error": {
      "description": "Messaggio di errore leggibile.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Esempio di risposta

```json
{
  "error": "The request timed out"
}
```

## Esempi di Codice Generati

Usa cURL direttamente, oppure installa un SDK per il tuo linguaggio. Ogni esempio invia la richiesta validata mostrata in questo riferimento.

### curl

```curl
curl -X POST https://runapi.ai/api/v1/openai_tts/text_to_speech \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model":"tts-1","text":"Welcome to RunAPI."}'
```

### javascript

#### Installa

```bash
npm install @runapi.ai/openai-tts
```

```javascript
import { OpenaiTtsClient } from "@runapi.ai/openai-tts";

const client = new OpenaiTtsClient({ apiKey: process.env.RUNAPI_API_KEY });
const result = await client.textToSpeech.run({
  "model": "tts-1",
  "text": "Welcome to RunAPI."
});
```

### python

#### Installa

```bash
pip install runapi-openai-tts
```

```python
import os
from runapi.openai_tts import OpenaiTtsClient

client = OpenaiTtsClient(api_key=os.environ["RUNAPI_API_KEY"])
result = client.text_to_speech.run(
  model="tts-1",
  text="Welcome to RunAPI."
)
```

### go

#### Installa

```bash
go get github.com/runapi-ai/openai-tts-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  openaitts "github.com/runapi-ai/openai-tts-sdk/go/openaitts"
)

func main() {
  client, err := openaitts.NewClient(option.WithAPIKey(os.Getenv("RUNAPI_API_KEY")))
  if err != nil {
    log.Fatal(err)
  }

  result, err := client.TextToSpeech.Run(context.Background(), openaitts.TextToSpeechParams{
    Model: "tts-1",
    Text: "Welcome to RunAPI.",
  })
  if err != nil {
    log.Fatal(err)
  }
  _ = result
}
```

### ruby

#### Installa

```bash
gem install runapi-openai-tts
```

```ruby
require "runapi/openai_tts"

client = RunApi::OpenaiTts::Client.new(api_key: ENV.fetch("RUNAPI_API_KEY"))
result = client.text_to_speech.run(
  model: "tts-1",
  text: "Welcome to RunAPI."
)
```

### java

#### Installa

```kotlin
implementation("ai.runapi:runapi-openai-tts")
```

```java
import ai.runapi.openaitts.OpenaiTtsClient;
import ai.runapi.openaitts.types.TextToSpeechParams;
import ai.runapi.openaitts.types.TextToSpeechResponse;

public final class Example {
  public static void main(String[] args) {
    OpenaiTtsClient client = OpenaiTtsClient.builder()
        .apiKey(System.getenv("RUNAPI_API_KEY"))
        .build();
    TextToSpeechResponse result = client.textToSpeech().run(
        TextToSpeechParams.builder()
        .model("tts-1")
        .text("Welcome to RunAPI.")
            .build()
    );
  }
}
```

### php

#### Installa

```bash
composer require runapi-ai/openai-tts
```

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use RunApi\Core\ClientOptions;
use RunApi\OpenaiTts\OpenaiTtsClient;

$client = new OpenaiTtsClient(new ClientOptions(apiKey: getenv('RUNAPI_API_KEY')));
$result = $client->textToSpeech->run([
  "model" => "tts-1",
  "text" => "Welcome to RunAPI."
]);
```

## Guide correlate

- [Autenticazione](https://runapi.ai/it/docs/guides/authentication.md)
- [Guida introduttiva](https://runapi.ai/it/docs/guides/task-api/quickstart.md)

---

## Altre risorse di RunAPI

- [Home](https://runapi.ai/it/.md)
- [Catalogo dei modelli](https://runapi.ai/it/models.md)
- [Prezzi](https://runapi.ai/it/pricing.md)
- [Fornitori](https://runapi.ai/it/models)
- [Documentazione](https://runapi.ai/it/docs/guides)
- [SDK](https://runapi.ai/it/sdk.md)
- [CLI](https://runapi.ai/it/cli.md)
- [MCP Server](https://runapi.ai/it/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/it/claude-code-vs-cursor.md)
- [Configurazione Cursor API](https://runapi.ai/it/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/it/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/it/contact.md)
- [Contatti](https://runapi.ai/it/contact.md)
- [Termini](https://runapi.ai/it/terms.md)
- [Privacy](https://runapi.ai/it/privacy.md)
- [Indice del sito per gli agenti](https://runapi.ai/llms.txt)

Contatti: contact@runapi.ai

## Dati strutturati

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/it/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/it",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/iticon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "it",
    "@type": "TechArticle",
    "headline": "OpenAI TTS Testo in voce",
    "description": "Usa l'endpoint da testo a voce per ricevere un risultato nella stessa risposta.",
    "url": "https://runapi.ai/it/docs/api/openai-tts/text-to-speech",
    "mainEntityOfPage": "https://runapi.ai/it/docs/api/openai-tts/text-to-speech"
  }
]
```
