# How to deploy FLUX.1

In this guide, we will create a simple **FLUX image generation workflow** using **Ikomia API** and deploy it to the cloud with **Ikomia SCALE** to integrate it into your application.

![An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.](/assets/images/generated-b550ad149a7bbb6cc4f38861317bb1c0.jpg)

FLUX generated image

💫 **This tutorial is also available as a [Jupyter notebook](https://github.com/Ikomia-dev/notebooks/blob/main/examples/HOWTO_deploy_Ikomia_SCALE_FLUX1.ipynb)**.

<br />

## 1. Installation[​](#1-installation "Direct link to 1. Installation")

First, ensure that you have installed the Ikomia Python API and CLI:

```
pip install ikomia ikomia-cli
```

<br />

## 2. Create a workflow with Ikomia API[​](#2-create-a-workflow-with-ikomia-api "Direct link to 2. Create a workflow with Ikomia API")

To get started, let's create a workflow using **[infer\_flux\_1](https://app.ikomia.ai/hub/algorithms/infer_flux_1/)** algorithm from Ikomia HUB:

```
from ikomia.dataprocess.workflow import Workflow

workflow = Workflow("FLUX Image Generation")

flux = workflow.add_task(name="infer_flux_1")
flux.set_parameters({
    "model_name": "flux1-schnell",
})

# Save workflow as a JSON file
workflow.save("flux_workflow.json")
```

**Running your workflow locally**

Ikomia API is **open-source** and also highly suitable for **self-hosted solutions** if you prefer to run workflows locally.

Here's how you can modify the previous script to execute the workflow locally:

```
from ikomia.dataprocess.workflow import Workflow
from ikomia.utils.displayIO import display

workflow = Workflow("FLUX Image Generation")
flux = workflow.add_task(name="infer_flux_1")

# Configure the algorithm
flux.set_parameters({
    "model_name": "flux1-schnell",
    "prompt": "An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.",
})

# Run the workflow
workflow.run()

# Display the output image
display(flux.get_output(0).get_image())
```

warning

Please note that FLUX is a large model that requires at least 12GB of VRAM.

To create more advanced workflows, **check out the [Ikomia API documentation](https://ikomia-dev.github.io/python-api-documentation/index.html)**.

<br />

## 3. Deploy your workflow to Ikomia SCALE[​](#3-deploy-your-workflow-to-ikomia-scale "Direct link to 3. Deploy your workflow to Ikomia SCALE")

If you haven't already, **[create an Ikomia account](https://app.ikomia.ai/signup)**.

### Create an API token[​](#create-an-api-token "Direct link to Create an API token")

To authorize the CLI and your code to access your Ikomia SCALE account, **[create an API token](https://app.ikomia.ai/settings/tokens)** and set it as an environment variable:

```
export IKOMIA_TOKEN=PASTE_YOUR_TOKEN_HERE
```

### Push your workflow[​](#push-your-workflow "Direct link to Push your workflow")

Create a project and push your workflow to Ikomia SCALE:

```
ikcli project add YOUR_USERNAME FluxImageGeneration
ikcli project push FluxImageGeneration flux_workflow.json
```

You can now view and manage your project and workflow on the **[Ikomia SCALE dashboard](https://app.ikomia.ai/)**.

### Deploy[​](#deploy "Direct link to Deploy")

On the workflow page, select a **[deployment option](https://docs.ikomia.ai/scale/deployment/available-infrastructures.md)** and click on the **Deploy workflow** button.

![The deployment creation interface, with various deployment options](/assets/images/deployment_options-a15feaa61e69d801e9b3f90bcf2f1892.png)

Deploying our FLUX image generation workflow on a cloud GPU instance

Once your deployment is ready, you can **test it via our [online interface](https://docs.ikomia.ai/scale/deployment/test-interface.md)**.

<br />

## 4. Integrate your deployment in your application[​](#4-integrate-your-deployment-in-your-application "Direct link to 4. Integrate your deployment in your application")

We provide **[Python](https://docs.ikomia.ai/scale/integration/python/getting-started.md)** and **[JavaScript](https://docs.ikomia.ai/scale/integration/javascript/getting-started.md)** client libraries to help you integrate your deployment into your application.

info

We also provide a **[REST API](https://docs.ikomia.ai/scale/integration/rest.md)** for integration on any language/platform.

* Python
* JavaScript/TypeScript

```
pip install ikomia-client
```

```
from ikclient.core.client import Client
from ikclient.core.io import ImageIO

# Initialize the client with your deployment URL
with Client(
    url="https://your.flux.deployment.url",
    token="your-api-token"  # Or set IKOMIA_TOKEN environment variable
) as flux_deployment:
    # Generate an image with FLUX
    results = flux_deployment.run(
        parameters={
            "prompt": "An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.",
        }
    )

    # Get the generated image
    output_image = results.get_output(0, assert_type=ImageIO)

    # Convert to PIL image and save
    pil_image = output_image.to_pil()
    pil_image.save("generated_image.png")
```

```
npm install @ikomia/ikclient
```

```
import {Buffer} from 'buffer';
import fs from 'fs';

import {Client, ImageIO} from '@ikomia/ikclient';

// Initialize the client with your deployment URL
const fluxDeployment = new Client({
  url: 'https://your.flux.deployment.url',
  token: 'your-api-token', // Or set IKOMIA_TOKEN environment variable
});

// Generate an image with FLUX
const results = await fluxDeployment.run({
  parameters: {
    prompt:
      "An adventurer in the jungle with a tshirt that says 'Deploy FLUX.1'.",
  },
});

// Get the generated image
const outputImage = results.getOutput(0, ImageIO);

// Convert to buffer and save
const imageBuffer = outputImage.toArrayBuffer();
fs.writeFileSync('generated_image.png', Buffer.from(imageBuffer));
```

Replace `https://your.flux.deployment.url` with the actual URL of your FLUX deployment.
