Here’s a tool function that gives all the API parameters to an AI - it is up to the AI then to use it appropriately and spend your money wisely. You’ll likely want to write your own and then rewrite what is actually sent.
tools_list.extend([{
"type": "function",
"function": {
"name": "create_image",
"description": "Create an image using either DALL-E 2 or DALL-E 3. AI can call this tool to generate images based on a prompt, model, and specified options.",
"parameters": {
"type": "object",
"properties": {
"prompt": {
"type": "string",
"description": "A text description of the desired image(s). The maximum length is 1000 characters for DALL-E 2 and 4000 characters for DALL-E 3.",
},
"model": {
"type": "string",
"enum": ["dall-e-2", "dall-e-3"],
"default": "dall-e-2",
"description": "The model to use for image generation. Defaults to DALL-E 2."
},
"n": {
"type": ["integer", "null"],
"default": 1,
"description": "The number of images to generate. Must be between 1 and 10. For DALL-E 3, only n=1 is supported."
},
"quality": {
"type": "string",
"enum": ["standard", "hd"],
"default": "standard",
"description": "The quality of the image that will be generated. 'hd' creates images with finer details and greater consistency across the image. This parameter is only supported for DALL-E 3."
},
"response_format": {
"type": ["string", "null"],
"enum": ["url", "b64_json"],
"default": "url",
"description": "The format in which the generated images are returned. Must be one of 'url' or 'b64_json'. URLs are only valid for 60 minutes after the image has been generated."
},
"size": {
"type": ["string", "null"],
"description": "The size of the generated images. Must be one of '256x256', '512x512', or '1024x1024' for DALL-E 2. Must be one of '1024x1024', '1792x1024', or '1024x1792' for DALL-E 3 models."
},
"style": {
"type": ["string", "null"],
"enum": ["vivid", "natural"],
"default": "vivid",
"description": "The style of the generated images. Must be one of 'vivid' or 'natural'. 'Vivid' causes the model to lean towards generating hyper-real and dramatic images. 'Natural' causes the model to produce more natural, less hyper-real looking images. This parameter is only supported for DALL-E 3."
}
},
"required": ["prompt"]
}