Try creating an image through Portkey will give base64 format, even after setting up
response_format
to be
url
.
config_json = json.dumps(config)
url = 'https://api.portkey.ai/v1/images/generations'
headers = {
'Content-Type': 'application/json',
'x-portkey-api-key': f'{PORTKEY_API_KEY}',
}
headers['x-portkey-config'] = config_json
data = {"prompt": "Harry potter using aeroplane for transport", "response_format":"url"}
response = requests.post(url, headers=headers, data=json.dumps(data))
generation_response = response.json()
print(generation_response)
# {'created': '1710664648966', 'data': [{'b64_json': 'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACA....
This could be because Stability AI does not return URL in it's response (after
Accept: image/png
). But it does return
bytes
. How can one get them through Portkey ?