### ----------------------------------------------------
### -- WWW::OpenAI
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: docs/Image-generation_woven.md
### ----------------------------------------------------
### -- Chunk 349 of 349
AgYGBAkGCQYJCg4PCQEGAPr07urk5xobEfv+A/f5BTUzJNDO2Ovp6hEXEQ4TEwUFAwL/AwD8/fH08+jn5/738QwVFv78+wsQEA8OEwD+/v77/wsNB/r5/fPs7fz7+woKB8W2uyswKgkJDRMVFAkQCv/+8wUKAfv38Ozp9A4RDxAQDfr5++3q7xMbEwQGCP37AQMEAgMDAfT3//3/9v/7///9/AwRAff2/f/9AgYJDgwKCPXw9P/79vz9Av8B+gEFAgUDCQACBvsABQYIBP39/fnz9P7++AMCB+rm7wUIBAgFBfr59wMIA/v7AQ8PDwQBCgQFAPLt7/8CAfHu8vf19v3/AAIHBQ4RCw4OC/z9/wH/9+/s8b+0vzpEO/fx7xAVGQkLCwcJCAMCBgsLBgQGBf759PX09gkKBAEHC/7//gIB/wUJBggHCQADBQID/vv7/wEA//f1/QULBvf09gD++f4AAP8A/Pn8/QH7BP38AgD+AP34+/39+/j2/QkIA/jz9O3u7AsOBu3s8RIUDg4TCfr09P36+w8PDN7Z5AYJCgwPC+fh9CAqHezp7xgbDvHw6+fg7S01J/Ht7wIC/vbv7xciHwcIBvf4AQgICf79Afv+AQQE///+AwMCAPv5+wMDA+zq8Q0NDP77//nz+hQXDfbx8RAPCvb0+g4SCfn1+wMD/wIB/uTc4RYiGQgKCwMGBAMGCAMHB/4BBgMGAwIDBgD/+v//9Pf39/fy8w0QDwL6/AAHBgkOEgUBBfz0+wD+//L1/ePVELhbZuaCAAAAAElFTkSuQmCC)


**Remark:** The obtained images are put into the *woven* document via the output of the code cell, 
which has the setting `results=asis`.

The first argument is a *prompt* used to generate the image(s).

Here are the descriptions of the named arguments (options):

- `model` takes `Whatever`, or one of 'dall-e-2' or 'dall-e-3'
- `n` takes a positive integer, for the number of images to be generated
- `size` takes the values according to the `model` value:
  - 'dall-e-2' : '1024x1024', '512x512', '256x256', 'large', 'medium', 'small'
  - 'dall-e-3' : '1024x1024', '1792x1024', '1024x1792', 'square', 'portrait', 'landscape'
- `response-format` takes the values "url" and "b64_json"
- `method` takes the values "tiny" and "curl"

**Remark:** See the model-parameter breakdown in the section below. 

Here we generate a few images, get their URLs, and place (embed) the image links using a table:

```perl6, results=asis
my @imgRes = |openai-create-image(
        "painting of a racoon and onion in the style of Rene Magritte",
        response-format => 'url',
        n => 2,
        size => 'small',
        format => 'values',
        method => 'tiny');

@imgRes.map({ '![](' ~ $_ ~ ')' }).join("\n\n")       
```
![](https://oaidalleapiprodscus.blob.core.windows.net/private/org-KbuLSsqssXAPQFZORGWZzuN0/user-Ss9QQAmz9L5UJDcmKnhxnRoT/img-D1kpMcjalq4jYZS9G39hTdLl.png?st=2023-12-10T15%3A32%3A29Z&se=2023-12-10T17%3A32%3A29Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-12-09T23%3A10%3A22Z&ske=2023-12-10T23%3A10%3A22Z&sks=b&skv=2021-08-06&sig=dYxFX53RsIsJApiRLUBsA/r1quPfYFSPjeqnOJz8BMQ%3D)

![](https://oaidalleapiprodscus.blob.core.windows.net/private/org-KbuLSsqssXAPQFZORGWZzuN0/user-Ss9QQAmz9L5UJDcmKnhxnRoT/img-QeEit06H1oNjN15kwAbOwRv2.png?st=2023-12-10T15%3A32%3A29Z&se=2023-12-10T17%3A32%3A29Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-12-09T23%3A10%3A22Z&ske=2023-12-10T23%3A10%3A22Z&sks=b&skv=2021-08-06&sig=ZJ9rLPBh1BwgO4epPtbLp4JE8U4On2miFB2VQzDi9bM%3D)


-----

## Parameters

As it was mentioned above, the argument "model" can be `Whatever` of one of "dall-e-2" or "dall-e-3".

Not all parameters that are valid for one of the models are valid or respected by the other --
see the subsection ["Create image"](https://platform.openai.com/docs/api-reference/images/create) of
[OpenAI's documentation](https://platform.openai.com/docs/api-reference).

Here is a table that shows a breakdown of the model-parameter relationships:

| Parameter | Type | Required/Optional | Default | dall-e-2 | dall-e-3 | Valid Values |
|-----------|------|------------------|---------|----------|----------|--------------|
| prompt | string | Required | N/A | ✔️ | ✔️ | Maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3 |
| model | string | Optional | dall-e-2 | ✔️ | ✔️ | N/A |
| n | integer or null | Optional | 1 | ✔️ | ✔️ (only n=1) | Must be between 1 and 10. For dall-e-3, only n=1 is supported |
| quality | string | Optional | standard | ❌ | ✔️ | N/A |
| response_format | string or null | Optional | url | ✔️ | ✔️ | Must be one of url or b64_json |
| size | string or null | Optional | 1024x1024 | ✔️ (256x256, 512x512, 1024x1024) | ✔️ (1024x1024, 1792x1024, 1024x1792) | 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 | string or null | Optional | vivid | ❌ | ✔️ | Must be one of vivid or natural |


--------

## References

### Articles

[AA1] Anton Antonov,
["Connecting Mathematica and Raku"](https://rakuforprediction.wordpress.com/2021/12/30/connecting-mathematica-and-raku/),
(2021),
[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).

### Packages

[AAp1] Anton Antonov,
[WWW::OpenAI Raku package](https://github.com/antononcube/Raku-WWW-OpenAI),
(2023),
[GitHub/antononcube](https://github.com/antononcube).

[AAp2] Anton Antonov,
[Text::CodeProcessing](https://github.com/antononcube/Raku-Text-CodeProcessing),
(2021),
[GitHub/antononcube](https://github.com/antononcube).

[OAI1] OpenAI Platform, [OpenAI platform](https://platform.openai.com/).

[OAI2] OpenAI Platform, [OpenAI documentation](https://platform.openai.com/docs).

[OAIp1] OpenAI,
[OpenAI Python Library](https://github.com/openai/openai-python),
(2020),
[GitHub/openai](https://github.com/openai/).


