Skip to content

Commit 45a7d3c

Browse files
committed
1.1.0
1 parent 8fc7f83 commit 45a7d3c

File tree

1 file changed

+314
-2
lines changed

1 file changed

+314
-2
lines changed

openapi.yaml

Lines changed: 314 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ openapi: 3.0.0
22
info:
33
title: OpenAI API
44
description: APIs for sampling from and fine-tuning language models
5-
version: '1.0.6'
5+
version: '1.1.0'
66
servers:
77
- url: https://api.openai.com/v1
88
tags:
@@ -285,6 +285,210 @@ paths:
285285
}
286286
}
287287
288+
/images/generations:
289+
post:
290+
operationId: createImage
291+
tags:
292+
- OpenAI
293+
summary: Creates an image given a prompt.
294+
requestBody:
295+
required: true
296+
content:
297+
application/json:
298+
schema:
299+
$ref: '#/components/schemas/CreateImageRequest'
300+
responses:
301+
"200":
302+
description: OK
303+
content:
304+
application/json:
305+
schema:
306+
$ref: '#/components/schemas/ImagesResponse'
307+
x-oaiMeta:
308+
name: Create image
309+
group: images
310+
path: create
311+
examples:
312+
curl: |
313+
curl https://api.openai.com/v1/images/generations \
314+
-H 'Content-Type: application/json' \
315+
-H 'Authorization: Bearer YOUR_API_KEY' \
316+
-d '{
317+
"prompt": "A cute baby sea otter",
318+
"n": 2,
319+
"size": "1024x1024"
320+
}'
321+
python: |
322+
import os
323+
import openai
324+
openai.api_key = os.getenv("OPENAI_API_KEY")
325+
openai.Image.create(
326+
prompt="A cute baby sea otter",
327+
n=2,
328+
size="1024x1024"
329+
)
330+
node.js: |
331+
const { Configuration, OpenAIApi } = require("openai");
332+
const configuration = new Configuration({
333+
apiKey: process.env.OPENAI_API_KEY,
334+
});
335+
const openai = new OpenAIApi(configuration);
336+
const response = await openai.createImage({
337+
prompt: "A cute baby sea otter",
338+
n: 2,
339+
size: "1024x1024",
340+
});
341+
parameters: |
342+
{
343+
"prompt": "A cute baby sea otter",
344+
"n": 2,
345+
"size": "1024x1024"
346+
}
347+
response: |
348+
{
349+
"created": 1589478378,
350+
"data": [
351+
{
352+
"url": "https://..."
353+
},
354+
{
355+
"url": "https://..."
356+
}
357+
]
358+
}
359+
360+
/images/edits:
361+
post:
362+
operationId: createImageEdit
363+
tags:
364+
- OpenAI
365+
summary: Creates an edited or extended image given an original image and a prompt.
366+
requestBody:
367+
required: true
368+
content:
369+
multipart/form-data:
370+
schema:
371+
$ref: '#/components/schemas/CreateImageEditRequest'
372+
responses:
373+
"200":
374+
description: OK
375+
content:
376+
application/json:
377+
schema:
378+
$ref: '#/components/schemas/ImagesResponse'
379+
x-oaiMeta:
380+
name: Create image edit
381+
group: images
382+
path: create-edit
383+
examples:
384+
curl: |
385+
curl https://api.openai.com/v1/images/edits \
386+
-H 'Authorization: Bearer YOUR_API_KEY' \
387+
-F image='@otter.png' \
388+
-F mask='@mask.png' \
389+
-F prompt="A cute baby sea otter wearing a beret" \
390+
-F n=2 \
391+
-F size="1024x1024"
392+
python: |
393+
import os
394+
import openai
395+
openai.api_key = os.getenv("OPENAI_API_KEY")
396+
openai.Image.create_edit(
397+
image=open("otter.png"),
398+
mask=open("mask.png"),
399+
prompt="A cute baby sea otter wearing a beret",
400+
n=2,
401+
size="1024x1024"
402+
)
403+
node.js: |
404+
const { Configuration, OpenAIApi } = require("openai");
405+
const configuration = new Configuration({
406+
apiKey: process.env.OPENAI_API_KEY,
407+
});
408+
const openai = new OpenAIApi(configuration);
409+
const response = await openai.createImageEdit(
410+
fs.createReadStream("otter.png"),
411+
fs.createReadStream("mask.png"),
412+
"A cute baby sea otter wearing a beret",
413+
2,
414+
"1024x1024",
415+
);
416+
response: |
417+
{
418+
"created": 1589478378,
419+
"data": [
420+
{
421+
"url": "https://..."
422+
},
423+
{
424+
"url": "https://..."
425+
}
426+
]
427+
}
428+
429+
/images/variations:
430+
post:
431+
operationId: createImageVariation
432+
tags:
433+
- OpenAI
434+
summary: Creates a variation of a given image.
435+
requestBody:
436+
required: true
437+
content:
438+
multipart/form-data:
439+
schema:
440+
$ref: '#/components/schemas/CreateImageVariationRequest'
441+
responses:
442+
"200":
443+
description: OK
444+
content:
445+
application/json:
446+
schema:
447+
$ref: '#/components/schemas/ImagesResponse'
448+
x-oaiMeta:
449+
name: Create image variation
450+
group: images
451+
path: create-variation
452+
examples:
453+
curl: |
454+
curl https://api.openai.com/v1/images/variations \
455+
-H 'Authorization: Bearer YOUR_API_KEY' \
456+
-F image='@otter.png' \
457+
-F n=2 \
458+
-F size="1024x1024"
459+
python: |
460+
import os
461+
import openai
462+
openai.api_key = os.getenv("OPENAI_API_KEY")
463+
openai.Image.create_variation(
464+
image=open("otter.png"),
465+
n=2,
466+
size="1024x1024"
467+
)
468+
node.js: |
469+
const { Configuration, OpenAIApi } = require("openai");
470+
const configuration = new Configuration({
471+
apiKey: process.env.OPENAI_API_KEY,
472+
});
473+
const openai = new OpenAIApi(configuration);
474+
const response = await openai.createImageVariation(
475+
fs.createReadStream("otter.png"),
476+
2,
477+
"1024x1024",
478+
);
479+
response: |
480+
{
481+
"created": 1589478378,
482+
"data": [
483+
{
484+
"url": "https://..."
485+
},
486+
{
487+
"url": "https://..."
488+
}
489+
]
490+
}
491+
288492
/embeddings:
289493
post:
290494
operationId: createEmbedding
@@ -1509,6 +1713,13 @@ paths:
15091713
import openai
15101714
openai.api_key = os.getenv("OPENAI_API_KEY")
15111715
openai.Model.delete("curie:ft-acmeco-2021-03-03-21-44-20")
1716+
node.js: |
1717+
const { Configuration, OpenAIApi } = require("openai");
1718+
const configuration = new Configuration({
1719+
apiKey: process.env.OPENAI_API_KEY,
1720+
});
1721+
const openai = new OpenAIApi(configuration);
1722+
const response = await openai.deleteModel('curie:ft-acmeco-2021-03-03-21-44-20');
15121723
response: |
15131724
{
15141725
"id": "curie:ft-acmeco-2021-03-03-21-44-20",
@@ -1554,6 +1765,15 @@ paths:
15541765
openai.Moderation.create(
15551766
input="I want to kill them.",
15561767
)
1768+
node.js: |
1769+
const { Configuration, OpenAIApi } = require("openai");
1770+
const configuration = new Configuration({
1771+
apiKey: process.env.OPENAI_API_KEY,
1772+
});
1773+
const openai = new OpenAIApi(configuration);
1774+
const response = await openai.createModeration({
1775+
input: "I want to kill them.",
1776+
});
15571777
parameters: |
15581778
{
15591779
"input": "I want to kill them."
@@ -1800,7 +2020,7 @@ components:
18002020
type: string
18012021
example: user-1234
18022022
description: |
1803-
A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
2023+
A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. [Learn more](/docs/usage-policies/end-user-ids).
18042024
required:
18052025
- model
18062026

@@ -1974,6 +2194,94 @@ components:
19742194
- choices
19752195
- usage
19762196

2197+
CreateImageRequest:
2198+
type: object
2199+
properties:
2200+
prompt:
2201+
description: A text description of the desired image(s). The maximum length is 1000 characters.
2202+
type: string
2203+
example: "A cute baby sea otter"
2204+
n: &images_n
2205+
type: integer
2206+
minimum: 1
2207+
maximum: 10
2208+
default: 1
2209+
example: 1
2210+
nullable: true
2211+
description: The number of images to generate. Must be between 1 and 10.
2212+
size: &images_size
2213+
type: string
2214+
enum: ["256x256", "512x512", "1024x1024"]
2215+
default: "1024x1024"
2216+
example: "1024x1024"
2217+
nullable: true
2218+
description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
2219+
response_format: &images_response_format
2220+
type: string
2221+
enum: ["url", "b64_json"]
2222+
default: "url"
2223+
example: "url"
2224+
nullable: true
2225+
description: The format in which the generated images are returned. Must be one of `url` or `b64_json`.
2226+
user: *end_user_param_configuration
2227+
required:
2228+
- prompt
2229+
2230+
ImagesResponse:
2231+
properties:
2232+
created:
2233+
type: integer
2234+
data:
2235+
type: array
2236+
items:
2237+
type: object
2238+
properties:
2239+
url:
2240+
type: string
2241+
b64_json:
2242+
type: string
2243+
required:
2244+
- created
2245+
- data
2246+
2247+
CreateImageEditRequest:
2248+
type: object
2249+
properties:
2250+
image:
2251+
description: The image to edit. Must be a valid PNG file, less than 4MB, and square.
2252+
type: string
2253+
format: binary
2254+
mask:
2255+
description: An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.
2256+
type: string
2257+
format: binary
2258+
prompt:
2259+
description: A text description of the desired image(s). The maximum length is 1000 characters.
2260+
type: string
2261+
example: "A cute baby sea otter wearing a beret"
2262+
n: *images_n
2263+
size: *images_size
2264+
response_format: *images_response_format
2265+
user: *end_user_param_configuration
2266+
required:
2267+
- prompt
2268+
- image
2269+
- mask
2270+
2271+
CreateImageVariationRequest:
2272+
type: object
2273+
properties:
2274+
image:
2275+
description: The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
2276+
type: string
2277+
format: binary
2278+
n: *images_n
2279+
size: *images_size
2280+
response_format: *images_response_format
2281+
user: *end_user_param_configuration
2282+
required:
2283+
- image
2284+
19772285
CreateModerationRequest:
19782286
type: object
19792287
properties:
@@ -2831,6 +3139,10 @@ x-oaiMeta:
28313139
title: Edits
28323140
description: |
28333141
Given a prompt and an instruction, the model will return an edited version of the prompt.
3142+
- id: images
3143+
title: Images
3144+
description: |
3145+
Given a prompt and/or an input image, the model will generate a new image.
28343146
- id: embeddings
28353147
title: Embeddings
28363148
description: |

0 commit comments

Comments
 (0)