我有可以完美工作的curl命令(通过稳定API使用img2img):
curl --request POST 'https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image' \
--header 'Content-Type: multipart/form-data' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer somesecrettoken' \
--form 'init_image=@"/full/path/to/init_image.png"' \
--form 'text_prompts[0][text]=Beautiful php code' \
--output '/full/path/to/response.json'
我已经在GUZLE v.6.5.8中try 了这段PHP代码,它给出了HTTP520:
(new Client())
->post(
'https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image',
[
RequestOptions::HEADERS => [
'Accept' => 'application/json',
'Authorization' => 'Bearer somesecrettoken',
'Content-Type' => 'multipart/form-data',
],
RequestOptions::MULTIPART => [
[
'name' => 'text_prompts[0][text]',
'contents' => 'Beautiful php code',
],
[
'name' => 'init_image',
'contents' => (new File('/full/path/to/init_image.png'))->getContent(),
// 'contents' => \GuzzleHttp\Psr7\Utils::tryFopen('/full/path/to/init_image.png', 'rb'), // This won't work too
],
],
RequestOptions::SINK => '/full/path/to/response.json',
RequestOptions::DEBUG => true,
],
)
我在这里做错了什么?