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

# TypeScript SDK

> Use Galileo from Node.js and TypeScript.

The Node.js SDK provides typed resources for evaluations, videos, and account data. It supports ESM and CommonJS on Node.js 20 and later.

<Info>
  Current preview: `0.1.0-rc.4`. Install the `next` tag to use this build.
</Info>

```bash theme={null}
npm install @physionlabs/galileo@next
```

```ts theme={null}
import Galileo from "@physionlabs/galileo";

const galileo = new Galileo({
  apiKey: process.env.GALILEO_API_KEY,
});

const evaluation = await galileo.evaluations.createAndWait({
  prompt: "A paper boat floats down a narrow stream.",
  video: { url: "https://example.com/boat.mp4" },
});
```

Check the terminal status before reading the result:

```ts theme={null}
if (evaluation.status === "failed") {
  console.error(evaluation.error?.message);
} else {
  for (const finding of evaluation.result?.glitches ?? []) {
    console.log(finding.type, finding.description);
  }
}
```

## Resources

| Resource      | Methods                                                                                         |
| ------------- | ----------------------------------------------------------------------------------------------- |
| `evaluations` | `create`, `createAndWait`, `retrieve`, `list`, `iterate`, `retry`, `delete`, `waitUntilSettled` |
| `videos`      | `upload`, `retrieve`, `waitUntilReady`                                                          |
| `account`     | `retrieve`, `models`, `quota`, `credits`, `status`                                              |

## Configuration

```ts theme={null}
const galileo = new Galileo({
  apiKey: process.env.GALILEO_API_KEY,
  timeoutMs: 60_000,
  maxRetries: 2,
  maxConcurrency: 4,
});
```

| Option                | Default                      | Purpose                                            |
| --------------------- | ---------------------------- | -------------------------------------------------- |
| `apiKey`              | `GALILEO_API_KEY`            | Authenticate requests.                             |
| `baseURL`             | `https://api.physionlabs.ai` | Select the API host.                               |
| `uploadBaseURL`       | `baseURL`                    | Resolve relative upload paths.                     |
| `timeoutMs`           | `60000`                      | Limit one request attempt.                         |
| `maxRetries`          | `2`                          | Retry safe requests after transient failures.      |
| `rateLimitBudgetMs`   | `60000`                      | Limit total time spent waiting on `429` responses. |
| `maxRateLimitRetries` | `20`                         | Limit repeated `429` responses.                    |
| `maxConcurrency`      | `4`                          | Limit requests in flight.                          |

Evaluation creation is sent once because a repeated submission can create a second evaluation. Rate-limit responses use their own time and attempt limits.

## Errors

Catch `GalileoError` for any SDK failure. API failures inherit from `APIError` and include `InvalidRequestError`, `AuthenticationError`, `NotFoundError`, `InsufficientCreditsError`, `RateLimitError`, and `ServerError`. Transport and polling failures use `ConnectionError` and `PollTimeoutError`.

[View the source on GitHub](https://github.com/Physion-Labs/galileo-node).
