> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reedapt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Libraries

> Official Node.js, Python, Go, Rust and PHP (Laravel) libraries that handle uploads, retries and webhook signatures for you.

The libraries do everything the API does, plus the parts that take the most code by hand: sending files in parts, retrying safely, and checking webhook signatures.

> [card] [Node.js](https://www.npmjs.com/package/reedapt)
>
> `npm install reedapt`. Node.js 18 or later, with TypeScript types.

> [card] [Python](https://pypi.org/project/reedapt/)
>
> `pip install reedapt`. Python 3.9 or later, sync and asyncio.

> [card] [Go](https://pkg.go.dev/github.com/Reedapt/reedapt-go)
>
> `go get github.com/Reedapt/reedapt-go`. Go 1.21 or later, standard library only.

> [card] [Rust](https://crates.io/crates/reedapt)
>
> `cargo add reedapt`. Rust 1.83 or later, async with an optional blocking client.

> [card] [PHP and Laravel](https://packagist.org/packages/reedapt/reedapt-php)
>
> `composer require reedapt/reedapt-php`. PHP 8.1 or later, with Laravel built in.

## Dub a file

All of them read your key from `REEDAPT_API_KEY`.

```javascript Node.js theme={"system"}
import Reedapt from "reedapt";

const reedapt = new Reedapt();

const { dubs, refused } = await reedapt.dub("./interview.mp4", {
  source_language: "en",
  target_languages: ["fr", "es"],
  metadata: { order_id: "1042" },
});
```

```python Python theme={"system"}
from reedapt import Reedapt

reedapt = Reedapt()

created = reedapt.dub(
    "interview.mp4",
    source_language="en",
    target_languages=["fr", "es"],
    metadata={"order_id": "1042"},
)
```

```go Go theme={"system"}
client := reedapt.NewClient("") // reads REEDAPT_API_KEY

created, err := client.DubPath(ctx, "./interview.mp4", &reedapt.DubParams{
	SourceLanguage:  "en",
	TargetLanguages: []string{"fr", "es"},
	Metadata:        map[string]string{"order_id": "1042"},
})
```

```rust Rust theme={"system"}
let client = reedapt::Client::from_env()?; // reads REEDAPT_API_KEY

let created = client
    .dub_file("interview.mp4", DubParams::new("en", ["fr", "es"]).metadata("order_id", "1042"))
    .await?;
```

```php PHP theme={"system"}
$client = new Reedapt\Client(); // reads REEDAPT_API_KEY

['dubs' => $dubs, 'refused' => $refused] = $client->dub('./interview.mp4', [
    'source_language' => 'en',
    'target_languages' => ['fr', 'es'],
    'metadata' => ['order_id' => '1042'],
]);
```

`dub` uploads the file in parts, four at a time, and starts one dub per language. Give it a public `https://` link instead of a path and Reedapt downloads the file itself.

## Get the files

Use a [webhook](https://docs.reedapt.com/guides/webhooks.md) in production. While building, you can wait in code:

```javascript Node.js theme={"system"}
const dub = await reedapt.dubs.waitUntilDone(dubs[0].id);
if (dub.status === "completed") {
  const { files } = await reedapt.dubs.files(dub.id);
  console.log(files[0].url); // lasts an hour
}
```

```python Python theme={"system"}
dub = reedapt.dubs.wait_until_done(created["dubs"][0]["id"])
if dub["status"] == "completed":
    files = reedapt.dubs.files(dub["id"])["files"]
    print(files[0]["url"])  # lasts an hour
```

```go Go theme={"system"}
dub, err := client.Dubs.WaitUntilDone(ctx, created.Dubs[0].ID, nil)
if err == nil && dub.Status == reedapt.DubStatusCompleted {
	files, _ := client.Dubs.Files(ctx, dub.ID)
	fmt.Println(files.Files[0].URL) // lasts an hour
}
```

```rust Rust theme={"system"}
let dub = client.dubs().wait_until_done(&created.dubs[0].id, Default::default()).await?;
if dub.status == DubStatus::Completed {
    let files = client.dubs().files(&dub.id).await?;
    println!("{}", files.files[0].url); // lasts an hour
}
```

```php PHP theme={"system"}
$dub = $client->dubs->waitUntilDone($dubs[0]['id']);
if ($dub['status'] === 'completed') {
    $files = $client->dubs->files($dub['id'])['files'];
    echo $files[0]['url']; // lasts an hour
}
```

## Check webhook signatures

Pass the raw body, exactly as it arrived:

```javascript Node.js theme={"system"}
import { constructWebhookEvent } from "reedapt";

const event = constructWebhookEvent(rawBody, req.get("Reedapt-Signature"), process.env.REEDAPT_WEBHOOK_SECRET);
```

```python Python theme={"system"}
from reedapt import construct_webhook_event

event = construct_webhook_event(raw_body, request.headers.get("Reedapt-Signature"), os.environ["REEDAPT_WEBHOOK_SECRET"])
```

```go Go theme={"system"}
event, err := webhook.ConstructEvent(body, r.Header.Get("Reedapt-Signature"), os.Getenv("REEDAPT_WEBHOOK_SECRET"))
```

```rust Rust theme={"system"}
let event = reedapt::webhook::construct_event(body, signature, &secret)?;
```

```php PHP theme={"system"}
use Reedapt\Webhook;

$event = Webhook::constructEvent($payload, $header, getenv('REEDAPT_WEBHOOK_SECRET'));
```

A delivery that doesn't check out raises `WebhookVerificationError` (in Go and Rust, `ConstructEvent` / `construct_event` returns an error). In Laravel, put the route behind the package's `reedapt.webhook` middleware and listen for events such as `DubCompleted`; the PHP README shows the setup.

## Ask Reedapt for changes

Early access: [asking for changes](https://docs.reedapt.com/guides/changes.md) is on some paid accounts first, and the others get `NOT_AVAILABLE`. Add `instructions` to `dub` or `dubs.create` for notes on the dub itself, and read the quality report with `dubs.quality`.

```javascript Node.js theme={"system"}
const run = await reedapt.dubs.requests.create("job_3f9a2c7e1b4d", {
  text: "Is line 3 natural? If not, make it sound calmer.",
  autonomy: "ask", // nothing changes until you answer
});
if (run.status === "needs_input") {
  await reedapt.runs.answer(run.id, { choice: "apply" }); // or "decline"
}
const { lines } = await reedapt.dubs.lines.list("job_3f9a2c7e1b4d");
```

```python Python theme={"system"}
run = reedapt.dubs.requests.create(
    "job_3f9a2c7e1b4d",
    text="Is line 3 natural? If not, make it sound calmer.",
    autonomy="ask",  # nothing changes until you answer
)
if run["status"] == "needs_input":
    reedapt.runs.answer(run["id"], choice="apply")  # or "decline"
lines = reedapt.dubs.lines.list("job_3f9a2c7e1b4d")["lines"]
```

```go Go theme={"system"}
run, err := client.Dubs.Requests.Create(ctx, "job_3f9a2c7e1b4d", &reedapt.CreateRunParams{
	Text: "Is line 3 natural? If not, make it sound calmer.",
})
if err == nil && run.Status == reedapt.RunStatusNeedsInput {
	run, err = client.Runs.Answer(ctx, run.ID, &reedapt.AnswerRunParams{Choice: reedapt.RunChoiceApply}) // or RunChoiceDecline
}
lines, err := client.Dubs.Lines.List(ctx, "job_3f9a2c7e1b4d")
```

```rust Rust theme={"system"}
let mut run = client
    .dubs()
    .requests()
    .create("job_3f9a2c7e1b4d", CreateRunParams::new("Is line 3 natural? If not, make it sound calmer."))
    .await?;
if run.status == RunStatus::NeedsInput {
    run = client.runs().answer(&run.id, RunChoice::Apply).await?; // or RunChoice::Decline
}
let lines = client.dubs().lines().list("job_3f9a2c7e1b4d").await?;
```

```php PHP theme={"system"}
$run = $client->dubs->requests->create('job_3f9a2c7e1b4d', [
    'text' => 'Is line 3 natural? If not, make it sound calmer.',
    'autonomy' => 'ask', // nothing changes until you answer
]);
if ($run['status'] === 'needs_input') {
    $run = $client->runs->answer($run['id'], ['choice' => 'apply']); // or 'decline'
}
$lines = $client->dubs->lines->list('job_3f9a2c7e1b4d')['lines'];
```

## What they handle

* **Uploads in parts.** Parts go straight to storage in parallel. Expired links are signed again and failed parts are retried.
* **Retries.** Network failures, `5xx` answers and per-minute rate limits are retried twice with backoff, honouring `Retry-After`.
* **Requests that change things.** Asking for a change, answering a run and editing lines are never retried after a network failure, so a change is never made twice.
* **Repeated requests.** Creating uploads and dubs always sends an [`Idempotency-Key`](https://docs.reedapt.com/idempotency), so a retry never makes a second dub. Pass your own to stay safe across restarts.
* **Errors.** Each failed request raises an error with the HTTP status, the stable [`code`](https://docs.reedapt.com/errors) and the `request_id` to quote to us.
* **Paging.** `listAll` (Node.js), `list_all` (Python and Rust), `Dubs.ListAll` (Go) and `listAll` (PHP) go through every dub.

The source and full reference are in each library's README: [Node.js](https://github.com/Reedapt/reedapt-node), [Python](https://github.com/Reedapt/reedapt-python), [Go](https://github.com/Reedapt/reedapt-go), [Rust](https://github.com/Reedapt/reedapt-rust) and [PHP](https://github.com/Reedapt/reedapt-php).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.