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

# API Integration

> Siray API is designed to provide a consistent interface across multiple platforms, simplifying development.

### 1. Authentication

All API requests require an authentication token. Please ensure you have your `SIRAY_API_TOKEN` set as an environment variable or passed directly to the client library.

* **Token:** `SIRAY_API_TOKEN`
* **Security:** Pass the token via an environment variable to prevent hardcoding secrets in your source code.

<Tip>
  Check [api keys](https://console.siray.ai/keys) to get your key.

  API Port: [https://api.siray.ai/](https://api.siray.ai/)
</Tip>

### 2. Unified API Overview

The core of the Siray platform is the "Unified API," which allows you to interact with various models using a consistent `run()` method.

The key components of an API call are:

1. **Model Identifier:** E.g., `"black-forest-labs/flux-kontext-i2i-pro"`.
2. **Input Payload:** A dictionary/object containing parameters like `prompt` and the input `image`.

### 3. Integration Examples

**Node.js**

```javascript theme={null}
// install using npm
// npm install siray

import { Siray } from 'siray';

const client = new Siray({
  apiKey: 'your-api-key-here',
});

// Optional: turn a local file into a base64 data URL you can pass as the `image` field
const initImage = await client.loadFromLocal('path/to/image.jpg');
const status = await client.image.run(
  {
    model: 'black-forest-labs/flux-kontext-i2i-pro',
    prompt: 'A cinematic portrait photo of a cyberpunk samurai',
    image: initImage,
  },
  {
    pollIntervalMs: 3000,
    timeoutMs: 3 * 60 * 1000,
  }
);

if (status.isCompleted()) {
  console.log('Generated image:', status.result);
} else if (status.isFailed()) {
  console.log('Error:', status.fail_reason);
} else {
  console.log('Final status:', status.status);
}
```

<Tip>
  Note: Always use the latest model identifiers from the Siray model catalog.
</Tip>
