Quickstart: Flux Kontext

Learn how to use Flux's new in-context image generation models

Flux Kontext

Black Forest Labs has released FLUX Kontext with support on Together AI. These models allow you to generate and edit images through in-context image generation.

Unlike existing text-to-image models, FLUX.1 Kontext allows you to prompt with both text and images, and seamlessly extract and modify visual concepts to produce new, coherent renderings.

The two new models are Max for maximum image quality, and Pro for faster generation speed.

Generating an image

Here's how to use the new Kontext models:

from together import Together

client = Together()

imageCompletion = client.images.generate(
    model="black-forest-labs/FLUX.1-kontext-pro",
    width=1024,
    height=768,
    prompt="make his shirt yellow",
    image_url="https://github.com/nutlope.png",
)

print(imageCompletion.data[0].url)

import Together from "together-ai";

const together = new Together();

async function main() {
  const response = await together.images.create({
    model: "black-forest-labs/FLUX.1-kontext-pro",
    width: 1024,
    height: 1024,
    prompt: "make his shirt yellow",
    image_url: "https://github.com/nutlope.png",
  });

  console.log(response.data[0].url);
}

main();

Check out all available Flux models here: https://docs.together.ai/docs/serverless-models#image-models