Skip to content

Commit 5b2ca28

Browse files
committed
updated examples snippets
1 parent 45a7d3c commit 5b2ca28

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

openapi.yaml

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ paths:
9999
path: retrieve
100100
examples:
101101
curl: |
102-
curl -u :YOUR_API_KEY https://api.openai.com/v1/engines/VAR_model_id
102+
curl https://api.openai.com/v1/engines/VAR_model_id \
103+
-H 'Authorization: Bearer YOUR_API_KEY'
103104
python: |
104105
import os
105106
import openai
@@ -151,7 +152,7 @@ paths:
151152
-d '{
152153
"model": "VAR_model_id",
153154
"prompt": "Say this is a test",
154-
"max_tokens": 6,
155+
"max_tokens": 7,
155156
"temperature": 0
156157
}'
157158
python: |
@@ -161,7 +162,7 @@ paths:
161162
openai.Completion.create(
162163
model="VAR_model_id",
163164
prompt="Say this is a test",
164-
max_tokens=6,
165+
max_tokens=7,
165166
temperature=0
166167
)
167168
node.js: |
@@ -173,14 +174,14 @@ paths:
173174
const response = await openai.createCompletion({
174175
model: "VAR_model_id",
175176
prompt: "Say this is a test",
176-
max_tokens: 6,
177+
max_tokens: 7,
177178
temperature: 0,
178179
});
179180
parameters: |
180181
{
181182
"model": "VAR_model_id",
182183
"prompt": "Say this is a test",
183-
"max_tokens": 6,
184+
"max_tokens": 7,
184185
"temperature": 0,
185186
"top_p": 1,
186187
"n": 1,
@@ -196,16 +197,16 @@ paths:
196197
"model": "VAR_model_id",
197198
"choices": [
198199
{
199-
"text": "\n\nThis is a test",
200+
"text": "\n\nThis is indeed a test",
200201
"index": 0,
201202
"logprobs": null,
202203
"finish_reason": "length"
203204
}
204205
],
205206
"usage": {
206207
"prompt_tokens": 5,
207-
"completion_tokens": 6,
208-
"total_tokens": 11
208+
"completion_tokens": 7,
209+
"total_tokens": 12
209210
}
210211
}
211212
@@ -394,8 +395,8 @@ paths:
394395
import openai
395396
openai.api_key = os.getenv("OPENAI_API_KEY")
396397
openai.Image.create_edit(
397-
image=open("otter.png"),
398-
mask=open("mask.png"),
398+
image=open("otter.png", "rb"),
399+
mask=open("mask.png", "rb"),
399400
prompt="A cute baby sea otter wearing a beret",
400401
n=2,
401402
size="1024x1024"
@@ -411,7 +412,7 @@ paths:
411412
fs.createReadStream("mask.png"),
412413
"A cute baby sea otter wearing a beret",
413414
2,
414-
"1024x1024",
415+
"1024x1024"
415416
);
416417
response: |
417418
{
@@ -461,7 +462,7 @@ paths:
461462
import openai
462463
openai.api_key = os.getenv("OPENAI_API_KEY")
463464
openai.Image.create_variation(
464-
image=open("otter.png"),
465+
image=open("otter.png", "rb"),
465466
n=2,
466467
size="1024x1024"
467468
)
@@ -474,7 +475,7 @@ paths:
474475
const response = await openai.createImageVariation(
475476
fs.createReadStream("otter.png"),
476477
2,
477-
"1024x1024",
478+
"1024x1024"
478479
);
479480
response: |
480481
{
@@ -519,14 +520,14 @@ paths:
519520
-H "Authorization: Bearer YOUR_API_KEY" \
520521
-H "Content-Type: application/json" \
521522
-d '{"input": "The food was delicious and the waiter...",
522-
"model": "text-similarity-babbage-001"}'
523+
"model": "text-embedding-ada-002"}'
523524
524525
python: |
525526
import os
526527
import openai
527528
openai.api_key = os.getenv("OPENAI_API_KEY")
528529
openai.Embedding.create(
529-
model="text-similarity-babbage-001",
530+
model="text-embedding-ada-002",
530531
input="The food was delicious and the waiter..."
531532
)
532533
node.js: |
@@ -536,12 +537,12 @@ paths:
536537
});
537538
const openai = new OpenAIApi(configuration);
538539
const response = await openai.createEmbedding({
539-
model: "text-similarity-babbage-001",
540+
model: "text-embedding-ada-002",
540541
input: "The food was delicious and the waiter...",
541542
});
542543
parameters: |
543544
{
544-
"model": "text-similarity-babbage-001",
545+
"model": "text-embedding-ada-002",
545546
"input": "The food was delicious and the waiter..."
546547
}
547548
response: |
@@ -551,14 +552,15 @@ paths:
551552
{
552553
"object": "embedding",
553554
"embedding": [
554-
0.018990106880664825,
555-
-0.0073809814639389515,
556-
.... (1024 floats total for ada)
557-
0.021276434883475304,
555+
0.0023064255,
556+
-0.009327292,
557+
.... (1056 floats total for ada)
558+
-0.0028842222,
558559
],
559560
"index": 0
560561
}
561562
],
563+
"model": "text-embedding-ada-002",
562564
"usage": {
563565
"prompt_tokens": 8,
564566
"total_tokens": 8
@@ -751,7 +753,7 @@ paths:
751753
import openai
752754
openai.api_key = os.getenv("OPENAI_API_KEY")
753755
openai.File.create(
754-
file=open("mydata.jsonl"),
756+
file=open("mydata.jsonl", "rb"),
755757
purpose='fine-tune'
756758
)
757759
node.js: |
@@ -1658,7 +1660,8 @@ paths:
16581660
path: retrieve
16591661
examples:
16601662
curl: |
1661-
curl -u :YOUR_API_KEY https://api.openai.com/v1/models/VAR_model_id
1663+
curl https://api.openai.com/v1/models/VAR_model_id \
1664+
-H 'Authorization: Bearer YOUR_API_KEY'
16621665
python: |
16631666
import os
16641667
import openai
@@ -2020,7 +2023,7 @@ components:
20202023
type: string
20212024
example: user-1234
20222025
description: |
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).
2026+
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).
20242027
required:
20252028
- model
20262029

@@ -2248,7 +2251,7 @@ components:
22482251
type: object
22492252
properties:
22502253
image:
2251-
description: The image to edit. Must be a valid PNG file, less than 4MB, and square.
2254+
description: The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
22522255
type: string
22532256
format: binary
22542257
mask:
@@ -2266,7 +2269,6 @@ components:
22662269
required:
22672270
- prompt
22682271
- image
2269-
- mask
22702272

22712273
CreateImageVariationRequest:
22722274
type: object
@@ -2922,9 +2924,7 @@ components:
29222924
model: *model_configuration
29232925
input:
29242926
description: |
2925-
Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 2048 tokens in length.
2926-
2927-
Unless you are embedding code, we suggest replacing newlines (`\n`) in your input with a single space, as we have observed inferior results when newlines are present.
2927+
Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length.
29282928
example: "The quick brown fox jumped over the lazy dog"
29292929
oneOf:
29302930
- type: string
@@ -3143,6 +3143,8 @@ x-oaiMeta:
31433143
title: Images
31443144
description: |
31453145
Given a prompt and/or an input image, the model will generate a new image.
3146+
3147+
Related guide: [Image generation](/docs/guides/images)
31463148
- id: embeddings
31473149
title: Embeddings
31483150
description: |

0 commit comments

Comments
 (0)