# Images
(*images*)

## Overview

### Available Operations

* [generateFromPrompt](#generatefromprompt) - Generate a new image from a text prompt
* [generateFromImage](#generatefromimage) - Generate a new image from an image
* [cannyEdgeDetection](#cannyedgedetection) - Pre-process the image with canny edge detection
* [generateFromControlNet](#generatefromcontrolnet) - Generate a new image using ControlNet with provided image as a guidance
* [generateQRCode](#generateqrcode) - Generate a QR code

## generateFromPrompt

Generate a new image from a text prompt

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.images.generateFromPrompt({
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyText2imageGen: {
      prompt: "A futuristic cityscape",
      negativePrompt: "cloudy day",
      height: 1024,
      width: 1024,
      cfgScale: 7,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      steps: 30,
      safetyCheck: false,
    },
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { imagesGenerateFromPrompt } from "@simplesagar/fireworksai/funcs/imagesGenerateFromPrompt.js";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await imagesGenerateFromPrompt(fireworksAI, {
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyText2imageGen: {
      prompt: "A futuristic cityscape",
      negativePrompt: "cloudy day",
      height: 1024,
      width: 1024,
      cfgScale: 7,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      steps: 30,
      safetyCheck: false,
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.GenerateImageFromPromptRequest](../../models/generateimagefrompromptrequest.md)                                                                                        | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.GenerateImageFromPromptResponse](../../models/generateimagefrompromptresponse.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.ServiceUnavailable  | 503                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |

## generateFromImage

Generate a new image from an image

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";
import { openAsBlob } from "node:fs";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.images.generateFromImage({
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyImage2imageGen: {
      initImage: await openAsBlob("example.file"),
      cfgScale: 7,
      height: 1024,
      imageStrength: 0.75,
      initImageMode: "IMAGE_STRENGTH",
      negativePrompt: "cloudy day",
      prompt: "A futuristic cityscape",
      safetyCheck: false,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      stepScheduleEnd: 1,
      stepScheduleStart: 0,
      steps: 30,
      width: 1024,
    },
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { imagesGenerateFromImage } from "@simplesagar/fireworksai/funcs/imagesGenerateFromImage.js";
import { openAsBlob } from "node:fs";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await imagesGenerateFromImage(fireworksAI, {
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyImage2imageGen: {
      initImage: await openAsBlob("example.file"),
      cfgScale: 7,
      height: 1024,
      imageStrength: 0.75,
      initImageMode: "IMAGE_STRENGTH",
      negativePrompt: "cloudy day",
      prompt: "A futuristic cityscape",
      safetyCheck: false,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      stepScheduleEnd: 1,
      stepScheduleStart: 0,
      steps: 30,
      width: 1024,
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.GenerateImageFromImageRequest](../../models/generateimagefromimagerequest.md)                                                                                          | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.GenerateImageFromImageResponse](../../models/generateimagefromimageresponse.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.ServiceUnavailable  | 503                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |

## cannyEdgeDetection

Pre-process the image with canny edge detection

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";
import { openAsBlob } from "node:fs";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.images.cannyEdgeDetection({
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    requestBody: {
      image: await openAsBlob("example.file"),
      maxVal: 100,
      minVal: 100,
    },
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { imagesCannyEdgeDetection } from "@simplesagar/fireworksai/funcs/imagesCannyEdgeDetection.js";
import { openAsBlob } from "node:fs";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await imagesCannyEdgeDetection(fireworksAI, {
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    requestBody: {
      image: await openAsBlob("example.file"),
      maxVal: 100,
      minVal: 100,
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.CannyEdgeDetectionRequest](../../models/cannyedgedetectionrequest.md)                                                                                                  | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.CannyEdgeDetectionResponse](../../models/cannyedgedetectionresponse.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.ServiceUnavailable  | 503                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |

## generateFromControlNet

Generate a new image using ControlNet with provided image as a guidance

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";
import { openAsBlob } from "node:fs";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.images.generateFromControlNet({
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyControlNetGen: {
      controlImage: await openAsBlob("example.file"),
      prompt: "make the image look like a painting",
      cfgScale: 7,
      conditioningScale: 0.5,
      controlNetName: "canny",
      height: 1024,
      negativePrompt: "cloudy day",
      safetyCheck: false,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      stepScheduleEnd: 1,
      stepScheduleStart: 0,
      steps: 30,
      width: 1024,
    },
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { imagesGenerateFromControlNet } from "@simplesagar/fireworksai/funcs/imagesGenerateFromControlNet.js";
import { openAsBlob } from "node:fs";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await imagesGenerateFromControlNet(fireworksAI, {
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    bodyControlNetGen: {
      controlImage: await openAsBlob("example.file"),
      prompt: "make the image look like a painting",
      cfgScale: 7,
      conditioningScale: 0.5,
      controlNetName: "canny",
      height: 1024,
      negativePrompt: "cloudy day",
      safetyCheck: false,
      sampler: "K_EULER",
      samples: 1,
      seed: 0,
      stepScheduleEnd: 1,
      stepScheduleStart: 0,
      steps: 30,
      width: 1024,
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.GenerateFromControlNetRequest](../../models/generatefromcontrolnetrequest.md)                                                                                          | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[ReadableStream<Uint8Array>](../../models/.md)\>**

### Errors

| Error Type                 | Status Code                | Content Type               |
| -------------------------- | -------------------------- | -------------------------- |
| models.BadRequest          | 400                        | application/json           |
| models.Unauthorized        | 401                        | application/json           |
| models.Forbidden           | 403                        | application/json           |
| models.NotFound            | 404                        | application/json           |
| models.TooManyRequests     | 429                        | application/json           |
| models.InternalServerError | 500                        | application/json           |
| models.SDKError            | 4XX, 5XX                   | \*/\*                      |

## generateQRCode

Generate a QR code

### Example Usage

```typescript
import { FireworksAI } from "@simplesagar/fireworksai";

const fireworksAI = new FireworksAI({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const result = await fireworksAI.images.generateQRCode({
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    requestBody: {
      prompt: "https://youtu.be/dQw4w9WgXcQ?si=VZUuOi3g_uiFLiSO",
      height: 800,
      width: 800,
      model: "stable-diffusion-xl-1024-v1-0",
    },
  });

  // Handle the result
  console.log(result);
}

run();
```

### Standalone function

The standalone function version of this method:

```typescript
import { FireworksAICore } from "@simplesagar/fireworksai/core.js";
import { imagesGenerateQRCode } from "@simplesagar/fireworksai/funcs/imagesGenerateQRCode.js";

// Use `FireworksAICore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fireworksAI = new FireworksAICore({
  apiKey: process.env["FIREWORKS_API_KEY"] ?? "",
});

async function run() {
  const res = await imagesGenerateQRCode(fireworksAI, {
    accountId: "fireworks",
    modelId: "stable-diffusion-xl-1024-v1-0",
    requestBody: {
      prompt: "https://youtu.be/dQw4w9WgXcQ?si=VZUuOi3g_uiFLiSO",
      height: 800,
      width: 800,
      model: "stable-diffusion-xl-1024-v1-0",
    },
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();
```

### Parameters

| Parameter                                                                                                                                                                      | Type                                                                                                                                                                           | Required                                                                                                                                                                       | Description                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request`                                                                                                                                                                      | [models.GenerateQRCodeRequest](../../models/generateqrcoderequest.md)                                                                                                          | :heavy_check_mark:                                                                                                                                                             | The request object to use for the request.                                                                                                                                     |
| `options`                                                                                                                                                                      | RequestOptions                                                                                                                                                                 | :heavy_minus_sign:                                                                                                                                                             | Used to set various options for making HTTP requests.                                                                                                                          |
| `options.fetchOptions`                                                                                                                                                         | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options)                                                                                        | :heavy_minus_sign:                                                                                                                                                             | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries`                                                                                                                                                              | [RetryConfig](../../lib/utils/retryconfig.md)                                                                                                                                  | :heavy_minus_sign:                                                                                                                                                             | Enables retrying HTTP requests under certain failure conditions.                                                                                                               |

### Response

**Promise\<[models.GenerateQRCodeResponse](../../models/generateqrcoderesponse.md)\>**

### Errors

| Error Type                | Status Code               | Content Type              |
| ------------------------- | ------------------------- | ------------------------- |
| models.ServiceUnavailable | 503                       | application/json          |
| models.SDKError           | 4XX, 5XX                  | \*/\*                     |