# HeyGen Voice 1

> Generate speech or change the voice in a recording with HeyGen.

Введите текст, выберите голос, язык и скорость. Цена зависит от количества символов. Поддерживаются теги эмоций HeyGen.

ID: `heygen-voice-1` · $0.13 per 1,000 characters · under 1 min

## Parameters

| Field | Type | Values | What it does |
|---|---|---|---|
| `text` | string | 1–10,000 characters | The text to speak, Russian or another language. Pause: `<#0.5#>` (seconds). `prompt` is accepted instead of `text`. |
| `voice` | string | see the table below | Voice, default `Russian_ReliableMan` |
| `speed` | number | 0.5–2.0 | Speech speed, 1 = normal |
| `emotion` | string | auto, neutral, happy, sad, angry, fearful, disgusted, surprised, calm, fluent | Emotion: auto lets the model choose; happy, sad, angry, fearful, disgusted, surprised, calm, fluent, neutral |

## Voices

| `voice` | Voice | Gender |
|---|---|---|
| `Russian_ReliableMan` | Надёжный мужчина | male |
| `Russian_HandsomeChildhoodFriend` | Дружелюбный мужчина | male |
| `Russian_AttractiveGuy` | Молодой мужчина | male |
| `Russian_BrightHeroine` | Яркая героиня | female |
| `Russian_AmbitiousWoman` | Уверенная женщина | female |
| `Russian_CrazyQueen` | Эмоциональная женщина | female |
| `Russian_PessimisticGirl` | Задумчивая девушка | female |

## Example

```bash
curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"heygen-voice-1","input":{"text":"Hello! Welcome to our bot. Today we will tell you about new features.","voice":"Russian_AmbitiousWoman","speed":1.1,"emotion":"happy"}}'
```

```python
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "heygen-voice-1",
      "input": {
        "text": "Hello! Welcome to our bot. Today we will tell you about new features.",
        "voice": "Russian_AmbitiousWoman",
        "speed": 1.1,
        "emotion": "happy"
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
```

```javascript
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "heygen-voice-1",
    "input": {
      "text": "Hello! Welcome to our bot. Today we will tell you about new features.",
      "voice": "Russian_AmbitiousWoman",
      "speed": 1.1,
      "emotion": "happy"
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }
```

Then poll the status every 2–3 seconds:

```bash
curl "https://mixmedia.tech/api/v1/jobs/recordInfo?taskId=TASK_ID" \
  -H "Authorization: Bearer $API_KEY"
```

```python
import os, requests

r = requests.get(
    "https://mixmedia.tech/api/v1/jobs/recordInfo",
    params={"taskId": "TASK_ID"},
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
print(r.json())
```

```javascript
const r = await fetch("https://mixmedia.tech/api/v1/jobs/recordInfo?taskId=TASK_ID", {
  headers: { Authorization: `Bearer ${process.env.API_KEY}` },
});
console.log(await r.json());
```

## Result

