openapi.openai.yaml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chromadb-java-client Show documentation
Show all versions of chromadb-java-client Show documentation
Chroma Vector DB Java Client
The newest version!
openapi: 3.0.0
info:
title: OpenAI API
description: APIs for sampling from and fine-tuning language models
version: '2.0.0'
servers:
- url: https://api.openai.com/v1
tags:
- name: OpenAI
description: The OpenAI REST API
paths:
/chat/completions:
post:
operationId: createChatCompletion
tags:
- OpenAI
summary: Creates a model response for the given chat conversation.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateChatCompletionRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateChatCompletionResponse'
x-oaiMeta:
name: Create chat completion
group: chat
path: create
examples:
curl: |
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}]
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{"role": "system", "content": "You are a helpful assistant."}, {role: "user", content: "Hello world"}],
});
console.log(completion.data.choices[0].message);
parameters: |
{
"model": "gpt-3.5-turbo",
"messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}]
}
response: |
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?",
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
/completions:
post:
operationId: createCompletion
tags:
- OpenAI
summary: Creates a completion for the provided prompt and parameters.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCompletionRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateCompletionResponse'
x-oaiMeta:
name: Create completion
group: completions
path: create
legacy: true
examples:
curl: |
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "VAR_model_id",
"prompt": "Say this is a test",
"max_tokens": 7,
"temperature": 0
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Completion.create(
model="VAR_model_id",
prompt="Say this is a test",
max_tokens=7,
temperature=0
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "VAR_model_id",
prompt: "Say this is a test",
max_tokens: 7,
temperature: 0,
});
parameters: |
{
"model": "VAR_model_id",
"prompt": "Say this is a test",
"max_tokens": 7,
"temperature": 0,
"top_p": 1,
"n": 1,
"stream": false,
"logprobs": null,
"stop": "\n"
}
response: |
{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "VAR_model_id",
"choices": [
{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}
/edits:
post:
operationId: createEdit
deprecated: true
tags:
- OpenAI
summary: Creates a new edit for the provided input, instruction, and parameters.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEditRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEditResponse'
x-oaiMeta:
name: Create edit
group: edits
path: create
examples:
curl: |
curl https://api.openai.com/v1/edits \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "VAR_model_id",
"input": "What day of the wek is it?",
"instruction": "Fix the spelling mistakes"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Edit.create(
model="VAR_model_id",
input="What day of the wek is it?",
instruction="Fix the spelling mistakes"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEdit({
model: "VAR_model_id",
input: "What day of the wek is it?",
instruction: "Fix the spelling mistakes",
});
parameters: |
{
"model": "VAR_model_id",
"input": "What day of the wek is it?",
"instruction": "Fix the spelling mistakes"
}
response: |
{
"object": "edit",
"created": 1589478378,
"choices": [
{
"text": "What day of the week is it?",
"index": 0,
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 32,
"total_tokens": 57
}
}
/images/generations:
post:
operationId: createImage
tags:
- OpenAI
summary: Creates an image given a prompt.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateImageRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ImagesResponse'
x-oaiMeta:
name: Create image
group: images
path: create
examples:
curl: |
curl https://api.openai.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create(
prompt="A cute baby sea otter",
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImage({
prompt: "A cute baby sea otter",
n: 2,
size: "1024x1024",
});
parameters: |
{
"prompt": "A cute baby sea otter",
"n": 2,
"size": "1024x1024"
}
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/images/edits:
post:
operationId: createImageEdit
tags:
- OpenAI
summary: Creates an edited or extended image given an original image and a prompt.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CreateImageEditRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ImagesResponse'
x-oaiMeta:
name: Create image edit
group: images
path: create-edit
examples:
curl: |
curl https://api.openai.com/v1/images/edits \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F image="@otter.png" \
-F mask="@mask.png" \
-F prompt="A cute baby sea otter wearing a beret" \
-F n=2 \
-F size="1024x1024"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create_edit(
image=open("otter.png", "rb"),
mask=open("mask.png", "rb"),
prompt="A cute baby sea otter wearing a beret",
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImageEdit(
fs.createReadStream("otter.png"),
"A cute baby sea otter wearing a beret",
fs.createReadStream("mask.png"),
2,
"1024x1024"
);
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/images/variations:
post:
operationId: createImageVariation
tags:
- OpenAI
summary: Creates a variation of a given image.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CreateImageVariationRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ImagesResponse'
x-oaiMeta:
name: Create image variation
group: images
path: create-variation
examples:
curl: |
curl https://api.openai.com/v1/images/variations \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F image="@otter.png" \
-F n=2 \
-F size="1024x1024"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Image.create_variation(
image=open("otter.png", "rb"),
n=2,
size="1024x1024"
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createImageVariation(
fs.createReadStream("otter.png"),
2,
"1024x1024"
);
response: |
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
/embeddings:
post:
operationId: createEmbedding
tags:
- OpenAI
summary: Creates an embedding vector representing the input text.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEmbeddingRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEmbeddingResponse'
x-oaiMeta:
name: Create embeddings
group: embeddings
path: create
examples:
curl: |
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The food was delicious and the waiter...",
"model": "text-embedding-ada-002"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Embedding.create(
model="text-embedding-ada-002",
input="The food was delicious and the waiter..."
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEmbedding({
model: "text-embedding-ada-002",
input: "The food was delicious and the waiter...",
});
parameters: |
{
"model": "text-embedding-ada-002",
"input": "The food was delicious and the waiter..."
}
response: |
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
.... (1536 floats total for ada-002)
-0.0028842222,
],
"index": 0
}
],
"model": "text-embedding-ada-002",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
/audio/transcriptions:
post:
operationId: createTranscription
tags:
- OpenAI
summary: Transcribes audio into the input language.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CreateTranscriptionRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTranscriptionResponse'
x-oaiMeta:
name: Create transcription
group: audio
path: create
examples:
curl: |
curl https://api.openai.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/audio.mp3" \
-F model="whisper-1"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
audio_file = open("audio.mp3", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
node: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranscription(
fs.createReadStream("audio.mp3"),
"whisper-1"
);
parameters: |
{
"file": "audio.mp3",
"model": "whisper-1"
}
response: |
{
"text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that."
}
/audio/translations:
post:
operationId: createTranslation
tags:
- OpenAI
summary: Translates audio into English.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CreateTranslationRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTranslationResponse'
x-oaiMeta:
name: Create translation
group: audio
path: create
examples:
curl: |
curl https://api.openai.com/v1/audio/translations \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F file="@/path/to/file/german.m4a" \
-F model="whisper-1"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
audio_file = open("german.m4a", "rb")
transcript = openai.Audio.translate("whisper-1", audio_file)
node: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const resp = await openai.createTranslation(
fs.createReadStream("audio.mp3"),
"whisper-1"
);
parameters: |
{
"file": "german.m4a",
"model": "whisper-1"
}
response: |
{
"text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
/files:
get:
operationId: listFiles
tags:
- OpenAI
summary: Returns a list of files that belong to the user's organization.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListFilesResponse'
x-oaiMeta:
name: List files
group: files
path: list
examples:
curl: |
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.list()
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listFiles();
response: |
{
"data": [
{
"id": "file-ccdDZrC3iZVNiQVeEA6Z66wf",
"object": "file",
"bytes": 175,
"created_at": 1613677385,
"filename": "train.jsonl",
"purpose": "search"
},
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "puppy.jsonl",
"purpose": "search"
}
],
"object": "list"
}
post:
operationId: createFile
tags:
- OpenAI
summary: |
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/CreateFileRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/OpenAIFile'
x-oaiMeta:
name: Upload file
group: files
path: upload
examples:
curl: |
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="fine-tune" \
-F file="@mydata.jsonl"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.create(
file=open("mydata.jsonl", "rb"),
purpose='fine-tune'
)
node.js: |
const fs = require("fs");
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createFile(
fs.createReadStream("mydata.jsonl"),
"fine-tune"
);
response: |
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"bytes": 140,
"created_at": 1613779121,
"filename": "mydata.jsonl",
"purpose": "fine-tune"
}
/files/{file_id}:
delete:
operationId: deleteFile
tags:
- OpenAI
summary: Delete a file.
parameters:
- in: path
name: file_id
required: true
schema:
type: string
description: The ID of the file to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteFileResponse'
x-oaiMeta:
name: Delete file
group: files
path: delete
examples:
curl: |
curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.delete("file-XjGxS3KTG0uNmNOK362iJua3")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.deleteFile("file-XjGxS3KTG0uNmNOK362iJua3");
response: |
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"deleted": true
}
get:
operationId: retrieveFile
tags:
- OpenAI
summary: Returns information about a specific file.
parameters:
- in: path
name: file_id
required: true
schema:
type: string
description: The ID of the file to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/OpenAIFile'
x-oaiMeta:
name: Retrieve file
group: files
path: retrieve
examples:
curl: |
curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.File.retrieve("file-XjGxS3KTG0uNmNOK362iJua3")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.retrieveFile("file-XjGxS3KTG0uNmNOK362iJua3");
response: |
{
"id": "file-XjGxS3KTG0uNmNOK362iJua3",
"object": "file",
"bytes": 140,
"created_at": 1613779657,
"filename": "mydata.jsonl",
"purpose": "fine-tune"
}
/files/{file_id}/content:
get:
operationId: downloadFile
tags:
- OpenAI
summary: Returns the contents of the specified file
parameters:
- in: path
name: file_id
required: true
schema:
type: string
description: The ID of the file to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
type: string
x-oaiMeta:
name: Retrieve file content
group: files
path: retrieve-content
examples:
curl: |
curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3/content \
-H "Authorization: Bearer $OPENAI_API_KEY" > file.jsonl
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
content = openai.File.download("file-XjGxS3KTG0uNmNOK362iJua3")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.downloadFile("file-XjGxS3KTG0uNmNOK362iJua3");
/fine-tunes:
post:
operationId: createFineTune
tags:
- OpenAI
summary: |
Creates a job that fine-tunes a specified model from a given dataset.
Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
[Learn more about Fine-tuning](/docs/guides/fine-tuning)
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateFineTuneRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/FineTune'
x-oaiMeta:
name: Create fine-tune
group: fine-tunes
path: create
examples:
curl: |
curl https://api.openai.com/v1/fine-tunes \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"training_file": "file-XGinujblHPwGLSztz8cPS8XY"
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.FineTune.create(training_file="file-XGinujblHPwGLSztz8cPS8XY")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createFineTune({
training_file: "file-XGinujblHPwGLSztz8cPS8XY",
});
response: |
{
"id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
"object": "fine-tune",
"model": "curie",
"created_at": 1614807352,
"events": [
{
"object": "fine-tune-event",
"created_at": 1614807352,
"level": "info",
"message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
}
],
"fine_tuned_model": null,
"hyperparams": {
"batch_size": 4,
"learning_rate_multiplier": 0.1,
"n_epochs": 4,
"prompt_loss_weight": 0.1,
},
"organization_id": "org-...",
"result_files": [],
"status": "pending",
"validation_files": [],
"training_files": [
{
"id": "file-XGinujblHPwGLSztz8cPS8XY",
"object": "file",
"bytes": 1547276,
"created_at": 1610062281,
"filename": "my-data-train.jsonl",
"purpose": "fine-tune-train"
}
],
"updated_at": 1614807352,
}
get:
operationId: listFineTunes
tags:
- OpenAI
summary: |
List your organization's fine-tuning jobs
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListFineTunesResponse'
x-oaiMeta:
name: List fine-tunes
group: fine-tunes
path: list
examples:
curl: |
curl https://api.openai.com/v1/fine-tunes \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.FineTune.list()
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listFineTunes();
response: |
{
"object": "list",
"data": [
{
"id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
"object": "fine-tune",
"model": "curie",
"created_at": 1614807352,
"fine_tuned_model": null,
"hyperparams": { ... },
"organization_id": "org-...",
"result_files": [],
"status": "pending",
"validation_files": [],
"training_files": [ { ... } ],
"updated_at": 1614807352,
},
{ ... },
{ ... }
]
}
/fine-tunes/{fine_tune_id}:
get:
operationId: retrieveFineTune
tags:
- OpenAI
summary: |
Gets info about the fine-tune job.
[Learn more about Fine-tuning](/docs/guides/fine-tuning)
parameters:
- in: path
name: fine_tune_id
required: true
schema:
type: string
example:
ft-AF1WoRqd3aJAHsqc9NY7iL8F
description: |
The ID of the fine-tune job
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/FineTune'
x-oaiMeta:
name: Retrieve fine-tune
group: fine-tunes
path: retrieve
examples:
curl: |
curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.FineTune.retrieve(id="ft-AF1WoRqd3aJAHsqc9NY7iL8F")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.retrieveFineTune("ft-AF1WoRqd3aJAHsqc9NY7iL8F");
response: |
{
"id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F",
"object": "fine-tune",
"model": "curie",
"created_at": 1614807352,
"events": [
{
"object": "fine-tune-event",
"created_at": 1614807352,
"level": "info",
"message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
},
{
"object": "fine-tune-event",
"created_at": 1614807356,
"level": "info",
"message": "Job started."
},
{
"object": "fine-tune-event",
"created_at": 1614807861,
"level": "info",
"message": "Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20."
},
{
"object": "fine-tune-event",
"created_at": 1614807864,
"level": "info",
"message": "Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT."
},
{
"object": "fine-tune-event",
"created_at": 1614807864,
"level": "info",
"message": "Job succeeded."
}
],
"fine_tuned_model": "curie:ft-acmeco-2021-03-03-21-44-20",
"hyperparams": {
"batch_size": 4,
"learning_rate_multiplier": 0.1,
"n_epochs": 4,
"prompt_loss_weight": 0.1,
},
"organization_id": "org-...",
"result_files": [
{
"id": "file-QQm6ZpqdNwAaVC3aSz5sWwLT",
"object": "file",
"bytes": 81509,
"created_at": 1614807863,
"filename": "compiled_results.csv",
"purpose": "fine-tune-results"
}
],
"status": "succeeded",
"validation_files": [],
"training_files": [
{
"id": "file-XGinujblHPwGLSztz8cPS8XY",
"object": "file",
"bytes": 1547276,
"created_at": 1610062281,
"filename": "my-data-train.jsonl",
"purpose": "fine-tune-train"
}
],
"updated_at": 1614807865,
}
/fine-tunes/{fine_tune_id}/cancel:
post:
operationId: cancelFineTune
tags:
- OpenAI
summary: |
Immediately cancel a fine-tune job.
parameters:
- in: path
name: fine_tune_id
required: true
schema:
type: string
example:
ft-AF1WoRqd3aJAHsqc9NY7iL8F
description: |
The ID of the fine-tune job to cancel
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/FineTune'
x-oaiMeta:
name: Cancel fine-tune
group: fine-tunes
path: cancel
examples:
curl: |
curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.FineTune.cancel(id="ft-AF1WoRqd3aJAHsqc9NY7iL8F")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.cancelFineTune("ft-AF1WoRqd3aJAHsqc9NY7iL8F");
response: |
{
"id": "ft-xhrpBbvVUzYGo8oUO1FY4nI7",
"object": "fine-tune",
"model": "curie",
"created_at": 1614807770,
"events": [ { ... } ],
"fine_tuned_model": null,
"hyperparams": { ... },
"organization_id": "org-...",
"result_files": [],
"status": "cancelled",
"validation_files": [],
"training_files": [
{
"id": "file-XGinujblHPwGLSztz8cPS8XY",
"object": "file",
"bytes": 1547276,
"created_at": 1610062281,
"filename": "my-data-train.jsonl",
"purpose": "fine-tune-train"
}
],
"updated_at": 1614807789,
}
/fine-tunes/{fine_tune_id}/events:
get:
operationId: listFineTuneEvents
tags:
- OpenAI
summary: |
Get fine-grained status updates for a fine-tune job.
parameters:
- in: path
name: fine_tune_id
required: true
schema:
type: string
example:
ft-AF1WoRqd3aJAHsqc9NY7iL8F
description: |
The ID of the fine-tune job to get events for.
- in: query
name: stream
required: false
schema:
type: boolean
default: false
description: |
Whether to stream events for the fine-tune job. If set to true,
events will be sent as data-only
[server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
as they become available. The stream will terminate with a
`data: [DONE]` message when the job is finished (succeeded, cancelled,
or failed).
If set to false, only events generated so far will be returned.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListFineTuneEventsResponse'
x-oaiMeta:
name: List fine-tune events
group: fine-tunes
path: events
examples:
curl: |
curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.FineTune.list_events(id="ft-AF1WoRqd3aJAHsqc9NY7iL8F")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listFineTuneEvents("ft-AF1WoRqd3aJAHsqc9NY7iL8F");
response: |
{
"object": "list",
"data": [
{
"object": "fine-tune-event",
"created_at": 1614807352,
"level": "info",
"message": "Job enqueued. Waiting for jobs ahead to complete. Queue number: 0."
},
{
"object": "fine-tune-event",
"created_at": 1614807356,
"level": "info",
"message": "Job started."
},
{
"object": "fine-tune-event",
"created_at": 1614807861,
"level": "info",
"message": "Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20."
},
{
"object": "fine-tune-event",
"created_at": 1614807864,
"level": "info",
"message": "Uploaded result files: file-QQm6ZpqdNwAaVC3aSz5sWwLT."
},
{
"object": "fine-tune-event",
"created_at": 1614807864,
"level": "info",
"message": "Job succeeded."
}
]
}
/models:
get:
operationId: listModels
tags:
- OpenAI
summary: Lists the currently available models, and provides basic information about each one such as the owner and availability.
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListModelsResponse'
x-oaiMeta:
name: List models
group: models
path: list
examples:
curl: |
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.list()
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.listModels();
response: |
{
"data": [
{
"id": "model-id-0",
"object": "model",
"owned_by": "organization-owner",
"permission": [...]
},
{
"id": "model-id-1",
"object": "model",
"owned_by": "organization-owner",
"permission": [...]
},
{
"id": "model-id-2",
"object": "model",
"owned_by": "openai",
"permission": [...]
},
],
"object": "list"
}
/models/{model}:
get:
operationId: retrieveModel
tags:
- OpenAI
summary: Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
parameters:
- in: path
name: model
required: true
schema:
type: string
# ideally this will be an actual ID, so this will always work from browser
example:
text-davinci-001
description:
The ID of the model to use for this request
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Model'
x-oaiMeta:
name: Retrieve model
group: models
path: retrieve
examples:
curl: |
curl https://api.openai.com/v1/models/VAR_model_id \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.retrieve("VAR_model_id")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.retrieveModel("VAR_model_id");
response: |
{
"id": "VAR_model_id",
"object": "model",
"owned_by": "openai",
"permission": [...]
}
delete:
operationId: deleteModel
tags:
- OpenAI
summary: Delete a fine-tuned model. You must have the Owner role in your organization.
parameters:
- in: path
name: model
required: true
schema:
type: string
example: curie:ft-acmeco-2021-03-03-21-44-20
description: The model to delete
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteModelResponse'
x-oaiMeta:
name: Delete fine-tune model
group: fine-tunes
path: delete-model
examples:
curl: |
curl https://api.openai.com/v1/models/curie:ft-acmeco-2021-03-03-21-44-20 \
-X DELETE \
-H "Authorization: Bearer $OPENAI_API_KEY"
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Model.delete("curie:ft-acmeco-2021-03-03-21-44-20")
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.deleteModel('curie:ft-acmeco-2021-03-03-21-44-20');
response: |
{
"id": "curie:ft-acmeco-2021-03-03-21-44-20",
"object": "model",
"deleted": true
}
/moderations:
post:
operationId: createModeration
tags:
- OpenAI
summary: Classifies if text violates OpenAI's Content Policy
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateModerationRequest'
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateModerationResponse'
x-oaiMeta:
name: Create moderation
group: moderations
path: create
examples:
curl: |
curl https://api.openai.com/v1/moderations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"input": "I want to kill them."
}'
python: |
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Moderation.create(
input="I want to kill them.",
)
node.js: |
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createModeration({
input: "I want to kill them.",
});
parameters: |
{
"input": "I want to kill them."
}
response: |
{
"id": "modr-XXXXX",
"model": "text-moderation-005",
"results": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": false,
"harassment": false,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": true,
"violence": true,
},
"category_scores": {
"sexual": 1.2282071e-06,
"hate": 0.010696256,
"harassment": 0.29842457,
"self-harm": 1.5236925e-08,
"sexual/minors": 5.7246268e-08,
"hate/threatening": 0.0060676364,
"violence/graphic": 4.435014e-06,
"self-harm/intent": 8.098441e-10,
"self-harm/instructions": 2.8498655e-11,
"harassment/threatening": 0.63055265,
"violence": 0.99011886,
}
}
]
}
components:
schemas:
Error:
type: object
properties:
type:
type: string
nullable: false
message:
type: string
nullable: false
param:
type: string
nullable: true
code:
type: string
nullable: true
required:
- type
- message
- param
- code
ErrorResponse:
type: object
properties:
error:
$ref: '#/components/schemas/Error'
required:
- error
ListModelsResponse:
type: object
properties:
object:
type: string
data:
type: array
items:
$ref: '#/components/schemas/Model'
required:
- object
- data
DeleteModelResponse:
type: object
properties:
id:
type: string
object:
type: string
deleted:
type: boolean
required:
- id
- object
- deleted
CreateCompletionRequest:
type: object
properties:
model:
description: &model_description |
ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.
anyOf:
- type: string
- type: string
enum: ["text-davinci-003","text-davinci-002","text-davinci-001","code-davinci-002","text-curie-001","text-babbage-001","text-ada-001"]
x-oaiTypeLabel: string
prompt:
description: &completions_prompt_description |
The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.
default: '<|endoftext|>'
nullable: true
type: string
suffix:
description:
The suffix that comes after a completion of inserted text.
default: null
nullable: true
type: string
example: "test."
max_tokens:
type: integer
minimum: 0
default: 16
example: 16
nullable: true
description: &completions_max_tokens_description |
The maximum number of [tokens](/tokenizer) to generate in the completion.
The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.
temperature:
type: number
minimum: 0
maximum: 2
default: 1
example: 1
nullable: true
description: &completions_temperature_description |
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
We generally recommend altering this or `top_p` but not both.
top_p:
type: number
minimum: 0
maximum: 1
default: 1
example: 1
nullable: true
description: &completions_top_p_description |
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or `temperature` but not both.
n:
type: integer
minimum: 1
maximum: 128
default: 1
example: 1
nullable: true
description: &completions_completions_description |
How many completions to generate for each prompt.
**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.
stream:
description: >
Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).
type: boolean
nullable: true
default: false
logprobs: &completions_logprobs_configuration
type: integer
minimum: 0
maximum: 5
default: null
nullable: true
description: &completions_logprobs_description |
Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.
The maximum value for `logprobs` is 5.
echo:
type: boolean
default: false
nullable: true
description: &completions_echo_description >
Echo back the prompt in addition to the completion
stop:
description: &completions_stop_description >
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
default: null
nullable: true
oneOf:
- type: string
default: <|endoftext|>
example: "\n"
nullable: true
- type: array
minItems: 1
maxItems: 4
items:
type: string
example: '["\n"]'
presence_penalty:
type: number
default: 0
minimum: -2
maximum: 2
nullable: true
description: &completions_presence_penalty_description |
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
frequency_penalty:
type: number
default: 0
minimum: -2
maximum: 2
nullable: true
description: &completions_frequency_penalty_description |
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)
best_of:
type: integer
default: 1
minimum: 0
maximum: 20
nullable: true
description: &completions_best_of_description |
Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.
When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.
**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.
logit_bias: &completions_logit_bias
type: object
x-oaiTypeLabel: map
default: null
nullable: true
additionalProperties:
type: integer
description: &completions_logit_bias_description |
Modify the likelihood of specified tokens appearing in the completion.
Accepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.
user: &end_user_param_configuration
type: string
example: user-1234
description: |
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).
required:
- model
- prompt
CreateCompletionResponse:
type: object
properties:
id:
type: string
object:
type: string
created:
type: integer
model:
type: string
choices:
type: array
items:
type: object
required:
- text
- index
- logprobs
- finish_reason
properties:
text:
type: string
index:
type: integer
logprobs:
type: object
nullable: true
properties:
tokens:
type: array
items:
type: string
token_logprobs:
type: array
items:
type: number
top_logprobs:
type: array
items:
type: object
additionalProperties:
type: integer
text_offset:
type: array
items:
type: integer
finish_reason:
type: string
enum: ["stop", "length"]
usage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
required:
- prompt_tokens
- completion_tokens
- total_tokens
required:
- id
- object
- created
- model
- choices
ChatCompletionRequestMessage:
type: object
properties:
role:
type: string
enum: ["system", "user", "assistant", "function"]
description: The role of the messages author. One of `system`, `user`, `assistant`, or `function`.
content:
type: string
nullable: true
description: The contents of the message. `content` is required for all messages, and may be null for assistant messages with function calls.
name:
type: string
description: The name of the author of this message. `name` is required if role is `function`, and it should be the name of the function whose response is in the `content`. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
function_call:
type: object
description: The name and arguments of a function that should be called, as generated by the model.
properties:
name:
type: string
description: The name of the function to call.
arguments:
type: string
description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
required:
- name
- arguments
required:
- role
- content
ChatCompletionFunctionParameters:
type: object
description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nTo describe a function that accepts no parameters, provide the value `{\"type\": \"object\", \"properties\": {}}`."
additionalProperties: true
ChatCompletionFunctions:
type: object
properties:
name:
type: string
description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
description:
type: string
description: A description of what the function does, used by the model to choose when and how to call the function.
parameters:
$ref: '#/components/schemas/ChatCompletionFunctionParameters'
required:
- name
- parameters
ChatCompletionResponseMessage:
type: object
properties:
role:
type: string
enum: ["system", "user", "assistant", "function"]
description: The role of the author of this message.
content:
type: string
description: The contents of the message.
nullable: true
function_call:
type: object
description: The name and arguments of a function that should be called, as generated by the model.
properties:
name:
type: string
description: The name of the function to call.
arguments:
type: string
description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
required:
- role
ChatCompletionStreamResponseDelta:
type: object
properties:
role:
type: string
enum: ["system", "user", "assistant", "function"]
description: The role of the author of this message.
content:
type: string
description: The contents of the chunk message.
nullable: true
function_call:
type: object
description: The name and arguments of a function that should be called, as generated by the model.
properties:
name:
type: string
description: The name of the function to call.
arguments:
type: string
description: The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
CreateChatCompletionRequest:
type: object
properties:
model:
description: ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.
example: "gpt-3.5-turbo"
anyOf:
- type: string
- type: string
enum: ["gpt-4","gpt-4-0314","gpt-4-0613","gpt-4-32k","gpt-4-32k-0314","gpt-4-32k-0613","gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-3.5-turbo-0301","gpt-3.5-turbo-0613","gpt-3.5-turbo-16k-0613"]
x-oaiTypeLabel: string
messages:
description: A list of messages comprising the conversation so far. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb).
type: array
minItems: 1
items:
$ref: '#/components/schemas/ChatCompletionRequestMessage'
functions:
description: A list of functions the model may generate JSON inputs for.
type: array
minItems: 1
items:
$ref: '#/components/schemas/ChatCompletionFunctions'
function_call:
description: Controls how the model responds to function calls. "none" means the model does not call a function, and responds to the end-user. "auto" means the model can pick between an end-user or calling a function. Specifying a particular function via `{"name":\ "my_function"}` forces the model to call that function. "none" is the default when no functions are present. "auto" is the default if functions are present.
oneOf:
- type: string
enum: [none, auto]
- type: object
properties:
name:
type: string
description: The name of the function to call.
required:
- name
temperature:
type: number
minimum: 0
maximum: 2
default: 1
example: 1
nullable: true
description: *completions_temperature_description
top_p:
type: number
minimum: 0
maximum: 1
default: 1
example: 1
nullable: true
description: *completions_top_p_description
n:
type: integer
minimum: 1
maximum: 128
default: 1
example: 1
nullable: true
description: How many chat completion choices to generate for each input message.
stream:
description: >
If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).
type: boolean
nullable: true
default: false
stop:
description: |
Up to 4 sequences where the API will stop generating further tokens.
default: null
oneOf:
- type: string
nullable: true
- type: array
minItems: 1
maxItems: 4
items:
type: string
max_tokens:
description: |
The maximum number of [tokens](/tokenizer) to generate in the chat completion.
The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.
default: inf
type: integer
presence_penalty:
type: number
default: 0
minimum: -2
maximum: 2
nullable: true
description: *completions_presence_penalty_description
frequency_penalty:
type: number
default: 0
minimum: -2
maximum: 2
nullable: true
description: *completions_frequency_penalty_description
logit_bias:
type: object
x-oaiTypeLabel: map
default: null
nullable: true
additionalProperties:
type: integer
description: |
Modify the likelihood of specified tokens appearing in the completion.
Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
user: *end_user_param_configuration
required:
- model
- messages
CreateChatCompletionResponse:
type: object
properties:
id:
type: string
object:
type: string
created:
type: integer
model:
type: string
choices:
type: array
items:
type: object
required:
- index
- message
- finish_reason
properties:
index:
type: integer
message:
$ref: '#/components/schemas/ChatCompletionResponseMessage'
finish_reason:
type: string
enum: ["stop", "length", "function_call"]
usage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
required:
- prompt_tokens
- completion_tokens
- total_tokens
required:
- id
- object
- created
- model
- choices
CreateChatCompletionStreamResponse:
type: object
properties:
id:
type: string
object:
type: string
created:
type: integer
model:
type: string
choices:
type: array
items:
type: object
required:
- index
- delta
- finish_reason
properties:
index:
type: integer
delta:
$ref: '#/components/schemas/ChatCompletionStreamResponseDelta'
finish_reason:
type: string
enum: ["stop", "length", "function_call"]
nullable: true
required:
- id
- object
- created
- model
- choices
CreateEditRequest:
type: object
properties:
model:
description: ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint.
example: "text-davinci-edit-001"
anyOf:
- type: string
- type: string
enum: ["text-davinci-edit-001","code-davinci-edit-001"]
x-oaiTypeLabel: string
input:
description:
The input text to use as a starting point for the edit.
type: string
default: ''
nullable: true
example: "What day of the wek is it?"
instruction:
description:
The instruction that tells the model how to edit the prompt.
type: string
example: "Fix the spelling mistakes."
n:
type: integer
minimum: 1
maximum: 20
default: 1
example: 1
nullable: true
description:
How many edits to generate for the input and instruction.
temperature:
type: number
minimum: 0
maximum: 2
default: 1
example: 1
nullable: true
description: *completions_temperature_description
top_p:
type: number
minimum: 0
maximum: 1
default: 1
example: 1
nullable: true
description: *completions_top_p_description
required:
- model
- instruction
CreateEditResponse:
type: object
properties:
object:
type: string
created:
type: integer
choices:
type: array
items:
type: object
required:
- text
- index
- finish_reason
properties:
text:
type: string
index:
type: integer
finish_reason:
type: string
enum: ["stop", "length"]
usage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
required:
- prompt_tokens
- completion_tokens
- total_tokens
required:
- object
- created
- choices
- usage
CreateImageRequest:
type: object
properties:
prompt:
description: A text description of the desired image(s). The maximum length is 1000 characters.
type: string
example: "A cute baby sea otter"
n: &images_n
type: integer
minimum: 1
maximum: 10
default: 1
example: 1
nullable: true
description: The number of images to generate. Must be between 1 and 10.
size: &images_size
type: string
enum: ["256x256", "512x512", "1024x1024"]
default: "1024x1024"
example: "1024x1024"
nullable: true
description: The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
response_format: &images_response_format
type: string
enum: ["url", "b64_json"]
default: "url"
example: "url"
nullable: true
description: The format in which the generated images are returned. Must be one of `url` or `b64_json`.
user: *end_user_param_configuration
required:
- prompt
ImagesResponse:
properties:
created:
type: integer
data:
type: array
items:
type: object
properties:
url:
type: string
b64_json:
type: string
required:
- created
- data
CreateImageEditRequest:
type: object
properties:
image:
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.
type: string
format: binary
mask:
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`.
type: string
format: binary
prompt:
description: A text description of the desired image(s). The maximum length is 1000 characters.
type: string
example: "A cute baby sea otter wearing a beret"
n: *images_n
size: *images_size
response_format: *images_response_format
user: *end_user_param_configuration
required:
- prompt
- image
CreateImageVariationRequest:
type: object
properties:
image:
description: The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
type: string
format: binary
n: *images_n
size: *images_size
response_format: *images_response_format
user: *end_user_param_configuration
required:
- image
CreateModerationRequest:
type: object
properties:
input:
description: The input text to classify
oneOf:
- type: string
default: ''
example: "I want to kill them."
- type: array
items:
type: string
default: ''
example: "I want to kill them."
model:
description: |
Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`.
The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`.
nullable: false
default: "text-moderation-latest"
example: "text-moderation-stable"
type: string
enum:
- "text-moderation-stable"
- "text-moderation-latest"
x-oaiTypeLabel: string
required:
- input
CreateModerationResponse:
type: object
properties:
id:
type: string
model:
type: string
results:
type: array
items:
type: object
properties:
flagged:
type: boolean
categories:
type: object
properties:
hate:
type: boolean
hate/threatening:
type: boolean
self-harm:
type: boolean
sexual:
type: boolean
sexual/minors:
type: boolean
violence:
type: boolean
violence/graphic:
type: boolean
required:
- hate
- hate/threatening
- self-harm
- sexual
- sexual/minors
- violence
- violence/graphic
category_scores:
type: object
properties:
hate:
type: number
hate/threatening:
type: number
self-harm:
type: number
sexual:
type: number
sexual/minors:
type: number
violence:
type: number
violence/graphic:
type: number
required:
- hate
- hate/threatening
- self-harm
- sexual
- sexual/minors
- violence
- violence/graphic
required:
- flagged
- categories
- category_scores
required:
- id
- model
- results
ListFilesResponse:
type: object
properties:
object:
type: string
data:
type: array
items:
$ref: '#/components/schemas/OpenAIFile'
required:
- object
- data
CreateFileRequest:
type: object
additionalProperties: false
properties:
file:
description: |
Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded.
If the `purpose` is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).
type: string
format: binary
purpose:
description: |
The intended purpose of the uploaded documents.
Use "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.
type: string
required:
- file
- purpose
DeleteFileResponse:
type: object
properties:
id:
type: string
object:
type: string
deleted:
type: boolean
required:
- id
- object
- deleted
CreateFineTuneRequest:
type: object
properties:
training_file:
description: |
The ID of an uploaded file that contains training data.
See [upload file](/docs/api-reference/files/upload) for how to upload a file.
Your dataset must be formatted as a JSONL file, where each training
example is a JSON object with the keys "prompt" and "completion".
Additionally, you must upload your file with the purpose `fine-tune`.
See the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.
type: string
example: "file-ajSREls59WBbvgSzJSVWxMCB"
validation_file:
description: |
The ID of an uploaded file that contains validation data.
If you provide this file, the data is used to generate validation
metrics periodically during fine-tuning. These metrics can be viewed in
the [fine-tuning results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).
Your train and validation data should be mutually exclusive.
Your dataset must be formatted as a JSONL file, where each validation
example is a JSON object with the keys "prompt" and "completion".
Additionally, you must upload your file with the purpose `fine-tune`.
See the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.
type: string
nullable: true
example: "file-XjSREls59WBbvgSzJSVWxMCa"
model:
description: |
The name of the base model to fine-tune. You can select one of "ada",
"babbage", "curie", "davinci", or a fine-tuned model created after 2022-04-21.
To learn more about these models, see the
[Models](https://platform.openai.com/docs/models) documentation.
default: "curie"
example: "curie"
nullable: true
type: string
enum: ["ada","babbage","curie","davinci"]
x-oaiTypeLabel: string
n_epochs:
description: |
The number of epochs to train the model for. An epoch refers to one
full cycle through the training dataset.
default: 4
type: integer
nullable: true
batch_size:
description: |
The batch size to use for training. The batch size is the number of
training examples used to train a single forward and backward pass.
By default, the batch size will be dynamically configured to be
~0.2% of the number of examples in the training set, capped at 256 -
in general, we've found that larger batch sizes tend to work better
for larger datasets.
default: null
type: integer
nullable: true
learning_rate_multiplier:
description: |
The learning rate multiplier to use for training.
The fine-tuning learning rate is the original learning rate used for
pretraining multiplied by this value.
By default, the learning rate multiplier is the 0.05, 0.1, or 0.2
depending on final `batch_size` (larger learning rates tend to
perform better with larger batch sizes). We recommend experimenting
with values in the range 0.02 to 0.2 to see what produces the best
results.
default: null
type: number
nullable: true
prompt_loss_weight:
description: |
The weight to use for loss on the prompt tokens. This controls how
much the model tries to learn to generate the prompt (as compared
to the completion which always has a weight of 1.0), and can add
a stabilizing effect to training when completions are short.
If prompts are extremely long (relative to completions), it may make
sense to reduce this weight so as to avoid over-prioritizing
learning the prompt.
default: 0.01
type: number
nullable: true
compute_classification_metrics:
description: |
If set, we calculate classification-specific metrics such as accuracy
and F-1 score using the validation set at the end of every epoch.
These metrics can be viewed in the [results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).
In order to compute classification metrics, you must provide a
`validation_file`. Additionally, you must
specify `classification_n_classes` for multiclass classification or
`classification_positive_class` for binary classification.
type: boolean
default: false
nullable: true
classification_n_classes:
description: |
The number of classes in a classification task.
This parameter is required for multiclass classification.
type: integer
default: null
nullable: true
classification_positive_class:
description: |
The positive class in binary classification.
This parameter is needed to generate precision, recall, and F1
metrics when doing binary classification.
type: string
default: null
nullable: true
classification_betas:
description: |
If this is provided, we calculate F-beta scores at the specified
beta values. The F-beta score is a generalization of F-1 score.
This is only used for binary classification.
With a beta of 1 (i.e. the F-1 score), precision and recall are
given the same weight. A larger beta score puts more weight on
recall and less on precision. A smaller beta score puts more weight
on precision and less on recall.
type: array
items:
type: number
example: [0.6, 1, 1.5, 2]
default: null
nullable: true
suffix:
description: |
A string of up to 40 characters that will be added to your fine-tuned model name.
For example, a `suffix` of "custom-model-name" would produce a model name like `ada:ft-your-org:custom-model-name-2022-02-15-04-21-04`.
type: string
minLength: 1
maxLength: 40
default: null
nullable: true
required:
- training_file
ListFineTunesResponse:
type: object
properties:
object:
type: string
data:
type: array
items:
$ref: '#/components/schemas/FineTune'
required:
- object
- data
ListFineTuneEventsResponse:
type: object
properties:
object:
type: string
data:
type: array
items:
$ref: '#/components/schemas/FineTuneEvent'
required:
- object
- data
CreateEmbeddingRequest:
type: object
additionalProperties: false
properties:
model:
description: *model_description
example: "text-embedding-ada-002"
type: string
enum: ["text-embedding-ada-002"]
x-oaiTypeLabel: string
input:
description: |
Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed the max input tokens for the model (8191 tokens for `text-embedding-ada-002`). [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.
example: "The quick brown fox jumped over the lazy dog"
oneOf:
- type: string
default: ''
example: "This is a test."
- type: array
items:
type: string
default: ''
example: "This is a test."
- type: array
minItems: 1
items:
type: integer
example: "[1212, 318, 257, 1332, 13]"
- type: array
minItems: 1
items:
type: array
minItems: 1
items:
type: integer
example: "[[1212, 318, 257, 1332, 13]]"
user: *end_user_param_configuration
required:
- model
- input
CreateEmbeddingResponse:
type: object
properties:
object:
type: string
model:
type: string
data:
type: array
items:
type: object
properties:
index:
type: integer
object:
type: string
embedding:
type: array
items:
type: number
required:
- index
- object
- embedding
usage:
type: object
properties:
prompt_tokens:
type: integer
total_tokens:
type: integer
required:
- prompt_tokens
- total_tokens
required:
- object
- model
- data
- usage
CreateTranscriptionRequest:
type: object
additionalProperties: false
properties:
file:
description: |
The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
type: string
x-oaiTypeLabel: file
format: binary
model:
description: |
ID of the model to use. Only `whisper-1` is currently available.
example: whisper-1
anyOf:
- type: string
- type: string
enum: ["whisper-1"]
x-oaiTypeLabel: string
prompt:
description: |
An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.
type: string
response_format:
description: |
The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
type: string
enum:
- json
- text
- srt
- verbose_json
- vtt
default: json
temperature:
description: |
The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
type: number
default: 0
language:
description: |
The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.
type: string
required:
- file
- model
# Note: This does not currently support the non-default response format types.
CreateTranscriptionResponse:
type: object
properties:
text:
type: string
required:
- text
CreateTranslationRequest:
type: object
additionalProperties: false
properties:
file:
description: |
The audio file object (not file name) translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.
type: string
x-oaiTypeLabel: file
format: binary
model:
description: |
ID of the model to use. Only `whisper-1` is currently available.
example: whisper-1
anyOf:
- type: string
- type: string
enum: ["whisper-1"]
x-oaiTypeLabel: string
prompt:
description: |
An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.
type: string
response_format:
description: |
The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.
type: string
default: json
temperature:
description: |
The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.
type: number
default: 0
required:
- file
- model
# Note: This does not currently support the non-default response format types.
CreateTranslationResponse:
type: object
properties:
text:
type: string
required:
- text
Model:
title: Model
properties:
id:
type: string
object:
type: string
created:
type: integer
owned_by:
type: string
required:
- id
- object
- created
- owned_by
OpenAIFile:
title: OpenAIFile
properties:
id:
type: string
object:
type: string
bytes:
type: integer
created_at:
type: integer
filename:
type: string
purpose:
type: string
status:
type: string
status_details:
type: string
nullable: true
required:
- id
- object
- bytes
- created_at
- filename
- purpose
FineTune:
title: FineTune
properties:
id:
type: string
object:
type: string
created_at:
type: integer
updated_at:
type: integer
model:
type: string
fine_tuned_model:
type: string
nullable: true
organization_id:
type: string
status:
type: string
hyperparams:
type: object
properties:
n_epochs:
type: integer
batch_size:
type: integer
prompt_loss_weight:
type: number
learning_rate_multiplier:
type: number
compute_classification_metrics:
type: boolean
classification_positive_class:
type: string
classification_n_classes:
type: integer
required:
- n_epochs
- batch_size
- prompt_loss_weight
- learning_rate_multiplier
training_files:
type: array
items:
$ref: '#/components/schemas/OpenAIFile'
validation_files:
type: array
items:
$ref: '#/components/schemas/OpenAIFile'
result_files:
type: array
items:
$ref: '#/components/schemas/OpenAIFile'
events:
type: array
items:
$ref: '#/components/schemas/FineTuneEvent'
required:
- id
- object
- created_at
- updated_at
- model
- fine_tuned_model
- organization_id
- status
- hyperparams
- training_files
- validation_files
- result_files
FineTuneEvent:
title: FineTuneEvent
properties:
object:
type: string
created_at:
type: integer
level:
type: string
message:
type: string
required:
- object
- created_at
- level
- message
x-oaiMeta:
groups:
- id: models
title: Models
description: |
List and describe the various models available in the API. You can refer to the [Models](/docs/models) documentation to understand what models are available and the differences between them.
- id: chat
title: Chat
description: |
Given a list of messages comprising a conversation, the model will return a response.
- id: completions
title: Completions
description: |
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position. Note: We recommend most users use our Chat Completions API. [Learn more](/docs/deprecations/2023-07-06-gpt-and-embeddings)
- id: images
title: Images
description: |
Given a prompt and/or an input image, the model will generate a new image.
Related guide: [Image generation](/docs/guides/images)
- id: embeddings
title: Embeddings
description: |
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
Related guide: [Embeddings](/docs/guides/embeddings)
- id: audio
title: Audio
description: |
Learn how to turn audio into text.
Related guide: [Speech to text](/docs/guides/speech-to-text)
- id: files
title: Files
description: |
Files are used to upload documents that can be used with features like [Fine-tuning](/docs/api-reference/fine-tunes).
- id: fine-tunes
title: Fine-tunes
description: |
Manage fine-tuning jobs to tailor a model to your specific training data.
Related guide: [Fine-tune models](/docs/guides/fine-tuning)
- id: moderations
title: Moderations
description: |
Given a input text, outputs if the model classifies it as violating OpenAI's content policy.
Related guide: [Moderations](/docs/guides/moderation)
- id: edits
title: Edits
description: |
Given a prompt and an instruction, the model will return an edited version of the prompt.