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

# JS/TS SDK Overview

> Understand what the official Mynth SDK provides and when to use it.

The official SDK package is [`@mynthio/sdk`](https://www.npmjs.com/package/@mynthio/sdk).

It is the easiest way to integrate Mynth from JavaScript or TypeScript applications.

## What the SDK gives you

* a typed `Mynth` client
* sync and async generation, rating, and alt text flows
* `ImageGenerationResult`, `ImageRateResult`, `ImageAltResult`, and `TaskAsync` abstractions
* built-in polling for async tasks
* exported runtime model metadata through `AVAILABLE_MODELS`
* a Convex webhook helper in `@mynthio/sdk/convex`

## Installation

<CodeGroup>
  ```bash Bun theme={"theme":"kanagawa-dragon"}
  bun add @mynthio/sdk
  ```

  ```bash PNPM theme={"theme":"kanagawa-dragon"}
  pnpm add @mynthio/sdk
  ```

  ```bash NPM theme={"theme":"kanagawa-dragon"}
  npm install @mynthio/sdk
  ```
</CodeGroup>

## Typical server-side use

`generate()` runs synchronously and resolves once the task is complete, returning an `ImageGenerationResult`:

```ts theme={"theme":"kanagawa-dragon"}
import Mynth from "@mynthio/sdk";

const mynth = new Mynth();

const result = await mynth.image.generate({
  prompt: "A premium e-commerce hero image for a leather backpack",
  model: "google/gemini-3.1-flash-image",
});

console.log(result.urls);
```

## Typical async use

`generateAsync()` starts generation and returns a `TaskAsync` immediately, so your server can respond fast and poll or wait later:

```ts theme={"theme":"kanagawa-dragon"}
const task = await mynth.image.generateAsync({
  prompt: "A premium e-commerce hero image for a leather backpack",
  model: "google/gemini-3.1-flash-image",
});

return {
  id: task.id,
  access: task.access,
};
```

## When to use the SDK

Prefer the SDK when you want:

* strong TypeScript support
* less boilerplate for polling
* consistent task handling
* first-class helpers for `mynth.image.generate`, `mynth.image.rate`, and `mynth.image.alt`

Use the raw API when you need another language or total transport-level control.
