---
title: Fish Audio Texto para fala | RunAPI
description: Use o endpoint de texto para fala para receber um resultado na mesma
  resposta.
url: https://runapi.ai/pt-BR/docs/api/fish-audio/text-to-speech.md
canonical: https://runapi.ai/pt-BR/docs/api/fish-audio/text-to-speech
locale: pt-BR
---

> Versão HTML: https://runapi.ai/pt-BR/docs/api/fish-audio/text-to-speech
> Índice do site para agentes: https://runapi.ai/llms.txt

# Fish Audio Texto para fala

## Visão geral

Use o endpoint de texto para fala e leia o resultado na mesma resposta.

### Início rápido

1. Crie uma Chave de API e defina-a como RUNAPI_API_KEY.
2. Envie uma requisição POST cujo corpo corresponda ao schema da requisição.
3. Leia o resultado do corpo da resposta bem-sucedida.

## Endpoint

POST /api/v1/fish_audio/text_to_speech

URL base: https://runapi.ai

Versão da API: v1

Autenticação: Authorization: Bearer YOUR_API_TOKEN

## Modelos suportados

Abra uma página de modelo para ver preços atuais, limites de taxa e detalhes de uso comercial.

- [s1](https://runapi.ai/pt-BR/models/fish-audio/s1)
- [s2-pro](https://runapi.ai/pt-BR/models/fish-audio/s2-pro)
- [s2.1-pro](https://runapi.ai/pt-BR/models/fish-audio/s2.1-pro)

## Esquema de solicitação

Envie apenas os campos declarados para este endpoint.

### s1

```json
{
  "bitrate_kbps": {
    "default": 128,
    "description": "Bitrate do MP3. Não aceito para saída em WAV.",
    "enum": [
      64,
      128,
      192
    ],
    "type": "integer"
  },
  "model": {
    "description": "Slug do modelo.",
    "required": true,
    "type": "string"
  },
  "output_format": {
    "default": "mp3",
    "description": "Formato de áudio de saída.",
    "enum": [
      "mp3",
      "wav"
    ],
    "type": "string"
  },
  "references": {
    "description": "Amostras de áudio de referência inline para esta requisição.",
    "items": {
      "properties": {
        "audio": {
          "description": "Bytes de áudio brutos codificados em Base64.",
          "required": true,
          "type": "string"
        },
        "text": {
          "description": "Transcrição exata do áudio de referência.",
          "required": true,
          "type": "string"
        }
      },
      "type": "object"
    },
    "type": "array"
  },
  "sample_rate_hz": {
    "default": 44100,
    "description": "Taxa de amostragem de saída. MP3 suporta 32000 e 44100 Hz; WAV suporta todos os valores listados.",
    "enum": [
      8000,
      16000,
      24000,
      32000,
      44100
    ],
    "type": "integer"
  },
  "text": {
    "required": true,
    "type": "string"
  },
  "voice_id": {
    "type": "string"
  }
}
```

### s2-pro

```json
{
  "bitrate_kbps": {
    "default": 128,
    "description": "Bitrate do MP3. Não aceito para saída em WAV.",
    "enum": [
      64,
      128,
      192
    ],
    "type": "integer"
  },
  "model": {
    "description": "Slug do modelo.",
    "required": true,
    "type": "string"
  },
  "output_format": {
    "default": "mp3",
    "description": "Formato de áudio de saída.",
    "enum": [
      "mp3",
      "wav"
    ],
    "type": "string"
  },
  "references": {
    "description": "Amostras de áudio de referência inline para esta requisição.",
    "items": {
      "properties": {
        "audio": {
          "description": "Bytes de áudio brutos codificados em Base64.",
          "required": true,
          "type": "string"
        },
        "text": {
          "description": "Transcrição exata do áudio de referência.",
          "required": true,
          "type": "string"
        }
      },
      "type": "object"
    },
    "type": "array"
  },
  "sample_rate_hz": {
    "default": 44100,
    "description": "Taxa de amostragem de saída. MP3 suporta 32000 e 44100 Hz; WAV suporta todos os valores listados.",
    "enum": [
      8000,
      16000,
      24000,
      32000,
      44100
    ],
    "type": "integer"
  },
  "text": {
    "required": true,
    "type": "string"
  },
  "voice_id": {
    "type": "string"
  }
}
```

### s2.1-pro

```json
{
  "bitrate_kbps": {
    "default": 128,
    "description": "Bitrate do MP3. Não aceito para saída em WAV.",
    "enum": [
      64,
      128,
      192
    ],
    "type": "integer"
  },
  "model": {
    "description": "Slug do modelo.",
    "required": true,
    "type": "string"
  },
  "output_format": {
    "default": "mp3",
    "description": "Formato de áudio de saída.",
    "enum": [
      "mp3",
      "wav"
    ],
    "type": "string"
  },
  "references": {
    "description": "Amostras de áudio de referência inline para esta requisição.",
    "items": {
      "properties": {
        "audio": {
          "description": "Bytes de áudio brutos codificados em Base64.",
          "required": true,
          "type": "string"
        },
        "text": {
          "description": "Transcrição exata do áudio de referência.",
          "required": true,
          "type": "string"
        }
      },
      "type": "object"
    },
    "type": "array"
  },
  "sample_rate_hz": {
    "default": 44100,
    "description": "Taxa de amostragem de saída. MP3 suporta 32000 e 44100 Hz; WAV suporta todos os valores listados.",
    "enum": [
      8000,
      16000,
      24000,
      32000,
      44100
    ],
    "type": "integer"
  },
  "text": {
    "required": true,
    "type": "string"
  },
  "voice_id": {
    "type": "string"
  }
}
```

#### Regras condicionais

Esses requisitos se aplicam quando todas as condições listadas corresponderem.

- **Quando**: `output_format` = `wav`; **Não aceito**: `bitrate_kbps`
- **Quando**: `output_format` = `mp3`
- **Quando**: `output_format` = `{"present" => false}`

## Resposta de sucesso

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

### Esquema de resposta

```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
}
```

### Exemplo de resposta

```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"
}
```

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "oneOf": [
    {
      "properties": {
        "error": {
          "description": "Mensagem de erro legível por humanos.",
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "type": "object",
      "unevaluatedProperties": false
    },
    {
      "properties": {
        "error": {
          "description": "Resumo de validação legível por humanos.",
          "type": "string"
        },
        "errors": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Mensagens de validação com chaves por campo de requisição público, com um array de strings legíveis por humanos para cada campo.",
          "type": "object"
        }
      },
      "required": [
        "error",
        "errors"
      ],
      "type": "object",
      "unevaluatedProperties": false
    }
  ]
}
```

### Exemplo de resposta

```json
{
  "error": "model must be one of: s1, s2-pro, s2.1-pro"
}
```

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Erros

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

### Esquema de resposta

```json
{
  "properties": {
    "error": {
      "description": "Mensagem de erro legível por humanos.",
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "type": "object",
  "unevaluatedProperties": false
}
```

### Exemplo de resposta

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

## Exemplos de Código Gerados

Use cURL diretamente ou instale um SDK para a sua linguagem. Cada exemplo submete a requisição validada mostrada nesta referência.

### curl

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

### javascript

#### Instalar

```bash
npm install @runapi.ai/fish-audio
```

```javascript
import { FishAudioClient } from "@runapi.ai/fish-audio";

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

### python

#### Instalar

```bash
pip install runapi-fish-audio
```

```python
import os
from runapi.fish_audio import FishAudioClient

client = FishAudioClient(api_key=os.environ["RUNAPI_API_KEY"])
result = client.text_to_speech.run(
  model="s1",
  text="Welcome to RunAPI."
)
```

### go

#### Instalar

```bash
go get github.com/runapi-ai/fish-audio-sdk/go@latest
```

```go
package main

import (
  "context"
  "log"
  "os"

  "github.com/runapi-ai/core-sdk/go/option"
  fishaudio "github.com/runapi-ai/fish-audio-sdk/go/fishaudio"
)

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

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

### ruby

#### Instalar

```bash
gem install runapi-fish-audio
```

```ruby
require "runapi/fish_audio"

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

### java

#### Instalar

```kotlin
implementation("ai.runapi:runapi-fish-audio")
```

```java
import ai.runapi.fishaudio.FishAudioClient;
import ai.runapi.fishaudio.types.TextToSpeechParams;
import ai.runapi.fishaudio.types.TextToSpeechResponse;

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

### php

#### Instalar

```bash
composer require runapi-ai/fish-audio
```

```php
<?php

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

use RunApi\Core\ClientOptions;
use RunApi\FishAudio\FishAudioClient;

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

## Guias Relacionados

- [Autenticação](https://runapi.ai/pt-BR/docs/guides/authentication.md)
- [Início rápido](https://runapi.ai/pt-BR/docs/guides/task-api/quickstart.md)

---

## Mais de RunAPI

- [Início](https://runapi.ai/pt-BR/.md)
- [Catálogo de modelos](https://runapi.ai/pt-BR/models.md)
- [Preços](https://runapi.ai/pt-BR/pricing.md)
- [Provedores](https://runapi.ai/pt-BR/models)
- [Documentação](https://runapi.ai/pt-BR/docs/guides)
- [SDKs](https://runapi.ai/pt-BR/sdk.md)
- [CLI](https://runapi.ai/pt-BR/cli.md)
- [Servidor MCP](https://runapi.ai/pt-BR/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/pt-BR/claude-code-vs-cursor.md)
- [Configuração da API do Cursor](https://runapi.ai/pt-BR/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/pt-BR/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/pt-BR/contact.md)
- [Contato](https://runapi.ai/pt-BR/contact.md)
- [Termos](https://runapi.ai/pt-BR/terms.md)
- [Privacidade](https://runapi.ai/pt-BR/privacy.md)
- [Índice do site para agentes](https://runapi.ai/llms.txt)

Contato: contact@runapi.ai

## Dados estruturados

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "pt-BR",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/pt-BR",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/pt-BR/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "pt-BR",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/pt-BR",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/pt-BRicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "pt-BR",
    "@type": "TechArticle",
    "headline": "Fish Audio Texto para fala",
    "description": "Use o endpoint de texto para fala para receber um resultado na mesma resposta.",
    "url": "https://runapi.ai/pt-BR/docs/api/fish-audio/text-to-speech",
    "mainEntityOfPage": "https://runapi.ai/pt-BR/docs/api/fish-audio/text-to-speech"
  }
]
```
