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

# Avvio rapido

> Crea un progetto karaoke, attendi che finisca, esportalo e scarica il risultato

Questa guida illustra il percorso più veloce da un file audio grezzo a un video karaoke renderizzato usando `@youka/sdk`.

## Prima di iniziare

* Node.js 20 o versioni successive
* Una chiave API Youka in `YOUKA_API_KEY` (creane una su [online.youka.io/account](https://online.youka.io/account) nella sezione **API keys**)
* Un file audio locale (`./song.mp3`) oppure un URL remoto

## Installazione

```bash theme={null}
npm install @youka/sdk
```

## Crea, attendi, esporta

```ts theme={null}
import { YoukaClient, YoukaRequestError, YoukaTaskError } from "@youka/sdk";

const client = new YoukaClient({
  apiKey: process.env.YOUKA_API_KEY!,
});

async function main() {
  // 1. Crea un progetto da un file locale
  const projectOperation = await client.projects.create({
    source: { type: "path", path: "./song.mp3" },
    lyricsSource: { type: "transcribe" },
  });

  // 2. Attendi che la generazione degli stem e la sincronizzazione dei testi terminino
  const { project } = await client.projects.wait(projectOperation);
  console.log("Project ready:", project.id, project.title);

  // 3. Avvia un'esportazione
  const exportOperation = await client.exports.create(project.id, {
    resolution: "1080p",
    quality: "high",
  });

  // 4. Attendi che l'esportazione termini
  const finishedExport = await client.exports.wait(exportOperation);
  await client.exports.download(finishedExport, {
    output: "./exports",
  });
  console.log("Export ready:", finishedExport.url);
}

main().catch((error) => {
  if (error instanceof YoukaRequestError) {
    console.error("Request failed:", error.code, error.status, error.message);
    process.exit(1);
  }
  if (error instanceof YoukaTaskError) {
    console.error("Task failed:", error.code, error.status, error.message);
    process.exit(1);
  }
  throw error;
});
```

<Note>
  `client.projects.create()` gestisce i caricamenti per le sorgenti `path`, `bytes` e `url`.
  Per un controllo del caricamento a più basso livello, usa `client.uploads.*`.
</Note>

## Tre tipi di sorgente

<Tabs>
  <Tab title="File locale">
    ```ts theme={null}
    const operation = await client.projects.create({
      source: { type: "path", path: "./song.mp3" },
    });
    ```
  </Tab>

  <Tab title="Byte in memoria">
    ```ts theme={null}
    const fileBuffer = new Uint8Array([/* audio bytes */]);

    const operation = await client.projects.create({
      source: {
        type: "bytes",
        data: fileBuffer,
        filename: "song.mp3",
      },
    });
    ```
  </Tab>

  <Tab title="URL remoto">
    ```ts theme={null}
    const operation = await client.projects.create({
      source: {
        type: "url",
        url: "https://example.com/song.mp4",
      },
    });
    ```
  </Tab>
</Tabs>

## Cosa fare dopo

* [Projects](/it/sdk/projects) — API completa dei progetti
* [Exports](/it/sdk/exports) — render locale e `client.exports.prepareLocal`
* [Errors](/it/sdk/errors) — gestire `YoukaRequestError` e `YoukaTaskError`
* [AI agents](/it/agents) — pattern consigliati per polling e retry
