Skip to main content
The Process API enables you to transform existing images with style transfer and edits. Perfect for building content creation tools, media processing pipelines, batch transformations, and creative applications.
For video processing (video editing, motion control), use the Queue API which provides asynchronous job-based processing.

Image Editing

Transform and restyle existing images:
import Foundation
import DecartSDK

let imageData = try Data(contentsOf: imageURL)
let input = try ImageToImageInput(
    prompt: "Oil painting style with impressionist brushstrokes",
    data: .image(data: imageData),
    enhancePrompt: true,
    seed: 123
)

let processClient = try client.createProcessClient(
    model: .lucy_pro_i2i,
    input: input
)

let result = try await processClient.process()
// result is Data containing the transformed image
ImageToImageInput parameters:
  • prompt (required) - Text description of the style transformation
  • data (required) - Input image as FileInput
  • seed (optional) - Random seed for reproducible results
  • resolution (optional) - Output resolution (.res720p or .res480p)
  • enhancePrompt (optional) - Auto-enhance the prompt for better results
Model: lucy_pro_i2i

Input Types

The FileInput type provides static factory methods for creating inputs:
// From image data
let imageInput = try FileInput.image(data: imageData, filename: "image.jpg")

// From video data
let videoInput = try FileInput.video(data: videoData, filename: "video.mp4")

// Auto-detect from UTType
let input = try FileInput.from(data: fileData, uniformType: .jpeg)

Error Handling

do {
    let processClient = try client.createProcessClient(
        model: .lucy_pro_i2i,
        input: input
    )
    let result = try await processClient.process()
} catch let error as DecartError {
    switch error {
    case .invalidAPIKey:
        print("Invalid API key - check your credentials")
    case .invalidInput(let message):
        print("Invalid input: \(message)")
    case .processingError(let message):
        print("Processing failed: \(message)")
    case .networkError(let underlying):
        print("Network error: \(underlying)")
    default:
        print("Error: \(error.localizedDescription)")
    }
}
Error Cases:
  • .invalidAPIKey - API key is invalid or missing
  • .invalidInput(String) - Invalid input parameters or validation failed
  • .processingError(String) - Server-side processing error
  • .modelNotFound(String) - Specified model doesn’t exist
  • .networkError(Error) - Network request failed

Complete Example

import DecartSDK
import UIKit

func editImage() async throws {
    let config = DecartConfiguration(apiKey: "your-api-key-here")
    let client = DecartClient(decartConfiguration: config)

    // Load image
    guard let image = UIImage(named: "input"),
          let imageData = image.jpegData(compressionQuality: 0.9) else {
        return
    }

    // Create input
    let input = try ImageToImageInput(
        prompt: "Transform to watercolor style",
        data: .image(data: imageData),
        resolution: .res720p,
        enhancePrompt: true
    )

    // Process
    let processClient = try client.createProcessClient(
        model: .lucy_pro_i2i,
        input: input
    )
    let resultData = try await processClient.process()

    // Use the result
    if let resultImage = UIImage(data: resultData) {
        // Display or save the transformed image
        print("Image transformed successfully")
    }
}

API Reference

client.createProcessClient(model:input:)

Creates a process client for image editing. Parameters:
  • model: ImageModel - Image model (.lucy_pro_i2i)
  • input: ImageToImageInput - Image editing input
Returns: ProcessClient Throws: DecartError if the model URL cannot be constructed

processClient.process()

Sends the image for processing and returns the result. Returns: Data - The transformed image bytes Throws: DecartError on network or processing failure

Next Steps

Queue API

Asynchronous video processing with job-based queue

Realtime API

Transform video streams in realtime with WebRTC