File size: 467 Bytes
5760606
 
 
 
1bc7525
 
 
 
5760606
 
 
 
 
 
 
 
739e67a
5760606
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
from typing import Any, Dict, List

import openai
from dotenv import load_dotenv

load_dotenv()


openai.api_key = os.environ["OPENAI_KEY_PERSONAL"]


def gen(prompt: str, n: int, size: str) -> Dict[str, Any]:
    return openai.Image.create(prompt=prompt, n=n, size=size)  # type: ignore


def urls(prompt: str, n: int = 1, size: str = "512x512") -> List[str]:
    images = gen(prompt, n, size)
    return [i["url"] for i in images["data"]]  # type: ignore