Skip to main content

Workflows

The Hautech API supports workflows that makes process for preparing an image or processing it simpler. So developers can get ready results just after one call.

Pricing

When using workflows, please note that the price will be calculated based on all operations inside the workflow pipeline. Each workflow consists of multiple operations, and the total cost is the sum of all individual operation costs.

Run Workflow

To run a workflow, you need to call the workflow endpoint with the workflow ID and input parameters:

  • Run Workflow:
    Call the /v1/workflows/run/{workflowId} endpoint with the required input parameters. The API will create a new pipeline with a status of "pending".

    Example Request:

    curl -X POST "https://api.hautech.ai/v1/workflows/run/{workflowId}" \
    -H "Authorization: Bearer <your_jwt_access_token>" \
    -H "Content-Type: application/json" \
    -d '{"input": {"parameter1": "value1", "parameter2": "value2"}}'
  • Retrieve the Result:
    Once the workflow has completed, retrieve the result by calling /v1/pipelines/{pipelineId}.

    Example Request:

    curl -X GET "https://api.hautech.ai/v1/pipelines/{pipelineId}" \
    -H "Authorization: Bearer <your_jwt_access_token>"

Upload Image

For information on how to upload images, please refer to the Upload Image section in Main Workflows.

Available Workflows

The Hautech API currently provides the following workflows:

Naomi Pipeline (ID: b8bfacd4-e6e8-401b-91ce-acc01f1f2b75)

This workflow runs the Naomi AI model to generate an image based on a prepared pose and clothing image. It transforms your clothing onto a model in the specified pose.

Workflow Parameters

The workflow accepts the following parameters:

  • poseId: ID of the prepared pose
  • imageId: ID of the prepared clothing image
  • label: (Optional) Description of the clothing item (e.g., "a cardigan cloth")
  • additionalPrompt: (Optional) Additional context for the image generation
  • enhancePrompt: (Optional) Boolean flag to enable automatic prompt enhancement
  • seed: (Optional) Random seed for reproducible results

Step-by-Step Guide

  1. Prepare Images:
    Ensure you have already prepared your pose and clothing images using the respective preparation workflows.

  2. Run the Workflow:
    Call the workflow endpoint with your parameters to start the image generation process.

  3. Wait for Completion:
    The workflow runs asynchronously. Poll the pipeline status until it completes.

  4. Retrieve Results:
    Once completed, retrieve the generated image from the pipeline output.

Example

import axios from 'axios';

const token = 'YOUR_TOKEN';
const baseUrl = 'https://api.hautech.ai';

// Helper function to wait for pipeline completion
const waitForPipeline = async (pipelineId: string) => {
while (true) {
const res = await axios.get(`${baseUrl}/v1/pipelines/${pipelineId}`, {
headers: { Authorization: `Bearer ${token}` },
});

if (res.data.status !== 'pending') return res.data;
await new Promise((r) => setTimeout(r, 1000));
}
};

// Run the Naomi Pipeline
(async () => {
const poseId = 'YOUR_PREPARED_POSE_ID';
const imageId = 'YOUR_PREPARED_IMAGE_ID';

const run = await axios.post(
`${baseUrl}/v1/workflows/run/b8bfacd4-e6e8-401b-91ce-acc01f1f2b75`,
{
input: {
poseId,
imageId,
label: 'a cardigan cloth',
additionalPrompt: 'Model in urban setting with natural lighting',
enhancePrompt: true,
seed: 123456,
},
},
{
headers: { Authorization: `Bearer ${token}` },
},
);

const result = await waitForPipeline(run.data.pipelineId);
console.log('✅ Final output:', result.output);
})();

Prepare Image Pipeline (ID: 31789314-f1c5-4c9f-9c41-0b6708015788)

This workflow prepares a clothing image for use with our AI models. It processes the image to extract and optimize the clothing item.

Workflow Parameters

The workflow accepts the following parameters:

  • imageId: ID of the uploaded clothing image
  • label: (Optional) Description of the clothing item
  • isHuman: (Optional) Boolean flag indicating if the subject is human