When `state` is `success`, `resultJson` has `resultUrls` with one MP3 link (32 kHz, 128 kbps, mono) and `duration` in seconds. The file is kept for 24 hours, so download it right away. You can pass the link straight to [HeyGen Lipsync Precision](https://docs.mixmedia.tech/en/models/heygen-lipsync-precision) as `input.audio_urls`.

```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_minimax-speech-2.8-hd_…",
    "model": "heygen-voice-1",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://mixmedia.tech/files/….mp3\"],\"duration\":6.42}"
  }
}
```

**Speech → lip-sync**

```bash
curl -X POST https://mixmedia.tech/api/v1/jobs/createTask \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"heygen-lipsync-precision","input":{"video_url":"https://example.com/talking-head.mp4","audio_urls":["https://mixmedia.tech/files/….mp3"],"keep_the_same_format":true}}'
```

```python
import os, requests

r = requests.post(
    "https://mixmedia.tech/api/v1/jobs/createTask",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={
      "model": "heygen-lipsync-precision",
      "input": {
        "video_url": "https://example.com/talking-head.mp4",
        "audio_urls": [
          "https://mixmedia.tech/files/….mp3"
        ],
        "keep_the_same_format": True
      }
    },
)
print(r.json())  # {"code": 200, "data": {"taskId": "..."}}
```

```javascript
const r = await fetch("https://mixmedia.tech/api/v1/jobs/createTask", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "model": "heygen-lipsync-precision",
    "input": {
      "video_url": "https://example.com/talking-head.mp4",
      "audio_urls": [
        "https://mixmedia.tech/files/….mp3"
      ],
      "keep_the_same_format": true
    }
  }),
});
console.log(await r.json()); // { code: 200, data: { taskId: "..." } }
```

## Price

$0.13 per 1,000 characters of `text` (spaces and punctuation count; Chinese, Japanese and Korean characters count as 2). The total is rounded up to $0.001, minimum $0.001. For example, 500 characters cost $0.065. A failure is refunded in full.

## Error handling

API responses are JSON `{"code", "msg", "data"}`; errors also have a string `error` field (type). **On `/api/v1/*` the HTTP status matches body `code`.**

### Example response bodies

**400**

```json
{
  "code": 400,
  "msg": "input.duration: must be between 4 and 30, or \"auto\" / -1",
  "data": null,
  "error": "invalid_request_error"
}
```

**401**

```json
{
  "code": 401,
  "msg": "Authentication failed. Please check your API key",
  "data": null,
  "error": "authentication_error"
}
```

**402**

```json
{
  "code": 402,
  "msg": "Insufficient balance. Please top up and try again. Available: $0.01, required: $0.015. Top up at https://mixmedia.tech/cabinet/billing",
  "data": {
    "balance": "0.0100",
    "required": "0.0150",
    "currency": "USD",
    "topUpUrl": "https://mixmedia.tech/cabinet/billing"
  },
  "error": "payment_required"
}
```

**429**

```json
{
  "code": 429,
  "msg": "Rate limit exceeded: 10 createTask/upload requests per 10 s per key. Retry after 8s",
  "data": null,
  "error": "rate_limit_error"
}
```

**500**

```json
{
  "code": 500,
  "msg": "Internal server error",
  "data": null,
  "error": "server_error"
}
```

### Codes on createTask / upload

| code | error | Meaning | What to do |
|---|---|---|---|
| 400 | `invalid_request_error` | Invalid parameter or body | See `msg` |
| 400 | `unsupported_model` | Unknown model | [Model list](https://docs.mixmedia.tech/en/models) |
| 401 | `authentication_error` | Missing or invalid key | Check the key |
| 402 | `payment_required` | Not enough balance | Top up |
| 403 | `permission_error` | No access | Contact support |
| 429 | `rate_limit_error` | Too many requests | Wait for `Retry-After` |
| 505 | `model_disabled` | Model temporarily disabled | Pick another |
| 500 | `server_error` | Our failure | Retry later |

Example `msg` values: `Authentication failed. Please check your API key` (401); `Insufficient balance. Please top up and try again…` (402).

### Task errors (recordInfo)

If the task was created and then failed: `state: "fail"` (alias `status: "failed"`), `failCode` / `failMsg`, and `error: { code, message, type }`. Money is refunded (`refunded: true`).

| failCode | error.type | Meaning |
|---|---|---|
| 400 | `nsfw_content_detected` / `invalid_request_error` | Moderation — `failMsg` is upstream text verbatim |
| 422 | `invalid_request_error` | The model rejected the parameters (e.g. a photo could not be downloaded) |
| 501 | `server_error` | The model could not generate (`failMsg`) |
| 504 | `timeout_error` | Timed out — retry |
| 500 / 503 | `server_error` | Service temporarily unavailable |

### Rate limits

| What | Limit |
|---|---|
| createTask and upload | 20 per 10 s per key |
| recordInfo / list / balance | 100 per 10 s per key |

Over the limit — HTTP 429 and `Retry-After`.
