diff --git a/demos/openai/image.md b/demos/openai/image.md new file mode 100644 index 000000000..2f2072c88 --- /dev/null +++ b/demos/openai/image.md @@ -0,0 +1,49 @@ +# Image Generation + +```javascript +import OpenAI from "demos/openai/openai.js" + + +let prompt = { + "model": "dall-e-3", + "prompt": "a white siamese cat", + "n": 1, + "size": "1024x1024" + } + + +async function imageGeneration(prompt) { + const apiKey = await OpenAI.ensureSubscriptionKey(); + const url = "https://api.openai.com/v1/images/generations"; + + const requestOptions = { + method: "POST", + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${apiKey}` + }, + body: JSON.stringify(prompt) + }; + return fetch(url, requestOptions); + } + + +let response = await imageGeneration(prompt) + + +reso + +let json = await response.json() + + +json.data[0].url + +``` + + diff --git a/demos/openai/vision.md b/demos/openai/vision.md index ad17b5234..6b630e5f9 100644 --- a/demos/openai/vision.md +++ b/demos/openai/vision.md @@ -3,9 +3,6 @@ ![](vision.png) -![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAsUlEQVR4nO3aMQrCQBBF0XcU7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB7qB) - - ```javascript import OpenAI from "demos/openai/openai.js"