Step-by-Step Guide

  1. Upload Image:
    Upload your clothing image using the image upload process described earlier.

  2. Run the Workflow:
    Call the workflow endpoint with your parameters to start the image preparation process.

  3. Wait for Completion:
    The workflow runs asynchronously. Poll the pipeline status until it completes.

  4. Retrieve Results:
    Once completed, retrieve the prepared image ID from the pipeline output for use in the Naomi Pipeline.

Example

import axios from 'axios';
import fs from 'fs';
import FormData from 'form-data';

const token = 'YOUR_TOKEN';
const baseUrl = 'https://api.hautech.ai';

// Helper function to upload an image
// For the implementation details, see the Upload Image section in Main Workflows: main-workflows.md#upload-image
const uploadImage = async (path: string) => {
// Implementation omitted for brevity - refer to main-workflows.md#upload-image
// This function handles the three-step process: initialize, upload, and finalize
return "YOUR_IMAGE_ID"; // In actual code, this would return the image ID from the API
};

// Helper function to wait for pipeline completion
const waitForPipeline = async (pipelineId: string) => {
while (true) {
const res = await axios.get(`${baseUrl}/v1/pipelines/${pipelineId}`, {
headers: { Authorization: `Bearer ${token}` },
});

if (res.data.status !== 'pending') return res.data;
await new Promise((r) => setTimeout(r, 1000));
}
};

// Run the Prepare Image Pipeline
(async () => {
// Upload the clothing image
const imagePath = './src/clothing.png';
const imageId = await uploadImage(imagePath);

// Run the workflow
const run = await axios.post(
`${baseUrl}/v1/workflows/run/31789314-f1c5-4c9f-9c41-0b6708015788`,
{
input: {
imageId,
label: 'a cardigan cloth',
isHuman: true,
},
},
{
headers: { Authorization: `Bearer ${token}` },
},
);

// Wait for the pipeline to complete
const result = await waitForPipeline(run.data.pipelineId);
console.log('✅ Prepared image ID:', result.output.preparedImageId);
})();

Prepare Pose Pipeline (ID: b4aa5223-8e67-4e62-9b70-1672d1bc43c9)

This workflow prepares a pose image for use with our AI models. It processes the image to extract and optimize the pose.

Workflow Parameters

The workflow accepts the following parameters:

  • poseImageId: ID of the uploaded pose image
  • aspectRatio: Desired aspect ratio of the output image (e.g., "7:10")

Step-by-Step Guide

  1. Upload Image:
    Upload your pose image using the image upload process described earlier.

  2. Run the Workflow:
    Call the workflow endpoint with your parameters to start the pose preparation process.

  3. Wait for Completion:
    The workflow runs asynchronously. Poll the pipeline status until it completes.

  4. Retrieve Results:
    Once completed, retrieve the prepared pose ID from the pipeline output for use in the Naomi Pipeline.

Example

import axios from 'axios';
import fs from 'fs';
import FormData from 'form-data';

const token = 'YOUR_TOKEN';
const baseUrl = 'https://api.hautech.ai';

// Helper function to upload an image
// For the implementation details, see the Upload Image section in Main Workflows: main-workflows.md#upload-image
const uploadImage = async (path: string) => {
// Implementation omitted for brevity - refer to main-workflows.md#upload-image
// This function handles the three-step process: initialize, upload, and finalize
return "YOUR_IMAGE_ID"; // In actual code, this would return the image ID from the API
};

// Helper function to wait for pipeline completion
const waitForPipeline = async (pipelineId: string) => {
while (true) {
const res = await axios.get(`${baseUrl}/v1/pipelines/${pipelineId}`, {
headers: { Authorization: `Bearer ${token}` },
});

if (res.data.status !== 'pending') return res.data;
await new Promise((r) => setTimeout(r, 1000));
}
};

