skip to Main Content

I’m new here and would appreciate your help.
I am currently experiencing an issue with the stablediffusion API.
Here’s my code.

const request_body = {
    key: process.env.REACT_APP_STABLE_DIFFUSION_API,
    prompt: "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner))",
    negative_prompt: null,
    width: "512",
    height: "512",
    samples: 1,
    num_inference_steps: "20",
    seed: null,
    guidance_scale: 7.5,
    safety_checker: "yes",
    multi_lingual: "no",
    panorama: "no",
    self_attention: "no",
    upscale: "no",
    embeddings_model: null,
    webhook: null,
    track_id: null,
};

const generateImage = async () => {
  const generateResponse = await axios.post(
    "https://stablediffusionapi.com/api/v5/text2video",
    request_body
  );
  console.log(generateResponse.data);
};

It’s not just an issue with the API key. The result is an error.
The status shows an error and the error message needs a seconds value.

2

Answers


  1. https://stablediffusionapi.com/api/v3/text2image
    

    Hey @theavocoder, you used the wrong API. The one you used is for text2video.
    Try using the API above.

    Login or Signup to reply.
  2. Add seconds parameter in request_body to specify the duration-related parameter if it is intended for video rendering.

    const request_body = {
        key: process.env.REACT_APP_STABLE_DIFFUSION_API,
        prompt: "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner))",
        negative_prompt: null,
        width: "512",
        height: "512",
        samples: 1,
        num_inference_steps: "20",
        seed: null,
        guidance_scale: 7.5,
        safety_checker: "yes",
        multi_lingual: "no",
        panorama: "no",
        self_attention: "no",
        upscale: "no",
        embeddings_model: null,
        webhook: null,
        track_id: null,
        seconds: 10, // Add duration in seconds
    };

    Add an exception handler for detailed error insights:

    const generateImage = async () => {
      try {
        const generateResponse = await axios.post(
          "https://stablediffusionapi.com/api/v5/text2video",
          request_body
        );
        console.log(generateResponse.data);
      } catch (error) {
        console.error("Error Status:", error.response.status);
        console.error("Error Message:", error.response.data);
      }
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search