> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 创建配音目标语言

POST https://api.elevenlabs.io/v1/dubbing/project/{project_id}/language
Content-Type: application/json

添加项目配音目标语言，并将配音任务加入队列。

此调用会生成配音音频，并按次计费。目标创建后状态为 `queued`，项目达到 `ready` 状态后便会开始处理，因此可在项目创建后的任何时间添加。它会继承项目的配音模型，无法选择其他模型。

使用 `webhook_ids` 创建的项目会发送包含输出下载 URL 的 `dubbing_language_completed` 事件，因此建议订阅该事件，而非轮询此目标直至完成。

Reference: https://elevenlabs.io/docs/api-reference/dubbing/language-targets/create-language-target

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `project_id` (string, required) — 父配音项目标识符。

### Body (application/json)

This endpoint expects a Body_Create_Dubbing_Language_Target_v1_dubbing_project__project_id__language_post.

- `target_language` (string, required) — BCP-47 language tag to dub the project into (for example, `fr` or `es-MX`). Must be one of the [languages the project's dubbing model supports](https://elevenlabs.io/docs/help-center/product/dubbing/which-languages-are-supported-in-dubbing), and a region-qualified tag must be one of the supported dialects.
- `voice_settings` (VoiceSettings, optional, nullable) — 应用于该语言中每位说话者的音色设置。省略则使用默认设置。
- `translations` (map from string to string, optional, nullable) — 仅限企业版。可选翻译，可替代机器翻译。将每个源片段的 `external_id`（如果未提供，则使用其 `id`）映射到译文；每个源片段必须且只能覆盖一次。最多 20,000 个条目，文本总量不超过 4 MiB。请参阅 [自带转录文本](https://elevenlabs.io/docs/eleven-api/guides/how-to/dubbing/bring-your-own-transcript)。

## Response

### 201

成功响应

- `language_id` (string, required) — 目标语言的唯一标识符。
- `project_id` (string, required) — 父配音项目标识符。
- `target_language` (string, required) — BCP-47 language tag this target is dubbed into.
- `status` (enum, required) — 生命周期状态：`queued`（等待项目就绪或等待工作线程）、配音期间为 `processing`、输出可用后为 `completed`、输出生成后转录内容发生变更时为 `stale`，或为 `failed`。
  - Allowed values: `queued`, `processing`, `completed`, `stale`, `failed`
- `revision` (integer, required) — 每当此目标的转录文本发生变化时递增的单调计数器（影响它的源编辑，或对其翻译的编辑）。
- `created_at` (string, required) — 创建语言目标的时间。
- `updated_at` (string, required) — 语言目标上次更新的时间。
- `model_id` (string, optional, nullable) — 此目标使用的配音模型，从项目继承，不能按语言选择。
- `voice_settings` (VoiceSettings, optional, nullable) — 应用于该语言中每位说话者的音色设置；使用默认设置时为 null。
- `outputs` (DubbingLanguageOutputs, optional, nullable) — 已签名的输出 URL；在目标生成输出前为 null（`completed` 后会提供，并在 `stale` 时保留——比较 `output_revision` 和 `revision` 可判断输出是否为最新）。
- `output_revision` (integer, optional, nullable) — 当前配音输出生成时所基于的 `revision`；最新时等于 `revision`，`stale` 时则小于它。在生成完成前，此值为 null。
- `error` (DubbingError, optional, nullable) — 此语言失败的原因；除非 `status` 为 `failed`，否则为 null；对于在引入失败报告前失败的少数语言，此字段也为 null。代码 `project_failed` 表示父项目失败，请查看该项目以了解根本原因。
- `warnings` (list of VoicesNotPermittedWarning, optional) — 为此语言配音时出现的非致命情况；没有时为空。反映最新一次生成。准备源内容时出现的情况会在项目中报告。

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### VoiceSettings

- `cloning_strength` (integer, optional, default: 7) — 配音说话者克隆源音色的强度，范围为 0 至 10。

### DubbingLanguageOutputs

语言目标输出的带签名限时下载 URL。

- `lossless_audio` (string, optional, nullable) — FLAC 格式配音无损音轨的签名 URL。链接签发 1 小时后过期；重新读取语言目标可获取新链接。
- `subtitles` (string, optional, nullable) — 译文行的签名 URL，以与源语音同步的 WebVTT 字幕形式提供。没有可用字幕时为 null，例如在字幕生成前已完成配音的语言。链接签发后 1 小时过期。

### DubbingError

- `message_type` ("error", required)
- `error` (string, required)

### VoicesNotPermittedWarning

- `type` ("voices_not_permitted", required) — 标识此警告；根据此字段进行分支处理以读取其他字段。
- `speaker_ids` (list of string, required) — 不允许克隆音色的说话人。配音会为每位此类说话人使用替代音色；其他说话人不受影响。
- `message` (string, required) — 供展示的人类可读警告说明。措辞可能随时更改，因此建议改为根据 `type` 进行分支处理。

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "target_language": "es"
}
```

**Response**

```json
{
  "language_id": "lang_1001kwkyxp0je6ktn4knsfrasx5s",
  "project_id": "proj_1601kwkyxp0hfzvtmyxwqxx6mcy3",
  "target_language": "es",
  "status": "queued",
  "revision": 0,
  "created_at": "2026-07-03T10:16:00Z",
  "updated_at": "2026-07-03T10:16:00Z",
  "model_id": "dubbing_v2",
  "warnings": []
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language"

payload = { "target_language": "es" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"target_language":"es"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language"

	payload := strings.NewReader("{\n  \"target_language\": \"es\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"target_language\": \"es\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language")
  .header("Content-Type", "application/json")
  .body("{\n  \"target_language\": \"es\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language', [
  'body' => '{
  "target_language": "es"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"target_language\": \"es\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["target_language": "es"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/dubbing/project/proj_1601kwkyxp0hfzvtmyxwqxx6mcy3/language")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```