Stability-AI / rest-api-support

Stability REST API examples, issues, and discussions | https://api.stability.ai
108 stars 21 forks source link

Standardize FormData Endpoints #4

Closed todd-elvers closed 1 year ago

todd-elvers commented 1 year ago

Remove the options argument passed to the image-to-image and image-to-image/masking endpoints and instead require each option to be passed in on the form data payload itself.

For example, the following TS code builds up a form-data object to pass to the v1alpha's image-to-image endpoint:

const formData = new FormData();

formData.append('init_image', initImage);
formData.append('options', JSON.stringify({
  "cfg_scale": 7,
  "clip_guidance_preset": "FAST_BLUE",
  "step_schedule_start": 0.6,
  "step_schedule_end": 0.01,
  "height": 512,
  "width": 512,
  "samples": 1,
  "steps": 50,
  "text_prompts": [
    {
      "text": "Galactic dog",
      "weight": 1
    }
  ],
}));

And with the proposed changes the example would become:

const formData = new FormData();

formData.append("init_image", initImage);
formData.append("cfg_scale", 7);
formData.append("clip_guidance_preset", "FAST_BLUE");
formData.append("step_schedule_start", 0.6);
formData.append("step_schedule_end", 0.01);
formData.append("height", 512);
formData.append("width", 512);
formData.append("samples", 1);
formData.append("steps", 50);
formData.append("text_prompts[0][text]", "Galactic dog");
formData.append("text_prompts[0][weight]", 1);
todd-elvers commented 1 year ago

This has been deployed to production.