axios 具有React问题的稳定扩散API

f1tvaqid  于 5个月前  发布在  iOS
关注(0)|答案(2)|浏览(49)

我是新来的,非常感谢您的帮助。我目前遇到了一个问题,与stablediffusion API。这是我的代码。

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);
};

字符串
这不仅仅是API键的问题。结果是错误。状态显示错误,错误消息需要秒值。

44u64gxh

44u64gxh1#

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

字符串
嘿@theavocoder,你使用了错误的API。你使用的是text 2 video。尝试使用上面的API。

esbemjvw

esbemjvw2#

在request_body中增加seconds参数,用于指定渲染时长相关参数。

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
};

字符串
添加异常处理程序以获得详细的错误洞察:

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);
  }
};

相关问题