// Run the Prepare Pose Pipeline
(async () => {
// Upload the pose image
const posePath = './src/pose.png';
const poseImageId = await uploadImage(posePath);

// Run the workflow
const run = await axios.post(
`${baseUrl}/v1/workflows/run/b4aa5223-8e67-4e62-9b70-1672d1bc43c9`,
{
input: {
poseImageId,
aspectRatio: '7:10',
},
},
{
headers: { Authorization: `Bearer ${token}` },
},
);

// Wait for the pipeline to complete
const result = await waitForPipeline(run.data.pipelineId);
console.log('✅ Prepared pose ID:', result.output.poseId);
})();

Full Naomi workflow (ID: dc1bd611-effc-443c-978a-88593553588d)

This workflow creates a pose from an pose image, detects and prepares clothing from clothing image, and then runs the full Naomi pipeline to generate an AI model based on your parameters. It combines multiple steps into a single process, allowing you to transform your clothing images with custom poses efficiently.

Workflow Parameters

The workflow accepts the following parameters, which are a combination of parameters from the Naomi Pipeline, Prepare Pose Pipeline, and Prepare Image Pipeline:

  • poseImageId: ID of the uploaded pose image
  • aspectRatio: Desired aspect ratio of the output image, e.g., "7:10"
  • imageId: ID of the uploaded clothing image
  • label: (Optional) Description of the clothing item, e.g., "a cardigan cloth"
  • isHuman: (Optional) Boolean flag indicating if the subject is human
  • additionalPrompt: (Optional) Additional context for the image generation, e.g., background setting, mood
  • enhancePrompt: (Optional) Boolean flag to enable automatic prompt enhancement
  • seed: (Optional) Random seed for reproducible results

Step-by-Step Guide

  1. Upload Images:
    Upload both your clothing image and pose image using the image upload process described earlier.

  2. Run the Workflow:
    Call the workflow endpoint with your parameters to start the image generation process.

  3. Wait for Completion:
    The workflow runs asynchronously. Poll the pipeline status until it completes.

  4. Retrieve Results:
    Once completed, retrieve the generated image from the pipeline output.

Complete Example

Here's a complete example using TypeScript/JavaScript:

import axios from 'axios';
import fs from 'fs';
import FormData from 'form-data';

const token = 'YOUR_TOKEN';
const baseUrl = 'https://api.hautech.ai';

const additionalPrompt =
'The main image should feature the model standing elegantly in a modern urban street setting. The composition should highlight the jeans in a natural pose with confidence.';
const label = 'a cardigan cloth';
const imagePath = './src/image-big.png';
const poseImagePath = './src/pose.png';
const size = '7:10';
const seed = Math.floor(Math.random() * 1e6);

// Helper function to upload an image
// For the implementation details, see the Upload Image section in Main Workflows: main-workflows.md#upload-image
const uploadImage = async (path: string) => {
// Implementation omitted for brevity - refer to main-workflows.md#upload-image
// This function handles the three-step process: initialize, upload, and finalize
return "YOUR_IMAGE_ID"; // In actual code, this would return the image ID from the API
};

// Helper function to wait for pipeline completion
const waitForPipeline = async (pipelineId: string) => {
while (true) {
const res = await axios.get(`${baseUrl}/v1/pipelines/${pipelineId}`, {
headers: { Authorization: `Bearer ${token}` },
});

if (res.data.status !== 'pending') return res.data;
await new Promise((r) => setTimeout(r, 1000));
}
};

// Main execution
(async () => {
// Upload both images
const poseImageId = await uploadImage(poseImagePath);
const imageId = await uploadImage(imagePath);

// Run the workflow
const run = await axios.post(
`${baseUrl}/v1/workflows/run/dc1bd611-effc-443c-978a-88593553588d`,
{
input: {
poseImageId,
imageId,
label,
additionalPrompt,
seed,
aspectRatio: size,
enhancePrompt: true,
isHuman: true,
},
},
{
headers: { Authorization: `Bearer ${token}` },
},
);

// Wait for the pipeline to complete
const result = await waitForPipeline(run.data.pipelineId);
console.log('✅ Final output:', result.output);
})();