Negative prompts for the inference api

Hello, for the free inference api, Is there a way to add negative prompts? I heard that huggingface recently added this feature, and was wondering how to include it in my request…

Thanks in advance!

EDIT: this would be for the Stable Diffusion inference api…

Any updates?

hi @jetpackjules,

Yes we’ve recently add the negative prompt to the API

Here is a request example in Javascript

fetch(
  "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2",
  {
    method: "POST",
    headers: {
      "content-type": "application/json",
    },
    body: JSON.stringify({
      inputs:
        "award winning high resolution photo of a giant tortoise/((ladybird)) hybrid, [trending on artstation]",
      negative_prompt: "blurry",
    }),
  }
)
  .then((res) => res.blob())
  .then((blob) => {
    const tab = window.open((target = "_blank"));
    tab.location.href = window.URL.createObjectURL(blob);
  });

Blockquote

Awesome, Thankyou very much!

1 Like

Does this also work for Stable Diffusion 1-5, or just 2?

Hi @jetpackjules atm the pipeline is very basic and only supports 512px inference, however we could change that, you can send your opinion needs here Document usage of text-to-image · Issue #152 · huggingface/api-inference-community · GitHub

1 Like

@jetpackjules sorry, it’s automatic, you have to set the sample size on the vae config file

Compare

For the negative prompt?

Hey, how to download an image from this data and display it in nodejs?


I use your code

Hi , I want to know about Inference Endpoint. Does it allow all parameters? size,…