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

# TypeScript client

> Use @reviseio/api for REST calls and document workflows.

`@reviseio/api` is a public npm package for Node.js 22+ and compatible runtimes. It has no runtime npm dependencies. Use it on your server; `fromPath` and `save` require Node filesystem APIs.

```bash theme={null}
npm install @reviseio/api
```

The resource methods mirror the REST API: `files`, `prompts`, `conversions`, `artifacts`, `account`, `models`, `usage`, and `webhooks`. Their JSON bodies use the same snake\_case fields shown in the REST reference. Each endpoint page includes a corresponding TypeScript example.

## Sources and results

`edit(source, prompt, options)` and `convert(source, format, options)` handle input resolution, upload, submission, and polling. Both return another `Source`, so results can become inputs without managing intermediate transfers.

```ts theme={null}
import { ReviseClient, Source } from "@reviseio/api";

const revise = new ReviseClient({ apiKey: process.env.REVISE_API_KEY! });
const edited = await revise.edit(
  Source.fromUrl("https://example.com/contract.docx"),
  "Change the payment term to 30 days.",
);
const pdf = await revise.convert(edited, "pdf");
const bytes = await pdf.bytes({ signal: AbortSignal.timeout(60_000) });
```

| Factory                                            | Input                                                                                |
| -------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `Source.fromBytes(bytes, { filename })`            | Uint8Array, Buffer, or ArrayBuffer                                                   |
| `Source.fromUrl(url, options?)`                    | HTTP(S), including signed URLs; separate `headers`/`fetch` for source authentication |
| `Source.fromPath(path, options?)`                  | Lazy local file                                                                      |
| `Source.fromBlob(blob, options?)`                  | Blob or native File; a File supplies its name                                        |
| `Source.fromStream(streamOrFactory, { filename })` | Binary Web stream, Node Readable, or async iterable of Uint8Array                    |
| `Source.fromResponse(response, options?)`          | Existing fetch Response                                                              |
| `Source.fromText(text, options?)`                  | UTF-8; defaults to `document.txt`                                                    |
| `Source.fromFileId(id, options?)`                  | Existing upload reference; no original-byte download                                 |
| `Source.fromArtifact(metadata, { client }?)`       | Existing output artifact; byte reads need a client                                   |

All factories accept filename, contentType, maxBytes, and upload lifetime options. A filename is required for upload: URLs/Responses infer it from Content-Disposition or the URL path, and unnamed Blobs need one supplied. Redirects are disabled. Applications accepting user-supplied URLs must enforce their own network access policy.

`bytes()` returns an independent byte copy; `blob()` returns an immutable Blob; `stream()` returns a fresh Web stream after buffering and verification; `save(path)` writes to an explicit local path. Standalone reads default to 64 MiB and accept `{ signal, maxBytes }`. Upload resolution caps at 18 MiB. The byte limit is not a process-memory ceiling.

Successful reads are cached snapshots. A failed one-shot stream/Response cannot restart. Its active reader owns the signal and cap, so an abort or size failure also affects waiting readers. Use a stream factory for retryable input; an independently aborted waiter cannot cancel another active reader.

`source.result` and `source.artifact` are defensive copies. `variant("tracked_changes")` selects another output from the same prompt; edits return the clean artifact by default. `getResponseMetadata` works on original low-level JSON results, not copied `source.result` receipts.

## Configuration

```ts theme={null}
import { ReviseClient } from "@reviseio/api";

const revise = new ReviseClient({
  apiKey: process.env.REVISE_API_KEY!,
  baseUrl: "https://revise.io/api", // omit /v1
  timeoutMs: 1_000_000,
  pollIntervalMs: 1_000,
  maxRetries: 2,
  maxRetryDelayMs: 60_000,
});
```

High-level options use `outputEncryption`, `responseOptions` (edit only), `trackedChanges` (edit only), `inference`, `limits`, `metadata`, and `retention`. Direct REST-shaped methods retain wire names such as `output_encryption`.

See [job lifecycle](/revise-api/jobs) and [error recovery](/revise-api/errors) for deadlines and retry behavior. A returned Source downloads lazily with its own signal. Aborting locally never cancels a server job automatically.
