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

# Getting started

> Install the SDK, authenticate, and run your first workflow

<Info>
  **Prerequisites** — Node.js 18.10.0 or higher, an API token from the Pixio dashboard, and a deployed workflow with a `deployment_id`.
</Info>

## 1. Install the SDK

```bash theme={null}
npm install @pixio/api-sdk
```

```bash theme={null}
yarn add @pixio/api-sdk
```

## 2. Store your key

Put the token in a `.env` file — never in source control.

```bash theme={null}
PIXIO_API_KEY=your-api-key-here
```

<Warning>
  Add `.env` to `.gitignore` before your first commit. A leaked token can run workflows on your account.
</Warning>

## 3. Create the client

```js theme={null}
const PixioAPI = require('@pixio/api-sdk');

const client = new PixioAPI(process.env.PIXIO_API_KEY);

client.getProjects().then((projects) => {
  console.log(projects);
});
```

If that returns your projects, your token works.

## 4. Run a workflow

Pass the `deployment_id` and whatever inputs your graph expects:

```js theme={null}
client
  .runWorkflow({
    deployment_id: 'your-deployment-id',
    inputs: {
      input_text: 'Example input',
      input_image: 'https://example.com/image.png',
    },
  })
  .then((response) => {
    console.log('Run ID:', response.run_id);
  });
```

The call returns as soon as the run is **queued**. It does not wait for the result.

## 5. Retrieve the output

Use the `run_id` to fetch the run:

```js theme={null}
client.getWorkflowOutput('your-run-id').then((output) => {
  console.log('Output:', output);
});
```

The response includes a `status`. Keep polling until it's `success`:

```js theme={null}
async function waitForRun(runId, { intervalMs = 2000, timeoutMs = 600000 } = {}) {
  const deadline = Date.now() + timeoutMs;

  while (Date.now() < deadline) {
    const run = await client.getWorkflowOutput(runId);

    if (run.status === 'success') return run;
    if (run.status === 'failed') throw new Error(`Run ${runId} failed`);

    await new Promise((resolve) => setTimeout(resolve, intervalMs));
  }

  throw new Error(`Run ${runId} timed out`);
}
```

<Warning>
  Wait for `success`, not merely for `running` to end. A run passes through `uploading` after execution finishes but before outputs are readable.
</Warning>

## Keeping the SDK current

```bash theme={null}
npm update @pixio/api-sdk
```

## Local development notes

If you're running a local server alongside the SDK and hit a port clash:

```js theme={null}
const PORT = process.env.PORT || 3333;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
```

An `EADDRINUSE` error means something else already holds that port — change the port or stop the other process.

## Next

<CardGroup cols={2}>
  <Card title="Workflows & deployments" icon="sitemap" href="/comfyui/workflows-and-deployments">
    How versions and deployments work, and how to ship changes safely.
  </Card>

  <Card title="Files & uploads" icon="upload" href="/comfyui/files-and-uploads">
    Feed images and other media into a run.
  </Card>

  <Card title="Running a workflow" icon="play" href="/comfyui/running-a-workflow">
    Inputs, polling, and output handling in depth.
  </Card>

  <Card title="Troubleshooting" icon="circle-question" href="/comfyui/troubleshooting">
    Token errors, failed runs, and stuck jobs.
  </Card>
</CardGroup>
