Docs
DataCrunch HomeSDKAPILogin / Signup
  • Welcome to DataCrunch
    • Overview
    • Locations and Sustainability
    • Pricing and Billing
    • Team Projects
    • Support
  • CPU and GPU Instances
    • Set up a CPU or GPU instance
    • Securing Your Instance
    • Shutdown, Hibernate, and Delete
    • Adding a New User
    • Managing SSH Keys
    • Connecting to Your DataCrunch.io Server
    • Connecting to Jupyter notebook with VS Code
    • Remote desktop access
  • Clusters
    • Instant Clusters
      • Deploying a GPU cluster
      • Slurm
      • Spack
      • Good to know
    • Customized GPU clusters
  • Storage
    • Block Volumes
      • Attaching a block volume
      • Resizing a block volume
      • Cloning a block volume
      • Permanently deleting a block volume
    • Shared Filesystems (SFS)
      • Creating a shared filesystem
      • Editing share settings
      • Mounting a shared filesystem
  • Containers
    • Overview
    • Container Registries
    • Scaling and health-checks
    • Batching and Streaming
    • Async Inference
    • Tutorials
      • Quick: Deploy with vLLM
      • In-Depth: Deploy with TGI
      • In-Depth: Deploy with SGLang
      • In-Depth: Deploy with vLLM
      • In-Depth: Deploy with Replicate Cog
      • In-Depth: Asynchronous Inference Requests with Whisper
  • Inference
    • Overview
    • Authorization
    • Image Models
      • Flux.1 Kontext pro
      • Flux.1 Kontext max
    • Audio Models
      • Whisper X
  • Pricing and Billing
  • Resources
    • Resources Overview
    • Services Overview
    • Shared Responsibility Model
    • DataCrunch API
  • Python SDK
  • Get Free Compute Credits
Powered by GitBook
On this page
  • Overview
  • Prerequisites
  • Sign Up
  • Top Up Your Project Balance
  • Authorization
  • Generating images
  • Text to image
  • Image to image

Was this helpful?

  1. Inference
  2. Image Models

Flux.1 Kontext pro

Overview

FLUX.1 Kontext [pro] offers state-of-the-art editing capabilities with extra speed and fidelity. It maintains strong prompt adherence while executing region-level edits and scene-wide changes, with excellent character consistency and image semantics across iterations. No fine-tuning like LoRAs required.

FLUX.1 Kontext [pro] is hosted outside of DataCrunch infrastructure.

Below please find examples on how to use DataCrunch Inference API to generate images with FLUX.1 Kontext [pro].

Find out more about FLUX.1 Kontext.

Prerequisites

Sign Up

  1. Go to https://cloud.datacrunch.io/signup/

  2. Fill in your details and press Create account.

  3. Verify your email address.

  4. Navigate to your dashboard: https://cloud.datacrunch.io/

Top Up Your Project Balance

  1. Go to Billing & settings.

  2. Input the amount under Add funds to your project balance.

  3. Add your payment method and press Save billing details.

  4. Press Complete payment.

Authorization

To access and use these API endpoints, authorization is required. Please visit our Authorization page for detailed instructions on obtaining and using a bearer token for secure API access.

Generating images

Text to image

curl --request POST "https://relay.datacrunch.io/bfl/flux-kontext-pro" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <your_api_key>" \
--output "picture.png" \
--data '{
        "prompt": "a scientist racoon eating icecream in a datacenter",
        "steps": 50,
        "guidance": 3.0,
        "prompt_upsampling":true
}'
import requests
import os

token = <your_api_key>
bearer_token = f"Bearer {token}"

url = "https://relay.datacrunch.io/bfl/flux-kontext-pro"
headers = {
    "Content-Type": "application/json",
    "Authorization": bearer_token
}
data = {
    "prompt": "a scientist racoon eating icecream in a datacenter",
    "steps": 50,
    "guidance": 3.0,
    "prompt_upsampling":True
}

resp = requests.post(url, headers=headers, json=data)
resp.raise_for_status()

ct = resp.headers.get("Content-Type", "")
outfile = "picture.png"

if ct.startswith("image/"):
    with open(outfile, "wb") as f:
        f.write(resp.content)
    print(f"Saved raw image to {outfile}")
const axios = require('axios');
const fs = require('fs');

const url = 'https://relay.datacrunch.io/bfl/flux-kontext-pro';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <your_api_key>'
};
const data = {
  prompt: 'a scientist racoon eating icecream in a datacenter',
  steps: 50,
  guidance: 3.0,
  prompt_upsampling: true
};

axios.post(url, data, {
    headers,
    responseType: 'arraybuffer'
  })
  .then(response => {
    fs.writeFileSync('picture.png', response.data);
    console.log('Saved image to picture.png');
  })
  .catch(error => {
    console.error('Error:', error);
  });

Image to image

INPUT_BASE64="data:image/png;base64,$(base64 -i <your_picture>.png)"
read -r -d '' PAYLOAD <<EOF
{
  "prompt": "Make the picture a pencil sketch",
  "steps": 50,
  "guidance": 2.0,
  "input_image": "$INPUT_BASE64"
}
EOF

curl --request POST "https://relay.datacrunch.io/bfl/flux-kontext-pro" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <your_api_key>" \
--output "picture.png" \
--data "$PAYLOAD"
import os
import requests
import base64
from PIL import Image
from io import BytesIO

token = <your_api_key>
bearer_token = f"Bearer {token}"

url = "https://relay.datacrunch.io/bfl/flux-kontext-pro"
headers = {
    "Content-Type": "application/json",
    "Authorization": bearer_token
}

image = Image.open("test_pic_small.png")
buffered = BytesIO()
image.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue()).decode()

data = {
    "prompt": "a scientist racoon eating icecream in a datacenter",
    "steps": 50,
    "guidance": 3.0,
    'input_image': img_str,
}

resp = requests.post(url, headers=headers, json=data)
resp.raise_for_status()

ct = resp.headers.get("Content-Type", "")
outfile = "picture.png"

if ct.startswith("image/"):
    with open(outfile, "wb") as f:
        f.write(resp.content)
    print(f"Saved raw image to {outfile}")
const axios = require('axios');
const fs = require('fs');
const path = require('path');

const filePath = path.resolve(__dirname, 'test_pic_small.png');
const imageBuffer = fs.readFileSync(filePath);
const inputImage = `data:image/png;base64,${imageBuffer.toString('base64')}`;

const url = 'https://relay.datacrunch.io/bfl/flux-kontext-pro';
const headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer <your_api_key>'
};
const data = {
  prompt: 'a scientist racoon eating icecream in a datacenter',
  steps: 50,
  guidance: 3.0,
  input_image: inputImage
};

axios.post(url, data, {
    headers,
    responseType: 'arraybuffer'
  })
  .then(response => {
    fs.writeFileSync('picture.png', response.data);
    console.log('Saved image to picture.png');
  })
  .catch(error => {
    console.error('Error:', error);
  });

Last updated 15 days ago

Was this helpful?