DALL-E Bird Images from Text

ÜCRETSİZ
Taraf OpenedAI | Güncelleyen vor einem Monat | Video, Images
Popülerlik

0.3 / 10

Gecikme

60ms

Hizmet Düzeyi

0%

Health Check

N/A

Tüm Eğitimlere Dön (1)

Calling the API & loading base64 in Python

Here is an example for correctly calling the API in Python:

import json
import requests
import base64

url = "https://dall-e-bird-images-from-text.p.rapidapi.com/generate"

text = "a crystal blue bird with a black head"

payload = {"text": text}
payload = json.dumps(payload)
headers = {
'x-rapidapi-host': "dall-e-bird-images-from-text.p.rapidapi.com",
'x-rapidapi-key': "YOURKEY",
‘content-type': "application/json"
}
response = requests.request("POST", url, data=payload, headers=headers)

b64img = json.loads(response.text)["base64img"]

imgdata = base64.b64decode(b64img)
filename = 'dalle-crystal-bird.jpg'
with open(filename, 'wb') as f:
	f.write(imgdata)