> ## 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.

# Quickstart

> Generate your first image with Mynth and understand the result you get back.

This quickstart gets you from zero to a completed image task using the official JavaScript and TypeScript SDK.

<Steps>
  <Step title="Create an API key">
    Create a key in the [Mynth dashboard](https://mynth.io/dashboard/keys).

    If you work with multiple environments, create separate keys and set a spending limit for each one.
  </Step>

  <Step title="Install the SDK">
    <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>
  </Step>

  <Step title="Set your environment variable">
    `bash export MYNTH_API_KEY=mak_your_key_here `
  </Step>

  <Step title="Generate an image">
    ```ts theme={"theme":"kanagawa-dragon"}
    import Mynth from "@mynthio/sdk";

    const mynth = new Mynth();

    const task = await mynth.image.generate({
      prompt: "Editorial product photo of a ceramic mug on a linen tablecloth",
      model: "google/gemini-3.1-flash-image",
    });

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

    By default, `generate()` waits for completion. The returned `task` is already a completed task object, so `task.urls` contains the successful image URLs immediately.
  </Step>

  <Step title="Return immediately with generateAsync">
    ```ts theme={"theme":"kanagawa-dragon"}
    const task = await mynth.image.generateAsync({
      prompt: "A floating garden at sunrise",
      model: "google/gemini-3.1-flash-image",
    });

    console.log(task.id);
    console.log(task.access.publicAccessToken);
    ```

    `generateAsync()` returns a `TaskAsync`. Use it when your server should start work now and your app will poll or wait later.
  </Step>
</Steps>

<Tip>
  Set `model` explicitly in production. `model: "auto"` is an early preview feature intended for
  experimentation.
</Tip>

## What to read next

<CardGroup cols={2}>
  <Card title="Async and Polling" icon="refresh" href="/guides/async-and-polling">
    Learn when to use sync, async, polling, and browser-safe access tokens.
  </Card>

  <Card title="Use Webhooks" icon="bell" href="/guides/use-webhooks">
    Send results to your backend automatically.
  </Card>

  <Card title="Request Reference" icon="brackets" href="/reference/image-generation-request">
    See every request field that Mynth accepts.
  </Card>

  <Card title="SDK Tasks" icon="clock-3" href="/sdk/js-ts/tasks">
    Understand `Task`, `TaskAsync`, and polling behavior in detail.
  </Card>
</CardGroup>
