{ "openapi": "3.0.0", "info": { "title": "OpenAI API", "description": "The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.", "version": "2.0.0", "termsOfService": "https://openai.com/policies/terms-of-use", "contact": { "name": "OpenAI Support", "url": "https://help.openai.com/" }, "license": { "name": "MIT", "url": "https://github.com/openai/openai-openapi/blob/master/LICENSE" } }, "servers": [ { "url": "https://api.openai.com/v1" } ], "tags": [ { "name": "Assistants", "description": "Build Assistants that can call models and use tools." }, { "name": "Audio", "description": "Learn how to turn audio into text or text into audio." }, { "name": "Chat", "description": "Given a list of messages comprising a conversation, the model will return a response." }, { "name": "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." }, { "name": "Embeddings", "description": "Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms." }, { "name": "Fine-tuning", "description": "Manage fine-tuning jobs to tailor a model to your specific training data." }, { "name": "Files", "description": "Files are used to upload documents that can be used with features like Assistants and Fine-tuning." }, { "name": "Images", "description": "Given a prompt and/or an input image, the model will generate a new image." }, { "name": "Models", "description": "List and describe the various models available in the API." }, { "name": "Moderations", "description": "Given a input text, outputs if the model classifies it as violating OpenAI's content policy." }, { "name": "Fine-tunes", "description": "Manage legacy fine-tuning jobs to tailor a model to your specific training data." }, { "name": "Edits", "description": "Given a prompt and an instruction, the model will return an edited version of the prompt." } ], "paths": { "/chat/completions": { "post": { "operationId": "createChatCompletion", "tags": [ "Chat" ], "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", "returns": "Returns a [chat completion](/docs/api-reference/chat/object) object, or a streamed sequence of [chat completion chunk](/docs/api-reference/chat/streaming) objects if the request is streamed.\n", "path": "create", "examples": [ { "title": "Default", "request": { "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ]\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=[\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ]\n)\n\nprint(completion.choices[0].message)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n messages: [{ role: \"system\", content: \"You are a helpful assistant.\" }],\n model: \"VAR_model_id\",\n });\n\n console.log(completion.choices[0]);\n}\n\nmain();" }, "response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" }, { "title": "Image input", "request": { "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"gpt-4-vision-preview\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"What’s in this image?\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\"\n }\n }\n ]\n }\n ],\n \"max_tokens\": 300\n }'\n", "python": "from openai import OpenAI\n\nclient = OpenAI()\n\nresponse = client.chat.completions.create(\n model=\"gpt-4-vision-preview\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"text\", \"text\": \"What’s in this image?\"},\n {\n \"type\": \"image_url\",\n \"image_url\": \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n },\n ],\n }\n ],\n max_tokens=300,\n)\n\nprint(response.choices[0])\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.chat.completions.create({\n model: \"gpt-4-vision-preview\",\n messages: [\n {\n role: \"user\",\n content: [\n { type: \"text\", text: \"What’s in this image?\" },\n {\n type: \"image_url\",\n image_url:\n \"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg\",\n },\n ],\n },\n ],\n });\n console.log(response.choices[0]);\n}\nmain();" }, "response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" }, { "title": "Streaming", "request": { "curl": "curl https://api.openai.com/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"stream\": true\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=[\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ],\n stream=True\n)\n\nfor chunk in completion:\n print(chunk.choices[0].delta)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.chat.completions.create({\n model: \"VAR_model_id\",\n messages: [\n {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n {\"role\": \"user\", \"content\": \"Hello!\"}\n ],\n stream: true,\n });\n\n for await (const chunk of completion) {\n console.log(chunk.choices[0].delta.content);\n }\n}\n\nmain();" }, "response": "{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n....\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\" today\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n" }, { "title": "Functions", "request": { "curl": "curl https://api.openai.com/v1/chat/completions \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n-d '{\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"What is the weather like in Boston?\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n }\n ],\n \"tool_choice\": \"auto\"\n}'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\ntools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n }\n]\nmessages = [{\"role\": \"user\", \"content\": \"What's the weather like in Boston today?\"}]\ncompletion = client.chat.completions.create(\n model=\"VAR_model_id\",\n messages=messages,\n tools=tools,\n tool_choice=\"auto\"\n)\n\nprint(completion)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const messages = [{\"role\": \"user\", \"content\": \"What's the weather like in Boston today?\"}];\n const tools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n }\n ];\n\n const response = await openai.chat.completions.create({\n model: \"gpt-3.5-turbo\",\n messages: messages,\n tools: tools,\n tool_choice: \"auto\",\n });\n\n console.log(response);\n}\n\nmain();" }, "response": "{\n \"id\": \"chatcmpl-abc123\",\n \"object\": \"chat.completion\",\n \"created\": 1699896916,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n \"id\": \"call_abc123\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\n\\\"location\\\": \\\"Boston, MA\\\"\\n}\"\n }\n }\n ]\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 82,\n \"completion_tokens\": 17,\n \"total_tokens\": 99\n }\n}\n" } ] } } }, "/completions": { "post": { "operationId": "createCompletion", "tags": [ "Completions" ], "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", "returns": "Returns a [completion](/docs/api-reference/completions/object) object, or a sequence of completion objects if the request is streamed.\n", "legacy": true, "examples": [ { "title": "No streaming", "request": { "curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.completions.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const completion = await openai.completions.create({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test.\",\n max_tokens: 7,\n temperature: 0,\n });\n\n console.log(completion);\n}\nmain();" }, "response": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"VAR_model_id\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [\n {\n \"text\": \"\\n\\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n" }, { "title": "Streaming", "request": { "curl": "curl https://api.openai.com/v1/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0,\n \"stream\": true\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nfor chunk in client.completions.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0,\n stream=True\n):\n print(chunk.choices[0].text)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.completions.create({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test.\",\n stream: true,\n });\n\n for await (const chunk of stream) {\n console.log(chunk.choices[0].text)\n }\n}\nmain();" }, "response": "{\n \"id\": \"cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe\",\n \"object\": \"text_completion\",\n \"created\": 1690759702,\n \"choices\": [\n {\n \"text\": \"This\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": null\n }\n ],\n \"model\": \"gpt-3.5-turbo-instruct\"\n \"system_fingerprint\": \"fp_44709d6fcb\",\n}\n" } ] } } }, "/edits": { "post": { "operationId": "createEdit", "deprecated": true, "tags": [ "Edits" ], "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", "returns": "Returns an [edit](/docs/api-reference/edits/object) object.\n", "group": "edits", "examples": { "request": { "curl": "curl https://api.openai.com/v1/edits \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"VAR_model_id\",\n \"input\": \"What day of the wek is it?\",\n \"instruction\": \"Fix the spelling mistakes\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.edits.create(\n model=\"VAR_model_id\",\n input=\"What day of the wek is it?\",\n instruction=\"Fix the spelling mistakes\"\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const edit = await openai.edits.create({\n model: \"VAR_model_id\",\n input: \"What day of the wek is it?\",\n instruction: \"Fix the spelling mistakes.\",\n });\n\n console.log(edit);\n}\n\nmain();" }, "response": "{\n \"object\": \"edit\",\n \"created\": 1589478378,\n \"choices\": [\n {\n \"text\": \"What day of the week is it?\",\n \"index\": 0,\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 25,\n \"completion_tokens\": 32,\n \"total_tokens\": 57\n }\n}\n" } } } }, "/images/generations": { "post": { "operationId": "createImage", "tags": [ "Images" ], "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", "returns": "Returns a list of [image](/docs/api-reference/images/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/images/generations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"model\": \"dall-e-3\",\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 1,\n \"size\": \"1024x1024\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.images.generate(\n model=\"dall-e-3\",\n prompt=\"A cute baby sea otter\",\n n=1,\n size=\"1024x1024\"\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.generate({ model: \"dall-e-3\", prompt: \"A cute baby sea otter\" });\n\n console.log(image.data);\n}\nmain();" }, "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" } } } }, "/images/edits": { "post": { "operationId": "createImageEdit", "tags": [ "Images" ], "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", "returns": "Returns a list of [image](/docs/api-reference/images/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/images/edits \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F image=\"@otter.png\" \\\n -F mask=\"@mask.png\" \\\n -F prompt=\"A cute baby sea otter wearing a beret\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.images.edit(\n image=open(\"otter.png\", \"rb\"),\n mask=open(\"mask.png\", \"rb\"),\n prompt=\"A cute baby sea otter wearing a beret\",\n n=2,\n size=\"1024x1024\"\n)\n", "node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.edit({\n image: fs.createReadStream(\"otter.png\"),\n mask: fs.createReadStream(\"mask.png\"),\n prompt: \"A cute baby sea otter wearing a beret\",\n });\n\n console.log(image.data);\n}\nmain();" }, "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" } } } }, "/images/variations": { "post": { "operationId": "createImageVariation", "tags": [ "Images" ], "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", "returns": "Returns a list of [image](/docs/api-reference/images/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/images/variations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F image=\"@otter.png\" \\\n -F n=2 \\\n -F size=\"1024x1024\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nresponse = client.images.create_variation(\n image=open(\"image_edit_original.png\", \"rb\"),\n n=2,\n size=\"1024x1024\"\n)\n", "node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const image = await openai.images.createVariation({\n image: fs.createReadStream(\"otter.png\"),\n });\n\n console.log(image.data);\n}\nmain();" }, "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" } } } }, "/embeddings": { "post": { "operationId": "createEmbedding", "tags": [ "Embeddings" ], "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", "returns": "A list of [embedding](/docs/api-reference/embeddings/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/embeddings \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"input\": \"The food was delicious and the waiter...\",\n \"model\": \"text-embedding-ada-002\",\n \"encoding_format\": \"float\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.embeddings.create(\n model=\"text-embedding-ada-002\",\n input=\"The food was delicious and the waiter...\",\n encoding_format=\"float\"\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const embedding = await openai.embeddings.create({\n model: \"text-embedding-ada-002\",\n input: \"The quick brown fox jumped over the lazy dog\",\n encoding_format: \"float\",\n });\n\n console.log(embedding);\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222,\n ],\n \"index\": 0\n }\n ],\n \"model\": \"text-embedding-ada-002\",\n \"usage\": {\n \"prompt_tokens\": 8,\n \"total_tokens\": 8\n }\n}\n" } } } }, "/audio/speech": { "post": { "operationId": "createSpeech", "tags": [ "Audio" ], "summary": "Generates audio from the input text.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateSpeechRequest" } } } }, "responses": { "200": { "description": "OK", "headers": { "Transfer-Encoding": { "schema": { "type": "string" }, "description": "chunked" } }, "content": { "application/octet-stream": { "schema": { "type": "string", "format": "binary" } } } } }, "x-oaiMeta": { "name": "Create speech", "group": "audio", "returns": "The audio file content.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/audio/speech \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"model\": \"tts-1\",\n \"input\": \"The quick brown fox jumped over the lazy dog.\",\n \"voice\": \"alloy\"\n }' \\\n --output speech.mp3\n", "python": "from pathlib import Path\nimport openai\n\nspeech_file_path = Path(__file__).parent / \"speech.mp3\"\nresponse = openai.audio.speech.create(\n model=\"tts-1\",\n voice=\"alloy\",\n input=\"The quick brown fox jumped over the lazy dog.\"\n)\nresponse.stream_to_file(speech_file_path)\n", "node": "import fs from \"fs\";\nimport path from \"path\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst speechFile = path.resolve(\"./speech.mp3\");\n\nasync function main() {\n const mp3 = await openai.audio.speech.create({\n model: \"tts-1\",\n voice: \"alloy\",\n input: \"Today is a wonderful day to build something people love!\",\n });\n console.log(speechFile);\n const buffer = Buffer.from(await mp3.arrayBuffer());\n await fs.promises.writeFile(speechFile, buffer);\n}\nmain();\n" } } } } }, "/audio/transcriptions": { "post": { "operationId": "createTranscription", "tags": [ "Audio" ], "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", "returns": "The transcribed text.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/audio/transcriptions \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/audio.mp3\" \\\n -F model=\"whisper-1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\naudio_file = open(\"speech.mp3\", \"rb\")\ntranscript = client.audio.transcriptions.create(\n model=\"whisper-1\",\n file=audio_file\n)\n", "node": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const transcription = await openai.audio.transcriptions.create({\n file: fs.createReadStream(\"audio.mp3\"),\n model: \"whisper-1\",\n });\n\n console.log(transcription.text);\n}\nmain();\n" }, "response": "{\n \"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.\"\n}\n" } } } }, "/audio/translations": { "post": { "operationId": "createTranslation", "tags": [ "Audio" ], "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", "returns": "The translated text.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/audio/translations \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F file=\"@/path/to/file/german.m4a\" \\\n -F model=\"whisper-1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\naudio_file = open(\"speech.mp3\", \"rb\")\ntranscript = client.audio.translations.create(\n model=\"whisper-1\",\n file=audio_file\n)\n", "node": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const translation = await openai.audio.translations.create({\n file: fs.createReadStream(\"speech.mp3\"),\n model: \"whisper-1\",\n });\n\n console.log(translation.text);\n}\nmain();\n" }, "response": "{\n \"text\": \"Hello, my name is Wolfgang and I come from Germany. Where are you heading today?\"\n}\n" } } } }, "/files": { "get": { "operationId": "listFiles", "tags": [ "Files" ], "summary": "Returns a list of files that belong to the user's organization.", "parameters": [ { "in": "query", "name": "purpose", "required": false, "schema": { "type": "string" }, "description": "Only return files with the given purpose." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListFilesResponse" } } } } }, "x-oaiMeta": { "name": "List files", "group": "files", "returns": "A list of [File](/docs/api-reference/files/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.list()\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.files.list();\n\n for await (const file of list) {\n console.log(file);\n }\n}\n\nmain();" }, "response": "{\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 175,\n \"created_at\": 1613677385,\n \"filename\": \"salesOverview.pdf\",\n \"purpose\": \"assistants\",\n },\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"puppy.jsonl\",\n \"purpose\": \"fine-tune\",\n }\n ],\n \"object\": \"list\"\n}\n" } } }, "post": { "operationId": "createFile", "tags": [ "Files" ], "summary": "Upload a file that can be used across various endpoints. The size of all the files uploaded by one organization can be up to 100 GB.\n\nThe size of individual files can be a maximum of 512 MB or 2 million tokens for Assistants. See the [Assistants Tools guide](/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files.\n\nPlease [contact us](https://help.openai.com/) if you need to increase these storage limits.\n", "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", "returns": "The uploaded [File](/docs/api-reference/files/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -F purpose=\"fine-tune\" \\\n -F file=\"@mydata.jsonl\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.create(\n file=open(\"mydata.jsonl\", \"rb\"),\n purpose=\"fine-tune\"\n)\n", "node.js": "import fs from \"fs\";\nimport OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.create({\n file: fs.createReadStream(\"mydata.jsonl\"),\n purpose: \"fine-tune\",\n });\n\n console.log(file);\n}\n\nmain();" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n" } } } }, "/files/{file_id}": { "delete": { "operationId": "deleteFile", "tags": [ "Files" ], "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", "returns": "Deletion status.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/files/file-abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.delete(\"file-abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.del(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"deleted\": true\n}\n" } } }, "get": { "operationId": "retrieveFile", "tags": [ "Files" ], "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", "returns": "The [File](/docs/api-reference/files/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/files/file-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.files.retrieve(\"file-abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.retrieve(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\",\n}\n" } } } }, "/files/{file_id}/content": { "get": { "operationId": "downloadFile", "tags": [ "Files" ], "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", "returns": "The file content.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/files/file-abc123/content \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\ncontent = client.files.retrieve_content(\"file-abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const file = await openai.files.retrieveContent(\"file-abc123\");\n\n console.log(file);\n}\n\nmain();\n" } } } } }, "/fine_tuning/jobs": { "post": { "operationId": "createFineTuningJob", "tags": [ "Fine-tuning" ], "summary": "Creates a job that fine-tunes a specified model from a given dataset.\n\nResponse includes details of the enqueued job including job status and the name of the fine-tuned models once complete.\n\n[Learn more about fine-tuning](/docs/guides/fine-tuning)\n", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateFineTuningJobRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FineTuningJob" } } } } }, "x-oaiMeta": { "name": "Create fine-tuning job", "group": "fine-tuning", "returns": "A [fine-tuning.job](/docs/api-reference/fine-tuning/object) object.", "examples": [ { "title": "Default", "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-BK7bzQj3FfZFXr7DbL6xJwfo\",\n \"model\": \"gpt-3.5-turbo\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\",\n model=\"gpt-3.5-turbo\"\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n}\n" }, { "title": "Epochs", "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"model\": \"gpt-3.5-turbo\",\n \"hyperparameters\": {\n \"n_epochs\": 2\n }\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\",\n model=\"gpt-3.5-turbo\",\n hyperparameters={\n \"n_epochs\":2\n }\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n model: \"gpt-3.5-turbo\",\n hyperparameters: { n_epochs: 2 }\n });\n\n console.log(fineTune);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\"n_epochs\": 2},\n}\n" }, { "title": "Validation file", "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\",\n \"validation_file\": \"file-abc123\",\n \"model\": \"gpt-3.5-turbo\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.create(\n training_file=\"file-abc123\",\n validation_file=\"file-def456\",\n model=\"gpt-3.5-turbo\"\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.create({\n training_file: \"file-abc123\",\n validation_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"queued\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\",\n}\n" } ] } }, "get": { "operationId": "listPaginatedFineTuningJobs", "tags": [ "Fine-tuning" ], "summary": "List your organization's fine-tuning jobs\n", "parameters": [ { "name": "after", "in": "query", "description": "Identifier for the last job from the previous pagination request.", "required": false, "schema": { "type": "string" } }, { "name": "limit", "in": "query", "description": "Number of fine-tuning jobs to retrieve.", "required": false, "schema": { "type": "integer", "default": 20 } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListPaginatedFineTuningJobsResponse" } } } } }, "x-oaiMeta": { "name": "List fine-tuning jobs", "group": "fine-tuning", "returns": "A list of paginated [fine-tuning job](/docs/api-reference/fine-tuning/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs?limit=2 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.list()\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.jobs.list();\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-TjX0lMfOniCZX64t9PUQT5hn\",\n \"created_at\": 1689813489,\n \"level\": \"warn\",\n \"message\": \"Fine tuning process stopping due to job cancellation\",\n \"data\": null,\n \"type\": \"message\"\n },\n { ... },\n { ... }\n ], \"has_more\": true\n}\n" } } } }, "/fine_tuning/jobs/{fine_tuning_job_id}": { "get": { "operationId": "retrieveFineTuningJob", "tags": [ "Fine-tuning" ], "summary": "Get info about a fine-tuning job.\n\n[Learn more about fine-tuning](/docs/guides/fine-tuning)\n", "parameters": [ { "in": "path", "name": "fine_tuning_job_id", "required": true, "schema": { "type": "string", "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F" }, "description": "The ID of the fine-tuning job.\n" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FineTuningJob" } } } } }, "x-oaiMeta": { "name": "Retrieve fine-tuning job", "group": "fine-tuning", "returns": "The [fine-tuning](/docs/api-reference/fine-tunes/object) object with the given ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ft-AF1WoRqd3aJAHsqc9NY7iL8F \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.retrieve(\"ftjob-abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.retrieve(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"davinci-002\",\n \"created_at\": 1692661014,\n \"finished_at\": 1692661190,\n \"fine_tuned_model\": \"ft:davinci-002:my-org:custom_suffix:7q8mpxmy\",\n \"organization_id\": \"org-123\",\n \"result_files\": [\n \"file-abc123\"\n ],\n \"status\": \"succeeded\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\n \"n_epochs\": 4,\n },\n \"trained_tokens\": 5768\n}\n" } } } }, "/fine_tuning/jobs/{fine_tuning_job_id}/events": { "get": { "operationId": "listFineTuningEvents", "tags": [ "Fine-tuning" ], "summary": "Get status updates for a fine-tuning job.\n", "parameters": [ { "in": "path", "name": "fine_tuning_job_id", "required": true, "schema": { "type": "string", "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F" }, "description": "The ID of the fine-tuning job to get events for.\n" }, { "name": "after", "in": "query", "description": "Identifier for the last event from the previous pagination request.", "required": false, "schema": { "type": "string" } }, { "name": "limit", "in": "query", "description": "Number of events to retrieve.", "required": false, "schema": { "type": "integer", "default": 20 } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListFineTuningJobEventsResponse" } } } } }, "x-oaiMeta": { "name": "List fine-tuning events", "group": "fine-tuning", "returns": "A list of fine-tuning event objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/events \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.list_events(\n fine_tuning_job_id=\"ftjob-abc123\",\n limit=2\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTuning.list_events(id=\"ftjob-abc123\", limit=2);\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-ddTJfwuMVpfLXseO0Am0Gqjm\",\n \"created_at\": 1692407401,\n \"level\": \"info\",\n \"message\": \"Fine tuning job successfully completed\",\n \"data\": null,\n \"type\": \"message\"\n },\n {\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ft-event-tyiGuB72evQncpH87xe505Sv\",\n \"created_at\": 1692407400,\n \"level\": \"info\",\n \"message\": \"New fine-tuned model created: ft:gpt-3.5-turbo:openai::7p4lURel\",\n \"data\": null,\n \"type\": \"message\"\n }\n ],\n \"has_more\": true\n}\n" } } } }, "/fine_tuning/jobs/{fine_tuning_job_id}/cancel": { "post": { "operationId": "cancelFineTuningJob", "tags": [ "Fine-tuning" ], "summary": "Immediately cancel a fine-tune job.\n", "parameters": [ { "in": "path", "name": "fine_tuning_job_id", "required": true, "schema": { "type": "string", "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F" }, "description": "The ID of the fine-tuning job to cancel.\n" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FineTuningJob" } } } } }, "x-oaiMeta": { "name": "Cancel fine-tuning", "group": "fine-tuning", "returns": "The cancelled [fine-tuning](/docs/api-reference/fine-tuning/object) object.", "examples": { "request": { "curl": "curl -X POST https://api.openai.com/v1/fine_tuning/jobs/ftjob-abc123/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.fine_tuning.jobs.cancel(\"ftjob-abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTuning.jobs.cancel(\"ftjob-abc123\");\n\n console.log(fineTune);\n}\nmain();" }, "response": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"gpt-3.5-turbo-0613\",\n \"created_at\": 1689376978,\n \"fine_tuned_model\": null,\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"hyperparameters\": {\n \"n_epochs\": \"auto\"\n },\n \"status\": \"cancelled\",\n \"validation_file\": \"file-abc123\",\n \"training_file\": \"file-abc123\"\n}\n" } } } }, "/fine-tunes": { "post": { "operationId": "createFineTune", "deprecated": true, "tags": [ "Fine-tunes" ], "summary": "Creates a job that fine-tunes a specified model from a given dataset.\n\nResponse includes details of the enqueued job including job status and the name of the fine-tuned models once complete.\n\n[Learn more about fine-tuning](/docs/guides/legacy-fine-tuning)\n", "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", "returns": "A [fine-tune](/docs/api-reference/fine-tunes/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-abc123\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nfine_tune = client.fine_tunes.create(\n training_file=\"file-abc123\",\n model=\"davinci\"\n}\nprint(fine_tune)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTunes.create({\n training_file: \"file-abc123\"\n });\n\n console.log(fineTune);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"events\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n }\n ],\n \"fine_tuned_model\": null,\n \"hyperparams\": {\n \"batch_size\": 4,\n \"learning_rate_multiplier\": 0.1,\n \"n_epochs\": 4,\n \"prompt_loss_weight\": 0.1,\n },\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"pending\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-results\"\n }\n ],\n \"updated_at\": 1614807352,\n}\n" } } }, "get": { "operationId": "listFineTunes", "deprecated": true, "tags": [ "Fine-tunes" ], "summary": "List your organization's fine-tuning jobs\n", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListFineTunesResponse" } } } } }, "x-oaiMeta": { "name": "List fine-tunes", "group": "fine-tunes", "returns": "A list of [fine-tune](/docs/api-reference/fine-tunes/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmodels = client.fine_tunes.list()\nprint(models)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.fineTunes.list();\n\n for await (const fineTune of list) {\n console.log(fineTune);\n }\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"ft-AF1WoRqd3aJAHsqc9NY7iL8F\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"fine_tuned_model\": null,\n \"hyperparams\": { ... },\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"pending\",\n \"validation_files\": [],\n \"training_files\": [ { ... } ],\n \"updated_at\": 1614807352,\n },\n { ... },\n { ... }\n ]\n}\n" } } } }, "/fine-tunes/{fine_tune_id}": { "get": { "operationId": "retrieveFineTune", "deprecated": true, "tags": [ "Fine-tunes" ], "summary": "Gets info about the fine-tune job.\n\n[Learn more about fine-tuning](/docs/guides/legacy-fine-tuning)\n", "parameters": [ { "in": "path", "name": "fine_tune_id", "required": true, "schema": { "type": "string", "example": "ft-AF1WoRqd3aJAHsqc9NY7iL8F" }, "description": "The ID of the fine-tune job\n" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FineTune" } } } } }, "x-oaiMeta": { "name": "Retrieve fine-tune", "group": "fine-tunes", "returns": "The [fine-tune](/docs/api-reference/fine-tunes/object) object with the given ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine-tunes/ft-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nfine_tune = client.fine_tunes.retrieve(\"ft-abc123\")\nprint(fine_tune)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTunes.retrieve(\"ft-abc123\");\n\n console.log(fineTune);\n}\n\nmain();" }, "response": "{\n \"id\": \"ft-abc123\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"events\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807356,\n \"level\": \"info\",\n \"message\": \"Job started.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807861,\n \"level\": \"info\",\n \"message\": \"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Uploaded result files: file-abc123.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Job succeeded.\"\n }\n ],\n \"fine_tuned_model\": \"curie:ft-acmeco-2021-03-03-21-44-20\",\n \"hyperparams\": {\n \"batch_size\": 4,\n \"learning_rate_multiplier\": 0.1,\n \"n_epochs\": 4,\n \"prompt_loss_weight\": 0.1,\n },\n \"organization_id\": \"org-123\",\n \"result_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 81509,\n \"created_at\": 1614807863,\n \"filename\": \"compiled_results.csv\",\n \"purpose\": \"fine-tune-results\"\n }\n ],\n \"status\": \"succeeded\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune\"\n }\n ],\n \"updated_at\": 1614807865,\n}\n" } } } }, "/fine-tunes/{fine_tune_id}/cancel": { "post": { "operationId": "cancelFineTune", "deprecated": true, "tags": [ "Fine-tunes" ], "summary": "Immediately cancel a fine-tune job.\n", "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\n" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FineTune" } } } } }, "x-oaiMeta": { "name": "Cancel fine-tune", "group": "fine-tunes", "returns": "The cancelled [fine-tune](/docs/api-reference/fine-tunes/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nfine_tune = client.fine_tunes.cancel(\"ft-abc123\")\nprint(fine_tune)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTunes.cancel(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n\n console.log(fineTune);\n}\nmain();" }, "response": "{\n \"id\": \"ft-xhrpBbvVUzYGo8oUO1FY4nI7\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807770,\n \"events\": [ { ... } ],\n \"fine_tuned_model\": null,\n \"hyperparams\": { ... },\n \"organization_id\": \"org-123\",\n \"result_files\": [],\n \"status\": \"cancelled\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune\"\n }\n ],\n \"updated_at\": 1614807789,\n}\n" } } } }, "/fine-tunes/{fine_tune_id}/events": { "get": { "operationId": "listFineTuneEvents", "deprecated": true, "tags": [ "Fine-tunes" ], "summary": "Get fine-grained status updates for a fine-tune job.\n", "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.\n" }, { "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,\nevents will be sent as data-only\n[server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)\nas they become available. The stream will terminate with a\n`data: [DONE]` message when the job is finished (succeeded, cancelled,\nor failed).\n\nIf set to false, only events generated so far will be returned.\n" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListFineTuneEventsResponse" } } } } }, "x-oaiMeta": { "name": "List fine-tune events", "group": "fine-tunes", "returns": "A list of fine-tune event objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nfine_tune = client.fine_tunes.list_events(\"ft-abc123\")\nprint(fine_tune)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const fineTune = await openai.fineTunes.listEvents(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n\n console.log(fineTune);\n}\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807356,\n \"level\": \"info\",\n \"message\": \"Job started.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807861,\n \"level\": \"info\",\n \"message\": \"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Uploaded result files: file-abc123\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Job succeeded.\"\n }\n ]\n}\n" } } } }, "/models": { "get": { "operationId": "listModels", "tags": [ "Models" ], "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", "returns": "A list of [model](/docs/api-reference/models/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/models \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.models.list()\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const list = await openai.models.list();\n\n for await (const model of list) {\n console.log(model);\n }\n}\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"model-id-0\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"organization-owner\"\n },\n {\n \"id\": \"model-id-1\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"organization-owner\",\n },\n {\n \"id\": \"model-id-2\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\"\n },\n ],\n \"object\": \"list\"\n}\n" } } } }, "/models/{model}": { "get": { "operationId": "retrieveModel", "tags": [ "Models" ], "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", "example": "gpt-3.5-turbo" }, "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", "returns": "The [model](/docs/api-reference/models/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/models/VAR_model_id \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.models.retrieve(\"VAR_model_id\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const model = await openai.models.retrieve(\"gpt-3.5-turbo\");\n\n console.log(model);\n}\n\nmain();" }, "response": "{\n \"id\": \"VAR_model_id\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\"\n}\n" } } }, "delete": { "operationId": "deleteModel", "tags": [ "Models" ], "summary": "Delete a fine-tuned model. You must have the Owner role in your organization to delete a model.", "parameters": [ { "in": "path", "name": "model", "required": true, "schema": { "type": "string", "example": "ft:gpt-3.5-turbo:acemeco:suffix:abc123" }, "description": "The model to delete" } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeleteModelResponse" } } } } }, "x-oaiMeta": { "name": "Delete a fine-tuned model", "group": "models", "returns": "Deletion status.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/models/ft:gpt-3.5-turbo:acemeco:suffix:abc123 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.models.delete(\"ft:gpt-3.5-turbo:acemeco:suffix:abc123\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const model = await openai.models.del(\"ft:gpt-3.5-turbo:acemeco:suffix:abc123\");\n\n console.log(model);\n}\nmain();" }, "response": "{\n \"id\": \"ft:gpt-3.5-turbo:acemeco:suffix:abc123\",\n \"object\": \"model\",\n \"deleted\": true\n}\n" } } } }, "/moderations": { "post": { "operationId": "createModeration", "tags": [ "Moderations" ], "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", "returns": "A [moderation](/docs/api-reference/moderations/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/moderations \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"input\": \"I want to kill them.\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nclient.moderations.create(input=\"I want to kill them.\")\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const moderation = await openai.moderations.create({ input: \"I want to kill them.\" });\n\n console.log(moderation);\n}\nmain();\n" }, "response": "{\n \"id\": \"modr-XXXXX\",\n \"model\": \"text-moderation-005\",\n \"results\": [\n {\n \"flagged\": true,\n \"categories\": {\n \"sexual\": false,\n \"hate\": false,\n \"harassment\": false,\n \"self-harm\": false,\n \"sexual/minors\": false,\n \"hate/threatening\": false,\n \"violence/graphic\": false,\n \"self-harm/intent\": false,\n \"self-harm/instructions\": false,\n \"harassment/threatening\": true,\n \"violence\": true,\n },\n \"category_scores\": {\n \"sexual\": 1.2282071e-06,\n \"hate\": 0.010696256,\n \"harassment\": 0.29842457,\n \"self-harm\": 1.5236925e-08,\n \"sexual/minors\": 5.7246268e-08,\n \"hate/threatening\": 0.0060676364,\n \"violence/graphic\": 4.435014e-06,\n \"self-harm/intent\": 8.098441e-10,\n \"self-harm/instructions\": 2.8498655e-11,\n \"harassment/threatening\": 0.63055265,\n \"violence\": 0.99011886,\n }\n }\n ]\n}\n" } } } }, "/assistants": { "get": { "operationId": "listAssistants", "tags": [ "Assistants" ], "summary": "Returns a list of assistants.", "parameters": [ { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListAssistantsResponse" } } } } }, "x-oaiMeta": { "name": "List assistants", "group": "assistants", "beta": true, "returns": "A list of [assistant](/docs/api-reference/assistants/object) objects.", "examples": { "request": { "curl": "curl \"https://api.openai.com/v1/assistants?order=desc&limit=20\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistants = client.beta.assistants.list(\n order=\"desc\",\n limit=\"20\",\n)\nprint(my_assistants.data)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistants = await openai.beta.assistants.list({\n order: \"desc\",\n limit: \"20\",\n });\n\n console.log(myAssistants.data);\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698982736,\n \"name\": \"Coding Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc456\",\n \"object\": \"assistant\",\n \"created_at\": 1698982718,\n \"name\": \"My Assistant\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc789\",\n \"object\": \"assistant\",\n \"created_at\": 1698982643,\n \"name\": null,\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"asst_abc123\",\n \"last_id\": \"asst_abc789\",\n \"has_more\": false\n}\n" } } }, "post": { "operationId": "createAssistant", "tags": [ "Assistants" ], "summary": "Create an assistant with a model and instructions.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateAssistantRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssistantObject" } } } } }, "x-oaiMeta": { "name": "Create assistant", "group": "assistants", "beta": true, "returns": "An [assistant](/docs/api-reference/assistants/object) object.", "examples": [ { "title": "Code Interpreter", "request": { "curl": "curl \"https://api.openai.com/v1/assistants\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"name\": \"Math Tutor\",\n \"tools\": [{\"type\": \"code_interpreter\"}],\n \"model\": \"gpt-4\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistant = client.beta.assistants.create(\n instructions=\"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n name=\"Math Tutor\",\n tools=[{\"type\": \"code_interpreter\"}],\n model=\"gpt-4\",\n)\nprint(my_assistant)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n name: \"Math Tutor\",\n tools: [{ type: \"code_interpreter\" }],\n model: \"gpt-4\",\n });\n\n console.log(myAssistant);\n}\n\nmain();" }, "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698984975,\n \"name\": \"Math Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" }, { "title": "Files", "request": { "curl": "curl https://api.openai.com/v1/assistants \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [{\"type\": \"retrieval\"}],\n \"model\": \"gpt-4\",\n \"file_ids\": [\"file-abc123\"]\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistant = client.beta.assistants.create(\n instructions=\"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n name=\"HR Helper\",\n tools=[{\"type\": \"retrieval\"}],\n model=\"gpt-4\",\n file_ids=[\"file-abc123\"],\n)\nprint(my_assistant)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n name: \"HR Helper\",\n tools: [{ type: \"retrieval\" }],\n model: \"gpt-4\",\n file_ids: [\"file-abc123\"],\n });\n\n console.log(myAssistant);\n}\n\nmain();" }, "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009403,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\"\n ],\n \"metadata\": {}\n}\n" } ] } } }, "/assistants/{assistant_id}": { "get": { "operationId": "getAssistant", "tags": [ "Assistants" ], "summary": "Retrieves an assistant.", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the assistant to retrieve." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssistantObject" } } } } }, "x-oaiMeta": { "name": "Retrieve assistant", "group": "assistants", "beta": true, "returns": "The [assistant](/docs/api-reference/assistants/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistant = client.beta.assistants.retrieve(\"asst_abc123\")\nprint(my_assistant)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.retrieve(\n \"asst_abc123\"\n );\n\n console.log(myAssistant);\n}\n\nmain();" }, "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\"\n ],\n \"metadata\": {}\n}\n" } } }, "post": { "operationId": "modifyAssistant", "tags": [ "Assistants" ], "summary": "Modifies an assistant.", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the assistant to modify." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModifyAssistantRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssistantObject" } } } } }, "x-oaiMeta": { "name": "Modify assistant", "group": "assistants", "beta": true, "returns": "The modified [assistant](/docs/api-reference/assistants/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [{\"type\": \"retrieval\"}],\n \"model\": \"gpt-4\",\n \"file_ids\": [\"file-abc123\", \"file-abc456\"]\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_updated_assistant = client.beta.assistants.update(\n \"asst_abc123\",\n instructions=\"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n name=\"HR Helper\",\n tools=[{\"type\": \"retrieval\"}],\n model=\"gpt-4\",\n file_ids=[\"file-abc123\", \"file-abc456\"],\n)\n\nprint(my_updated_assistant)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myUpdatedAssistant = await openai.beta.assistants.update(\n \"asst_abc123\",\n {\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n name: \"HR Helper\",\n tools: [{ type: \"retrieval\" }],\n model: \"gpt-4\",\n file_ids: [\n \"file-abc123\",\n \"file-abc456\",\n ],\n }\n );\n\n console.log(myUpdatedAssistant);\n}\n\nmain();" }, "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n}\n" } } }, "delete": { "operationId": "deleteAssistant", "tags": [ "Assistants" ], "summary": "Delete an assistant.", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the assistant to delete." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeleteAssistantResponse" } } } } }, "x-oaiMeta": { "name": "Delete assistant", "group": "assistants", "beta": true, "returns": "Deletion status", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X DELETE\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nresponse = client.beta.assistants.delete(\"asst_abc123\")\nprint(response)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.beta.assistants.del(\"asst_abc123\");\n\n console.log(response);\n}\nmain();" }, "response": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant.deleted\",\n \"deleted\": true\n}\n" } } } }, "/threads": { "post": { "operationId": "createThread", "tags": [ "Assistants" ], "summary": "Create a thread.", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateThreadRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ThreadObject" } } } } }, "x-oaiMeta": { "name": "Create thread", "group": "threads", "beta": true, "returns": "A [thread](/docs/api-reference/threads) object.", "examples": [ { "title": "Empty", "request": { "curl": "curl https://api.openai.com/v1/threads \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d ''\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nempty_thread = client.beta.threads.create()\nprint(empty_thread)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const emptyThread = await openai.beta.threads.create();\n\n console.log(emptyThread);\n}\n\nmain();" }, "response": "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699012949,\n \"metadata\": {}\n}\n" }, { "title": "Messages", "request": { "curl": "curl https://api.openai.com/v1/threads \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n-H \"OpenAI-Beta: assistants=v1\" \\\n-d '{\n \"messages\": [{\n \"role\": \"user\",\n \"content\": \"Hello, what is AI?\",\n \"file_ids\": [\"file-abc123\"]\n }, {\n \"role\": \"user\",\n \"content\": \"How does AI work? Explain it in simple terms.\"\n }]\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmessage_thread = client.beta.threads.create(\n messages=[\n {\n \"role\": \"user\",\n \"content\": \"Hello, what is AI?\",\n \"file_ids\": [\"file-abc123\"],\n },\n {\n \"role\": \"user\",\n \"content\": \"How does AI work? Explain it in simple terms.\"\n },\n ]\n)\n\nprint(message_thread)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const messageThread = await openai.beta.threads.create({\n messages: [\n {\n role: \"user\",\n content: \"Hello, what is AI?\",\n file_ids: [\"file-abc123\"],\n },\n {\n role: \"user\",\n content: \"How does AI work? Explain it in simple terms.\",\n },\n ],\n });\n\n console.log(messageThread);\n}\n\nmain();" }, "response": "{\n id: 'thread_abc123',\n object: 'thread',\n created_at: 1699014083,\n metadata: {}\n}\n" } ] } } }, "/threads/{thread_id}": { "get": { "operationId": "getThread", "tags": [ "Assistants" ], "summary": "Retrieves a thread.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to retrieve." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ThreadObject" } } } } }, "x-oaiMeta": { "name": "Retrieve thread", "group": "threads", "beta": true, "returns": "The [thread](/docs/api-reference/threads/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_thread = client.beta.threads.retrieve(\"thread_abc123\")\nprint(my_thread)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myThread = await openai.beta.threads.retrieve(\n \"thread_abc123\"\n );\n\n console.log(myThread);\n}\n\nmain();" }, "response": "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699014083,\n \"metadata\": {}\n}\n" } } }, "post": { "operationId": "modifyThread", "tags": [ "Assistants" ], "summary": "Modifies a thread.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to modify. Only the `metadata` can be modified." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModifyThreadRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ThreadObject" } } } } }, "x-oaiMeta": { "name": "Modify thread", "group": "threads", "beta": true, "returns": "The modified [thread](/docs/api-reference/threads/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmy_updated_thread = client.beta.threads.update(\n \"thread_abc123\",\n metadata={\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n)\nprint(my_updated_thread)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const updatedThread = await openai.beta.threads.update(\n \"thread_abc123\",\n {\n metadata: { modified: \"true\", user: \"abc123\" },\n }\n );\n\n console.log(updatedThread);\n}\n\nmain();" }, "response": "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699014083,\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n}\n" } } }, "delete": { "operationId": "deleteThread", "tags": [ "Assistants" ], "summary": "Delete a thread.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to delete." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeleteThreadResponse" } } } } }, "x-oaiMeta": { "name": "Delete thread", "group": "threads", "beta": true, "returns": "Deletion status", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X DELETE\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nresponse = client.beta.threads.delete(\"thread_abc123\")\nprint(response)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.beta.threads.del(\"thread_abc123\");\n\n console.log(response);\n}\nmain();" }, "response": "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread.deleted\",\n \"deleted\": true\n}\n" } } } }, "/threads/{thread_id}/messages": { "get": { "operationId": "listMessages", "tags": [ "Assistants" ], "summary": "Returns a list of messages for a given thread.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) the messages belong to." }, { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListMessagesResponse" } } } } }, "x-oaiMeta": { "name": "List messages", "group": "threads", "beta": true, "returns": "A list of [message](/docs/api-reference/messages) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nthread_messages = client.beta.threads.messages.list(\"thread_abc123\")\nprint(thread_messages.data)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const threadMessages = await openai.beta.threads.messages.list(\n \"thread_abc123\"\n );\n\n console.log(threadMessages.data);\n}\n\nmain();" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699016383,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"assistant_id\": null,\n \"run_id\": null,\n \"metadata\": {}\n },\n {\n \"id\": \"msg_abc456\",\n \"object\": \"thread.message\",\n \"created_at\": 1699016383,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"Hello, what is AI?\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [\n \"file-abc123\"\n ],\n \"assistant_id\": null,\n \"run_id\": null,\n \"metadata\": {}\n }\n ],\n \"first_id\": \"msg_abc123\",\n \"last_id\": \"msg_abc456\",\n \"has_more\": false\n}\n" } } }, "post": { "operationId": "createMessage", "tags": [ "Assistants" ], "summary": "Create a message.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) to create a message for." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateMessageRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MessageObject" } } } } }, "x-oaiMeta": { "name": "Create message", "group": "threads", "beta": true, "returns": "A [message](/docs/api-reference/messages/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"role\": \"user\",\n \"content\": \"How does AI work? Explain it in simple terms.\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nthread_message = client.beta.threads.messages.create(\n \"thread_abc123\",\n role=\"user\",\n content=\"How does AI work? Explain it in simple terms.\",\n)\nprint(thread_message)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const threadMessages = await openai.beta.threads.messages.create(\n \"thread_abc123\",\n { role: \"user\", content: \"How does AI work? Explain it in simple terms.\" }\n );\n\n console.log(threadMessages);\n}\n\nmain();" }, "response": "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699017614,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"assistant_id\": null,\n \"run_id\": null,\n \"metadata\": {}\n}\n" } } } }, "/threads/{thread_id}/messages/{message_id}": { "get": { "operationId": "getMessage", "tags": [ "Assistants" ], "summary": "Retrieve a message.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) to which this message belongs." }, { "in": "path", "name": "message_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the message to retrieve." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MessageObject" } } } } }, "x-oaiMeta": { "name": "Retrieve message", "group": "threads", "beta": true, "returns": "The [message](/docs/api-reference/threads/messages/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmessage = client.beta.threads.messages.retrieve(\n message_id=\"msg_abc123\",\n thread_id=\"thread_abc123\",\n)\nprint(message)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const message = await openai.beta.threads.messages.retrieve(\n \"thread_abc123\",\n \"msg_abc123\"\n );\n\n console.log(message);\n}\n\nmain();" }, "response": "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699017614,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"assistant_id\": null,\n \"run_id\": null,\n \"metadata\": {}\n}\n" } } }, "post": { "operationId": "modifyMessage", "tags": [ "Assistants" ], "summary": "Modifies a message.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to which this message belongs." }, { "in": "path", "name": "message_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the message to modify." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModifyMessageRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MessageObject" } } } } }, "x-oaiMeta": { "name": "Modify message", "group": "threads", "beta": true, "returns": "The modified [message](/docs/api-reference/threads/messages/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmessage = client.beta.threads.messages.update(\n message_id=\"msg_abc12\",\n thread_id=\"thread_abc123\",\n metadata={\n \"modified\": \"true\",\n \"user\": \"abc123\",\n },\n)\nprint(message)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const message = await openai.beta.threads.messages.update(\n \"thread_abc123\",\n \"msg_abc123\",\n {\n metadata: {\n modified: \"true\",\n user: \"abc123\",\n },\n }\n }'" }, "response": "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699017614,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"assistant_id\": null,\n \"run_id\": null,\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n}\n" } } } }, "/threads/runs": { "post": { "operationId": "createThreadAndRun", "tags": [ "Assistants" ], "summary": "Create a thread and run it in one request.", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateThreadAndRunRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Create thread and run", "group": "threads", "beta": true, "returns": "A [run](/docs/api-reference/runs/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\",\n \"thread\": {\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Explain deep learning to a 5 year old.\"}\n ]\n }\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.create_and_run(\n assistant_id=\"asst_abc123\",\n thread={\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Explain deep learning to a 5 year old.\"}\n ]\n }\n)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.createAndRun({\n assistant_id: \"asst_abc123\",\n thread: {\n messages: [\n { role: \"user\", content: \"Explain deep learning to a 5 year old.\" },\n ],\n },\n });\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699076792,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"queued\",\n \"started_at\": null,\n \"expires_at\": 1699077392,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"last_error\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant.\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" } } } }, "/threads/{thread_id}/runs": { "get": { "operationId": "listRuns", "tags": [ "Assistants" ], "summary": "Returns a list of runs belonging to a thread.", "parameters": [ { "name": "thread_id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread the run belongs to." }, { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListRunsResponse" } } } } }, "x-oaiMeta": { "name": "List runs", "group": "threads", "beta": true, "returns": "A list of [run](/docs/api-reference/runs/object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nruns = client.beta.threads.runs.list(\n \"thread_abc123\"\n)\nprint(runs)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const runs = await openai.beta.threads.runs.list(\n \"thread_abc123\"\n );\n\n console.log(runs);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-3.5-turbo\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n },\n {\n \"id\": \"run_abc456\",\n \"object\": \"thread.run\",\n \"created_at\": 1699063290,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699063290,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699063291,\n \"last_error\": null,\n \"model\": \"gpt-3.5-turbo\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"run_abc123\",\n \"last_id\": \"run_abc456\",\n \"has_more\": false\n}\n" } } }, "post": { "operationId": "createRun", "tags": [ "Assistants" ], "summary": "Create a run.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to run." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateRunRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Create run", "group": "threads", "beta": true, "returns": "A [run](/docs/api-reference/runs/object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.runs.create(\n thread_id=\"thread_abc123\",\n assistant_id=\"asst_abc123\"\n)\nprint(run)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.create(\n \"thread_abc123\",\n { assistant_id: \"asst_abc123\" }\n );\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699063290,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"queued\",\n \"started_at\": 1699063290,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699063291,\n \"last_error\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n}\n" } } } }, "/threads/{thread_id}/runs/{run_id}": { "get": { "operationId": "getRun", "tags": [ "Assistants" ], "summary": "Retrieves a run.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) that was run." }, { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run to retrieve." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Retrieve run", "group": "threads", "beta": true, "returns": "The [run](/docs/api-reference/runs/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.runs.retrieve(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\"\n)\nprint(run)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.retrieve(\n \"thread_abc123\",\n \"run_abc123\"\n );\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-3.5-turbo\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n}\n" } } }, "post": { "operationId": "modifyRun", "tags": [ "Assistants" ], "summary": "Modifies a run.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) that was run." }, { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run to modify." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModifyRunRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Modify run", "group": "threads", "beta": true, "returns": "The modified [run](/docs/api-reference/runs/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"metadata\": {\n \"user_id\": \"user_abc123\"\n }\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.runs.update(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\",\n metadata={\"user_id\": \"user_abc123\"},\n)\nprint(run)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.update(\n \"thread_abc123\",\n \"run_abc123\",\n {\n metadata: {\n user_id: \"user_abc123\",\n },\n }\n );\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-3.5-turbo\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {\n \"user_id\": \"user_abc123\"\n }\n}\n" } } } }, "/threads/{thread_id}/runs/{run_id}/submit_tool_outputs": { "post": { "operationId": "submitToolOuputsToRun", "tags": [ "Assistants" ], "summary": "When a run has the `status: \"requires_action\"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.\n", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the [thread](/docs/api-reference/threads) to which this run belongs." }, { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run that requires the tool output submission." } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SubmitToolOutputsRunRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Submit tool outputs to run", "group": "threads", "beta": true, "returns": "The modified [run](/docs/api-reference/runs/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/submit_tool_outputs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"tool_outputs\": [\n {\n \"tool_call_id\": \"call_abc123\",\n \"output\": \"28C\"\n }\n ]\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.runs.submit_tool_outputs(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\",\n tool_outputs=[\n {\n \"tool_call_id\": \"call_abc123\",\n \"output\": \"28C\"\n }\n ]\n)\nprint(run)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.submitToolOutputs(\n \"thread_abc123\",\n \"run_abc123\",\n {\n tool_outputs: [\n {\n tool_call_id: \"call_abc123\",\n output: \"28C\",\n },\n ],\n }\n );\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075592,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"queued\",\n \"started_at\": 1699075592,\n \"expires_at\": 1699076192,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"last_error\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You tell the weather.\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_weather\",\n \"description\": \"Determine weather in my location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\n \"c\",\n \"f\"\n ]\n }\n },\n \"required\": [\n \"location\"\n ]\n }\n }\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" } } } }, "/threads/{thread_id}/runs/{run_id}/cancel": { "post": { "operationId": "cancelRun", "tags": [ "Assistants" ], "summary": "Cancels a run that is `in_progress`.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to which this run belongs." }, { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run to cancel." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunObject" } } } } }, "x-oaiMeta": { "name": "Cancel a run", "group": "threads", "beta": true, "returns": "The modified [run](/docs/api-reference/runs/object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X POST\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun = client.beta.threads.runs.cancel(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\"\n)\nprint(run)\n", "node.js": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.cancel(\n \"thread_abc123\",\n \"run_abc123\"\n );\n\n console.log(run);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699076126,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"cancelling\",\n \"started_at\": 1699076126,\n \"expires_at\": 1699076726,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"last_error\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You summarize books.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" } } } }, "/threads/{thread_id}/runs/{run_id}/steps": { "get": { "operationId": "listRunSteps", "tags": [ "Assistants" ], "summary": "Returns a list of run steps belonging to a run.", "parameters": [ { "name": "thread_id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread the run and run steps belong to." }, { "name": "run_id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "The ID of the run the run steps belong to." }, { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListRunStepsResponse" } } } } }, "x-oaiMeta": { "name": "List run steps", "group": "threads", "beta": true, "returns": "A list of [run step](/docs/api-reference/runs/step-object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun_steps = client.beta.threads.runs.steps.list(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\"\n)\nprint(run_steps)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const runStep = await openai.beta.threads.runs.steps.list(\n \"thread_abc123\",\n \"run_abc123\"\n );\n console.log(runStep);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n }\n }\n ],\n \"first_id\": \"step_abc123\",\n \"last_id\": \"step_abc456\",\n \"has_more\": false\n}\n" } } } }, "/threads/{thread_id}/runs/{run_id}/steps/{step_id}": { "get": { "operationId": "getRunStep", "tags": [ "Assistants" ], "summary": "Retrieves a run step.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the thread to which the run and run step belongs." }, { "in": "path", "name": "run_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run to which the run step belongs." }, { "in": "path", "name": "step_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the run step to retrieve." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RunStepObject" } } } } }, "x-oaiMeta": { "name": "Retrieve run step", "group": "threads", "beta": true, "returns": "The [run step](/docs/api-reference/runs/step-object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nrun_step = client.beta.threads.runs.steps.retrieve(\n thread_id=\"thread_abc123\",\n run_id=\"run_abc123\",\n step_id=\"step_abc123\"\n)\nprint(run_step)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const runStep = await openai.beta.threads.runs.steps.retrieve(\n \"thread_abc123\",\n \"run_abc123\",\n \"step_abc123\"\n );\n console.log(runStep);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n }\n}\n" } } } }, "/assistants/{assistant_id}/files": { "get": { "operationId": "listAssistantFiles", "tags": [ "Assistants" ], "summary": "Returns a list of assistant files.", "parameters": [ { "name": "assistant_id", "in": "path", "description": "The ID of the assistant the file belongs to.", "required": true, "schema": { "type": "string" } }, { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListAssistantFilesResponse" } } } } }, "x-oaiMeta": { "name": "List assistant files", "group": "assistants", "beta": true, "returns": "A list of [assistant file](/docs/api-reference/assistants/file-object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nassistant_files = client.beta.assistants.files.list(\n assistant_id=\"asst_abc123\"\n)\nprint(assistant_files)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const assistantFiles = await openai.beta.assistants.files.list(\n \"asst_abc123\"\n );\n console.log(assistantFiles);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699060412,\n \"assistant_id\": \"asst_abc123\"\n },\n {\n \"id\": \"file-abc456\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699060412,\n \"assistant_id\": \"asst_abc123\"\n }\n ],\n \"first_id\": \"file-abc123\",\n \"last_id\": \"file-abc456\",\n \"has_more\": false\n}\n" } } }, "post": { "operationId": "createAssistantFile", "tags": [ "Assistants" ], "summary": "Create an assistant file by attaching a [File](/docs/api-reference/files) to an [assistant](/docs/api-reference/assistants).", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string", "example": "file-abc123" }, "description": "The ID of the assistant for which to create a File.\n" } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateAssistantFileRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssistantFileObject" } } } } }, "x-oaiMeta": { "name": "Create assistant file", "group": "assistants", "beta": true, "returns": "An [assistant file](/docs/api-reference/assistants/file-object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123/files \\\n -H 'Authorization: Bearer $OPENAI_API_KEY\"' \\\n -H 'Content-Type: application/json' \\\n -H 'OpenAI-Beta: assistants=v1' \\\n -d '{\n \"file_id\": \"file-abc123\"\n }'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nassistant_file = client.beta.assistants.files.create(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(assistant_file)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistantFile = await openai.beta.assistants.files.create(\n \"asst_abc123\",\n {\n file_id: \"file-abc123\"\n }\n );\n console.log(myAssistantFile);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" } } } }, "/assistants/{assistant_id}/files/{file_id}": { "get": { "operationId": "getAssistantFile", "tags": [ "Assistants" ], "summary": "Retrieves an AssistantFile.", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the assistant who the file belongs to." }, { "in": "path", "name": "file_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the file we're getting." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AssistantFileObject" } } } } }, "x-oaiMeta": { "name": "Retrieve assistant file", "group": "assistants", "beta": true, "returns": "The [assistant file](/docs/api-reference/assistants/file-object) object matching the specified ID.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \\\n -H 'Authorization: Bearer $OPENAI_API_KEY\"' \\\n -H 'Content-Type: application/json' \\\n -H 'OpenAI-Beta: assistants=v1'\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nassistant_file = client.beta.assistants.files.retrieve(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(assistant_file)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistantFile = await openai.beta.assistants.files.retrieve(\n \"asst_abc123\",\n \"file-abc123\"\n );\n console.log(myAssistantFile);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" } } }, "delete": { "operationId": "deleteAssistantFile", "tags": [ "Assistants" ], "summary": "Delete an assistant file.", "parameters": [ { "in": "path", "name": "assistant_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the assistant that the file belongs to." }, { "in": "path", "name": "file_id", "required": true, "schema": { "type": "string" }, "description": "The ID of the file to delete." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DeleteAssistantFileResponse" } } } } }, "x-oaiMeta": { "name": "Delete assistant file", "group": "assistants", "beta": true, "returns": "Deletion status", "examples": { "request": { "curl": "curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X DELETE\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\ndeleted_assistant_file = client.beta.assistants.files.delete(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(deleted_assistant_file)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const deletedAssistantFile = await openai.beta.assistants.files.del(\n \"asst_abc123\",\n \"file-abc123\"\n );\n console.log(deletedAssistantFile);\n}\n\nmain();\n" }, "response": "{\n id: \"file-abc123\",\n object: \"assistant.file.deleted\",\n deleted: true\n}\n" } } } }, "/threads/{thread_id}/messages/{message_id}/files": { "get": { "operationId": "listMessageFiles", "tags": [ "Assistants" ], "summary": "Returns a list of message files.", "parameters": [ { "name": "thread_id", "in": "path", "description": "The ID of the thread that the message and files belong to.", "required": true, "schema": { "type": "string" } }, { "name": "message_id", "in": "path", "description": "The ID of the message that the files belongs to.", "required": true, "schema": { "type": "string" } }, { "name": "limit", "in": "query", "description": "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.\n", "required": false, "schema": { "type": "integer", "default": 20 } }, { "name": "order", "in": "query", "description": "Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.\n", "schema": { "type": "string", "default": "desc", "enum": [ "asc", "desc" ] } }, { "name": "after", "in": "query", "description": "A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n", "schema": { "type": "string" } }, { "name": "before", "in": "query", "description": "A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n", "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ListMessageFilesResponse" } } } } }, "x-oaiMeta": { "name": "List message files", "group": "threads", "beta": true, "returns": "A list of [message file](/docs/api-reference/messages/file-object) objects.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmessage_files = client.beta.threads.messages.files.list(\n thread_id=\"thread_abc123\",\n message_id=\"msg_abc123\"\n)\nprint(message_files)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const messageFiles = await openai.beta.threads.messages.files.list(\n \"thread_abc123\",\n \"msg_abc123\"\n );\n console.log(messageFiles);\n}\n\nmain();\n" }, "response": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"thread.message.file\",\n \"created_at\": 1699061776,\n \"message_id\": \"msg_abc123\"\n },\n {\n \"id\": \"file-abc123\",\n \"object\": \"thread.message.file\",\n \"created_at\": 1699061776,\n \"message_id\": \"msg_abc123\"\n }\n ],\n \"first_id\": \"file-abc123\",\n \"last_id\": \"file-abc123\",\n \"has_more\": false\n}\n" } } } }, "/threads/{thread_id}/messages/{message_id}/files/{file_id}": { "get": { "operationId": "getMessageFile", "tags": [ "Assistants" ], "summary": "Retrieves a message file.", "parameters": [ { "in": "path", "name": "thread_id", "required": true, "schema": { "type": "string", "example": "thread_abc123" }, "description": "The ID of the thread to which the message and File belong." }, { "in": "path", "name": "message_id", "required": true, "schema": { "type": "string", "example": "msg_abc123" }, "description": "The ID of the message the file belongs to." }, { "in": "path", "name": "file_id", "required": true, "schema": { "type": "string", "example": "file-abc123" }, "description": "The ID of the file being retrieved." } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MessageFileObject" } } } } }, "x-oaiMeta": { "name": "Retrieve message file", "group": "threads", "beta": true, "returns": "The [message file](/docs/api-reference/messages/file-object) object.", "examples": { "request": { "curl": "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files/file-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n", "python": "from openai import OpenAI\nclient = OpenAI()\n\nmessage_files = client.beta.threads.messages.files.retrieve(\n thread_id=\"thread_abc123\",\n message_id=\"msg_abc123\",\n file_id=\"file-abc123\"\n)\nprint(message_files)\n", "node.js": "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const messageFile = await openai.beta.threads.messages.files.retrieve(\n \"thread_abc123\",\n \"msg_abc123\",\n \"file-abc123\"\n );\n console.log(messageFile);\n}\n\nmain();\n" }, "response": "{\n \"id\": \"file-abc123\",\n \"object\": \"thread.message.file\",\n \"created_at\": 1699061776,\n \"message_id\": \"msg_abc123\"\n}\n" } } } } }, "components": { "securitySchemes": { "ApiKeyAuth": { "type": "http", "scheme": "bearer" } }, "schemas": { "Error": { "type": "object", "properties": { "code": { "type": "string", "nullable": true }, "message": { "type": "string", "nullable": false }, "param": { "type": "string", "nullable": true }, "type": { "type": "string", "nullable": false } }, "required": [ "type", "message", "param", "code" ] }, "ErrorResponse": { "type": "object", "properties": { "error": { "$ref": "#/components/schemas/Error" } }, "required": [ "error" ] }, "ListModelsResponse": { "type": "object", "properties": { "object": { "type": "string", "enum": [ "list" ] }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Model" } } }, "required": [ "object", "data" ] }, "DeleteModelResponse": { "type": "object", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" }, "object": { "type": "string" } }, "required": [ "id", "object", "deleted" ] }, "CreateCompletionRequest": { "type": "object", "properties": { "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.\n", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "babbage-002", "davinci-002", "gpt-3.5-turbo-instruct", "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": "The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote 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.\n", "default": "<|endoftext|>", "nullable": true, "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]]" } ] }, "best_of": { "type": "integer", "default": 1, "minimum": 0, "maximum": 20, "nullable": true, "description": "Generates `best_of` completions server-side and returns the \"best\" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen 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`.\n\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`.\n" }, "echo": { "type": "boolean", "default": false, "nullable": true, "description": "Echo back the prompt in addition to the completion\n" }, "frequency_penalty": { "type": "number", "default": 0, "minimum": -2, "maximum": 2, "nullable": true, "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.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)\n" }, "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.\n\nAccepts 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.\n\nAs an example, you can pass `{\"50256\": -100}` to prevent the <|endoftext|> token from being generated.\n" }, "logprobs": { "type": "integer", "minimum": 0, "maximum": 5, "default": null, "nullable": true, "description": "Include the log probabilities on the `logprobs` most likely output 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.\n\nThe maximum value for `logprobs` is 5.\n" }, "max_tokens": { "type": "integer", "minimum": 0, "default": 16, "example": 16, "nullable": true, "description": "The maximum number of [tokens](/tokenizer) that can be generated in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n" }, "n": { "type": "integer", "minimum": 1, "maximum": 128, "default": 1, "example": 1, "nullable": true, "description": "How many completions to generate for each prompt.\n\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`.\n" }, "presence_penalty": { "type": "number", "default": 0, "minimum": -2, "maximum": 2, "nullable": true, "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.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)\n" }, "seed": { "type": "integer", "minimum": -9223372036854776000, "maximum": 9223372036854776000, "nullable": true, "description": "If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\n\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n" }, "stop": { "description": "Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.\n", "default": null, "nullable": true, "oneOf": [ { "type": "string", "default": "<|endoftext|>", "example": "\n", "nullable": true }, { "type": "array", "minItems": 1, "maxItems": 4, "items": { "type": "string", "example": "[\"\\n\"]" } } ] }, "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://cookbook.openai.com/examples/how_to_stream_completions).\n", "type": "boolean", "nullable": true, "default": false }, "suffix": { "description": "The suffix that comes after a completion of inserted text.", "default": null, "nullable": true, "type": "string", "example": "test." }, "temperature": { "type": "number", "minimum": 0, "maximum": 2, "default": 1, "example": 1, "nullable": true, "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.\n\nWe generally recommend altering this or `top_p` but not both.\n" }, "top_p": { "type": "number", "minimum": 0, "maximum": 1, "default": 1, "example": 1, "nullable": true, "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.\n\nWe generally recommend altering this or `temperature` but not both.\n" }, "user": { "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).\n" } }, "required": [ "model", "prompt" ] }, "CreateCompletionResponse": { "type": "object", "description": "Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).\n", "properties": { "id": { "type": "string", "description": "A unique identifier for the completion." }, "choices": { "type": "array", "description": "The list of completion choices the model generated for the input prompt.", "items": { "type": "object", "required": [ "finish_reason", "index", "logprobs", "text" ], "properties": { "finish_reason": { "type": "string", "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\nor `content_filter` if content was omitted due to a flag from our content filters.\n", "enum": [ "stop", "length", "content_filter" ] }, "index": { "type": "integer" }, "logprobs": { "type": "object", "nullable": true, "properties": { "text_offset": { "type": "array", "items": { "type": "integer" } }, "token_logprobs": { "type": "array", "items": { "type": "number" } }, "tokens": { "type": "array", "items": { "type": "string" } }, "top_logprobs": { "type": "array", "items": { "type": "object", "additionalProperties": { "type": "number" } } } } }, "text": { "type": "string" } } } }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the completion was created." }, "model": { "type": "string", "description": "The model used for completion." }, "system_fingerprint": { "type": "string", "description": "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" }, "object": { "type": "string", "description": "The object type, which is always \"text_completion\"", "enum": [ "text_completion" ] }, "usage": { "$ref": "#/components/schemas/CompletionUsage" } }, "required": [ "id", "object", "created", "model", "choices" ], "x-oaiMeta": { "name": "The completion object", "legacy": true, "example": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"gpt-3.5-turbo\",\n \"choices\": [\n {\n \"text\": \"\\n\\nThis is indeed a test\",\n \"index\": 0,\n \"logprobs\": null,\n \"finish_reason\": \"length\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 5,\n \"completion_tokens\": 7,\n \"total_tokens\": 12\n }\n}\n" } }, "ChatCompletionRequestMessageContentPart": { "oneOf": [ { "$ref": "#/components/schemas/ChatCompletionRequestMessageContentPartText" }, { "$ref": "#/components/schemas/ChatCompletionRequestMessageContentPartImage" } ], "x-oaiExpandable": true }, "ChatCompletionRequestMessageContentPartImage": { "type": "object", "title": "Image content part", "properties": { "type": { "type": "string", "enum": [ "image_url" ], "description": "The type of the content part." }, "image_url": { "type": "object", "properties": { "url": { "type": "string", "description": "Either a URL of the image or the base64 encoded image data.", "format": "uri" }, "detail": { "type": "string", "description": "Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding).", "enum": [ "auto", "low", "high" ], "default": "auto" } }, "required": [ "url" ] } }, "required": [ "type", "image_url" ] }, "ChatCompletionRequestMessageContentPartText": { "type": "object", "title": "Text content part", "properties": { "type": { "type": "string", "enum": [ "text" ], "description": "The type of the content part." }, "text": { "type": "string", "description": "The text content." } }, "required": [ "type", "text" ] }, "ChatCompletionRequestMessage": { "oneOf": [ { "$ref": "#/components/schemas/ChatCompletionRequestSystemMessage" }, { "$ref": "#/components/schemas/ChatCompletionRequestUserMessage" }, { "$ref": "#/components/schemas/ChatCompletionRequestAssistantMessage" }, { "$ref": "#/components/schemas/ChatCompletionRequestToolMessage" }, { "$ref": "#/components/schemas/ChatCompletionRequestFunctionMessage" } ], "x-oaiExpandable": true }, "ChatCompletionRequestSystemMessage": { "type": "object", "title": "System message", "properties": { "content": { "description": "The contents of the system message.", "type": "string" }, "role": { "type": "string", "enum": [ "system" ], "description": "The role of the messages author, in this case `system`." }, "name": { "type": "string", "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role." } }, "required": [ "content", "role" ] }, "ChatCompletionRequestUserMessage": { "type": "object", "title": "User message", "properties": { "content": { "description": "The contents of the user message.\n", "oneOf": [ { "type": "string", "description": "The text contents of the message.", "title": "Text content" }, { "type": "array", "description": "An array of content parts with a defined type, each can be of type `text` or `image_url` when passing in images. You can pass multiple images by adding multiple `image_url` content parts. Image input is only supported when using the `gpt-4-visual-preview` model.", "title": "Array of content parts", "items": { "$ref": "#/components/schemas/ChatCompletionRequestMessageContentPart" }, "minItems": 1 } ], "x-oaiExpandable": true }, "role": { "type": "string", "enum": [ "user" ], "description": "The role of the messages author, in this case `user`." }, "name": { "type": "string", "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role." } }, "required": [ "content", "role" ] }, "ChatCompletionRequestAssistantMessage": { "type": "object", "title": "Assistant message", "properties": { "content": { "nullable": true, "type": "string", "description": "The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.\n" }, "role": { "type": "string", "enum": [ "assistant" ], "description": "The role of the messages author, in this case `assistant`." }, "name": { "type": "string", "description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role." }, "tool_calls": { "$ref": "#/components/schemas/ChatCompletionMessageToolCalls" }, "function_call": { "type": "object", "deprecated": true, "description": "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.", "properties": { "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." }, "name": { "type": "string", "description": "The name of the function to call." } }, "required": [ "arguments", "name" ] } }, "required": [ "role" ] }, "ChatCompletionRequestToolMessage": { "type": "object", "title": "Tool message", "properties": { "role": { "type": "string", "enum": [ "tool" ], "description": "The role of the messages author, in this case `tool`." }, "content": { "type": "string", "description": "The contents of the tool message." }, "tool_call_id": { "type": "string", "description": "Tool call that this message is responding to." } }, "required": [ "role", "content", "tool_call_id" ] }, "ChatCompletionRequestFunctionMessage": { "type": "object", "title": "Function message", "deprecated": true, "properties": { "role": { "type": "string", "enum": [ "function" ], "description": "The role of the messages author, in this case `function`." }, "content": { "nullable": true, "type": "string", "description": "The contents of the function message." }, "name": { "type": "string", "description": "The name of the function to call." } }, "required": [ "role", "content", "name" ] }, "FunctionParameters": { "type": "object", "description": "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list.", "additionalProperties": true }, "ChatCompletionFunctions": { "type": "object", "deprecated": true, "properties": { "description": { "type": "string", "description": "A description of what the function does, used by the model to choose when and how to call the function." }, "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." }, "parameters": { "$ref": "#/components/schemas/FunctionParameters" } }, "required": [ "name" ] }, "ChatCompletionFunctionCallOption": { "type": "object", "description": "Specifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n", "properties": { "name": { "type": "string", "description": "The name of the function to call." } }, "required": [ "name" ] }, "ChatCompletionTool": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "function" ], "description": "The type of the tool. Currently, only `function` is supported." }, "function": { "$ref": "#/components/schemas/FunctionObject" } }, "required": [ "type", "function" ] }, "FunctionObject": { "type": "object", "properties": { "description": { "type": "string", "description": "A description of what the function does, used by the model to choose when and how to call the function." }, "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." }, "parameters": { "$ref": "#/components/schemas/FunctionParameters" } }, "required": [ "name" ] }, "ChatCompletionToolChoiceOption": { "description": "Controls which (if any) function is called by the model.\n`none` means the model will not call a function and instead generates a message.\n`auto` means the model can pick between generating a message or calling a function.\nSpecifying a particular function via `{\"type: \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that function.\n\n`none` is the default when no functions are present. `auto` is the default if functions are present.\n", "oneOf": [ { "type": "string", "description": "`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.\n", "enum": [ "none", "auto" ] }, { "$ref": "#/components/schemas/ChatCompletionNamedToolChoice" } ], "x-oaiExpandable": true }, "ChatCompletionNamedToolChoice": { "type": "object", "description": "Specifies a tool the model should use. Use to force the model to call a specific function.", "properties": { "type": { "type": "string", "enum": [ "function" ], "description": "The type of the tool. Currently, only `function` is supported." }, "function": { "type": "object", "properties": { "name": { "type": "string", "description": "The name of the function to call." } }, "required": [ "name" ] } }, "required": [ "type", "function" ] }, "ChatCompletionMessageToolCalls": { "type": "array", "description": "The tool calls generated by the model, such as function calls.", "items": { "$ref": "#/components/schemas/ChatCompletionMessageToolCall" } }, "ChatCompletionMessageToolCall": { "type": "object", "properties": { "id": { "type": "string", "description": "The ID of the tool call." }, "type": { "type": "string", "enum": [ "function" ], "description": "The type of the tool. Currently, only `function` is supported." }, "function": { "type": "object", "description": "The function that the model called.", "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": [ "id", "type", "function" ] }, "ChatCompletionMessageToolCallChunk": { "type": "object", "properties": { "index": { "type": "integer" }, "id": { "type": "string", "description": "The ID of the tool call." }, "type": { "type": "string", "enum": [ "function" ], "description": "The type of the tool. Currently, only `function` is supported." }, "function": { "type": "object", "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": [ "index" ] }, "ChatCompletionRole": { "type": "string", "description": "The role of the author of a message", "enum": [ "system", "user", "assistant", "tool", "function" ] }, "ChatCompletionResponseMessage": { "type": "object", "description": "A chat completion message generated by the model.", "properties": { "content": { "type": "string", "description": "The contents of the message.", "nullable": true }, "tool_calls": { "$ref": "#/components/schemas/ChatCompletionMessageToolCalls" }, "role": { "type": "string", "enum": [ "assistant" ], "description": "The role of the author of this message." }, "function_call": { "type": "object", "deprecated": true, "description": "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.", "properties": { "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." }, "name": { "type": "string", "description": "The name of the function to call." } }, "required": [ "name", "arguments" ] } }, "required": [ "role", "content" ] }, "ChatCompletionStreamResponseDelta": { "type": "object", "description": "A chat completion delta generated by streamed model responses.", "properties": { "content": { "type": "string", "description": "The contents of the chunk message.", "nullable": true }, "function_call": { "deprecated": true, "type": "object", "description": "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.", "properties": { "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." }, "name": { "type": "string", "description": "The name of the function to call." } } }, "tool_calls": { "type": "array", "items": { "$ref": "#/components/schemas/ChatCompletionMessageToolCallChunk" } }, "role": { "type": "string", "enum": [ "system", "user", "assistant", "tool" ], "description": "The role of the author of this message." } } }, "CreateChatCompletionRequest": { "type": "object", "properties": { "messages": { "description": "A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models).", "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/ChatCompletionRequestMessage" } }, "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-1106-preview", "gpt-4-vision-preview", "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-1106", "gpt-3.5-turbo-16k-0613" ] } ], "x-oaiTypeLabel": "string" }, "frequency_penalty": { "type": "number", "default": 0, "minimum": -2, "maximum": 2, "nullable": true, "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.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)\n" }, "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.\n\nAccepts 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.\n" }, "logprobs": { "description": "Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. This option is currently not available on the `gpt-4-vision-preview` model.", "type": "boolean", "default": false, "nullable": true }, "top_logprobs": { "description": "An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.", "type": "integer", "minimum": 0, "maximum": 5, "nullable": true }, "max_tokens": { "description": "The maximum number of [tokens](/tokenizer) that can be generated in the chat completion.\n\nThe total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n", "type": "integer", "nullable": true }, "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. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs." }, "presence_penalty": { "type": "number", "default": 0, "minimum": -2, "maximum": 2, "nullable": true, "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.\n\n[See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details)\n" }, "response_format": { "type": "object", "description": "An object specifying the format that the model must output. Compatible with `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.\n\nSetting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is valid JSON.\n\n**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if `finish_reason=\"length\"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.\n", "properties": { "type": { "type": "string", "enum": [ "text", "json_object" ], "example": "json_object", "default": "text", "description": "Must be one of `text` or `json_object`." } } }, "seed": { "type": "integer", "minimum": -9223372036854776000, "maximum": 9223372036854776000, "nullable": true, "description": "This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.\n", "x-oaiMeta": { "beta": true } }, "stop": { "description": "Up to 4 sequences where the API will stop generating further tokens.\n", "default": null, "oneOf": [ { "type": "string", "nullable": true }, { "type": "array", "minItems": 1, "maxItems": 4, "items": { "type": "string" } } ] }, "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://cookbook.openai.com/examples/how_to_stream_completions).\n", "type": "boolean", "nullable": true, "default": false }, "temperature": { "type": "number", "minimum": 0, "maximum": 2, "default": 1, "example": 1, "nullable": true, "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.\n\nWe generally recommend altering this or `top_p` but not both.\n" }, "top_p": { "type": "number", "minimum": 0, "maximum": 1, "default": 1, "example": 1, "nullable": true, "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.\n\nWe generally recommend altering this or `temperature` but not both.\n" }, "tools": { "type": "array", "description": "A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.\n", "items": { "$ref": "#/components/schemas/ChatCompletionTool" } }, "tool_choice": { "$ref": "#/components/schemas/ChatCompletionToolChoiceOption" }, "user": { "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).\n" }, "function_call": { "deprecated": true, "description": "Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n`none` means the model will not call a function and instead generates a message.\n`auto` means the model can pick between generating a message or calling a function.\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n\n`none` is the default when no functions are present. `auto` is the default if functions are present.\n", "oneOf": [ { "type": "string", "description": "`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.\n", "enum": [ "none", "auto" ] }, { "$ref": "#/components/schemas/ChatCompletionFunctionCallOption" } ], "x-oaiExpandable": true }, "functions": { "deprecated": true, "description": "Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.\n", "type": "array", "minItems": 1, "maxItems": 128, "items": { "$ref": "#/components/schemas/ChatCompletionFunctions" } } }, "required": [ "model", "messages" ] }, "CreateChatCompletionResponse": { "type": "object", "description": "Represents a chat completion response returned by model, based on the provided input.", "properties": { "id": { "type": "string", "description": "A unique identifier for the chat completion." }, "choices": { "type": "array", "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1.", "items": { "type": "object", "required": [ "finish_reason", "index", "message", "logprobs" ], "properties": { "finish_reason": { "type": "string", "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n", "enum": [ "stop", "length", "tool_calls", "content_filter", "function_call" ] }, "index": { "type": "integer", "description": "The index of the choice in the list of choices." }, "message": { "$ref": "#/components/schemas/ChatCompletionResponseMessage" }, "logprobs": { "description": "Log probability information for the choice.", "type": "object", "nullable": true, "properties": { "content": { "description": "A list of message content tokens with log probability information.", "type": "array", "items": { "$ref": "#/components/schemas/ChatCompletionTokenLogprob" }, "nullable": true } }, "required": [ "content" ] } } } }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the chat completion was created." }, "model": { "type": "string", "description": "The model used for the chat completion." }, "system_fingerprint": { "type": "string", "description": "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" }, "object": { "type": "string", "description": "The object type, which is always `chat.completion`.", "enum": [ "chat.completion" ] }, "usage": { "$ref": "#/components/schemas/CompletionUsage" } }, "required": [ "choices", "created", "id", "model", "object" ], "x-oaiMeta": { "name": "The chat completion object", "group": "chat", "example": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" } }, "CreateChatCompletionFunctionResponse": { "type": "object", "description": "Represents a chat completion response returned by model, based on the provided input.", "properties": { "id": { "type": "string", "description": "A unique identifier for the chat completion." }, "choices": { "type": "array", "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1.", "items": { "type": "object", "required": [ "finish_reason", "index", "message", "logprobs" ], "properties": { "finish_reason": { "type": "string", "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function.\n", "enum": [ "stop", "length", "function_call", "content_filter" ] }, "index": { "type": "integer", "description": "The index of the choice in the list of choices." }, "message": { "$ref": "#/components/schemas/ChatCompletionResponseMessage" } } } }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the chat completion was created." }, "model": { "type": "string", "description": "The model used for the chat completion." }, "system_fingerprint": { "type": "string", "description": "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" }, "object": { "type": "string", "description": "The object type, which is always `chat.completion`.", "enum": [ "chat.completion" ] }, "usage": { "$ref": "#/components/schemas/CompletionUsage" } }, "required": [ "choices", "created", "id", "model", "object" ], "x-oaiMeta": { "name": "The chat completion object", "group": "chat", "example": "{\n \"id\": \"chatcmpl-abc123\",\n \"object\": \"chat.completion\",\n \"created\": 1699896916,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"choices\": [\n {\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": null,\n \"tool_calls\": [\n {\n \"id\": \"call_abc123\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"arguments\": \"{\\n\\\"location\\\": \\\"Boston, MA\\\"\\n}\"\n }\n }\n ]\n },\n \"logprobs\": null,\n \"finish_reason\": \"tool_calls\"\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 82,\n \"completion_tokens\": 17,\n \"total_tokens\": 99\n }\n}\n" } }, "ChatCompletionTokenLogprob": { "type": "object", "properties": { "token": { "description": "The token.", "type": "string" }, "logprob": { "description": "The log probability of this token.", "type": "number" }, "bytes": { "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.", "type": "array", "items": { "type": "integer" }, "nullable": true }, "top_logprobs": { "description": "List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.", "type": "array", "items": { "type": "object", "properties": { "token": { "description": "The token.", "type": "string" }, "logprob": { "description": "The log probability of this token.", "type": "number" }, "bytes": { "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.", "type": "array", "items": { "type": "integer" }, "nullable": true } }, "required": [ "token", "logprob", "bytes" ] } } }, "required": [ "token", "logprob", "bytes", "top_logprobs" ] }, "ListPaginatedFineTuningJobsResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/FineTuningJob" } }, "has_more": { "type": "boolean" }, "object": { "type": "string", "enum": [ "list" ] } }, "required": [ "object", "data", "has_more" ] }, "CreateChatCompletionStreamResponse": { "type": "object", "description": "Represents a streamed chunk of a chat completion response returned by model, based on the provided input.", "properties": { "id": { "type": "string", "description": "A unique identifier for the chat completion. Each chunk has the same ID." }, "choices": { "type": "array", "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1.", "items": { "type": "object", "required": [ "delta", "finish_reason", "index" ], "properties": { "delta": { "$ref": "#/components/schemas/ChatCompletionStreamResponseDelta" }, "logprobs": { "description": "Log probability information for the choice.", "type": "object", "nullable": true, "properties": { "content": { "description": "A list of message content tokens with log probability information.", "type": "array", "items": { "$ref": "#/components/schemas/ChatCompletionTokenLogprob" }, "nullable": true } }, "required": [ "content" ] }, "finish_reason": { "type": "string", "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n", "enum": [ "stop", "length", "tool_calls", "content_filter", "function_call" ], "nullable": true }, "index": { "type": "integer", "description": "The index of the choice in the list of choices." } } } }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp." }, "model": { "type": "string", "description": "The model to generate the completion." }, "system_fingerprint": { "type": "string", "description": "This fingerprint represents the backend configuration that the model runs with.\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n" }, "object": { "type": "string", "description": "The object type, which is always `chat.completion.chunk`.", "enum": [ "chat.completion.chunk" ] } }, "required": [ "choices", "created", "id", "model", "object" ], "x-oaiMeta": { "name": "The chat completion chunk object", "group": "chat", "example": "{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"!\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n....\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\" today\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{\"content\":\"?\"},\"logprobs\":null,\"finish_reason\":null}]}\n\n{\"id\":\"chatcmpl-123\",\"object\":\"chat.completion.chunk\",\"created\":1694268190,\"model\":\"gpt-3.5-turbo-0613\", \"system_fingerprint\": \"fp_44709d6fcb\", \"choices\":[{\"index\":0,\"delta\":{},\"logprobs\":null,\"finish_reason\":\"stop\"}]}\n" } }, "CreateChatCompletionImageResponse": { "type": "object", "description": "Represents a streamed chunk of a chat completion response returned by model, based on the provided input.", "x-oaiMeta": { "name": "The chat completion chunk object", "group": "chat", "example": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0613\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" } }, "CreateEditRequest": { "type": "object", "properties": { "instruction": { "description": "The instruction that tells the model how to edit the prompt.", "type": "string", "example": "Fix the spelling mistakes." }, "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?" }, "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": "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.\n\nWe generally recommend altering this or `top_p` but not both.\n" }, "top_p": { "type": "number", "minimum": 0, "maximum": 1, "default": 1, "example": 1, "nullable": true, "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.\n\nWe generally recommend altering this or `temperature` but not both.\n" } }, "required": [ "model", "instruction" ] }, "CreateEditResponse": { "type": "object", "deprecated": true, "title": "Edit", "properties": { "choices": { "type": "array", "description": "A list of edit choices. Can be more than one if `n` is greater than 1.", "items": { "type": "object", "required": [ "text", "index", "finish_reason" ], "properties": { "finish_reason": { "type": "string", "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\nor `content_filter` if content was omitted due to a flag from our content filters.\n", "enum": [ "stop", "length" ] }, "index": { "type": "integer", "description": "The index of the choice in the list of choices." }, "text": { "type": "string", "description": "The edited result." } } } }, "object": { "type": "string", "description": "The object type, which is always `edit`.", "enum": [ "edit" ] }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the edit was created." }, "usage": { "$ref": "#/components/schemas/CompletionUsage" } }, "required": [ "object", "created", "choices", "usage" ], "x-oaiMeta": { "name": "The edit object", "example": "{\n \"object\": \"edit\",\n \"created\": 1589478378,\n \"choices\": [\n {\n \"text\": \"What day of the week is it?\",\n \"index\": 0,\n }\n ],\n \"usage\": {\n \"prompt_tokens\": 25,\n \"completion_tokens\": 32,\n \"total_tokens\": 57\n }\n}\n" } }, "CreateImageRequest": { "type": "object", "properties": { "prompt": { "description": "A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`.", "type": "string", "example": "A cute baby sea otter" }, "model": { "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "dall-e-2", "dall-e-3" ] } ], "x-oaiTypeLabel": "string", "default": "dall-e-2", "example": "dall-e-3", "nullable": true, "description": "The model to use for image generation." }, "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. For `dall-e-3`, only `n=1` is supported." }, "quality": { "type": "string", "enum": [ "standard", "hd" ], "default": "standard", "example": "standard", "description": "The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`." }, "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`." }, "size": { "type": "string", "enum": [ "256x256", "512x512", "1024x1024", "1792x1024", "1024x1792" ], "default": "1024x1024", "example": "1024x1024", "nullable": true, "description": "The size of the generated images. 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": { "type": "string", "enum": [ "vivid", "natural" ], "default": "vivid", "example": "vivid", "nullable": true, "description": "The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`." }, "user": { "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).\n" } }, "required": [ "prompt" ] }, "ImagesResponse": { "properties": { "created": { "type": "integer" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Image" } } }, "required": [ "created", "data" ] }, "Image": { "type": "object", "description": "Represents the url or the content of an image generated by the OpenAI API.", "properties": { "b64_json": { "type": "string", "description": "The base64-encoded JSON of the generated image, if `response_format` is `b64_json`." }, "url": { "type": "string", "description": "The URL of the generated image, if `response_format` is `url` (default)." }, "revised_prompt": { "type": "string", "description": "The prompt that was used to generate the image, if there was any revision to the prompt." } }, "x-oaiMeta": { "name": "The image object", "example": "{\n \"url\": \"...\",\n \"revised_prompt\": \"...\"\n}\n" } }, "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" }, "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" }, "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" }, "model": { "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "dall-e-2" ] } ], "x-oaiTypeLabel": "string", "default": "dall-e-2", "example": "dall-e-2", "nullable": true, "description": "The model to use for image generation. Only `dall-e-2` is supported at this time." }, "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": { "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": { "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": { "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).\n" } }, "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" }, "model": { "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "dall-e-2" ] } ], "x-oaiTypeLabel": "string", "default": "dall-e-2", "example": "dall-e-2", "nullable": true, "description": "The model to use for image generation. Only `dall-e-2` is supported at this time." }, "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. For `dall-e-3`, only `n=1` is supported." }, "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`." }, "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`." }, "user": { "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).\n" } }, "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`.\n\nThe 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`.\n", "nullable": false, "default": "text-moderation-latest", "example": "text-moderation-stable", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "text-moderation-latest", "text-moderation-stable" ] } ], "x-oaiTypeLabel": "string" } }, "required": [ "input" ] }, "CreateModerationResponse": { "type": "object", "description": "Represents policy compliance report by OpenAI's content moderation model against a given input.", "properties": { "id": { "type": "string", "description": "The unique identifier for the moderation request." }, "model": { "type": "string", "description": "The model used to generate the moderation results." }, "results": { "type": "array", "description": "A list of moderation objects.", "items": { "type": "object", "properties": { "flagged": { "type": "boolean", "description": "Whether the content violates [OpenAI's usage policies](/policies/usage-policies)." }, "categories": { "type": "object", "description": "A list of the categories, and whether they are flagged or not.", "properties": { "hate": { "type": "boolean", "description": "Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment." }, "hate/threatening": { "type": "boolean", "description": "Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste." }, "harassment": { "type": "boolean", "description": "Content that expresses, incites, or promotes harassing language towards any target." }, "harassment/threatening": { "type": "boolean", "description": "Harassment content that also includes violence or serious harm towards any target." }, "self-harm": { "type": "boolean", "description": "Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders." }, "self-harm/intent": { "type": "boolean", "description": "Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders." }, "self-harm/instructions": { "type": "boolean", "description": "Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts." }, "sexual": { "type": "boolean", "description": "Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness)." }, "sexual/minors": { "type": "boolean", "description": "Sexual content that includes an individual who is under 18 years old." }, "violence": { "type": "boolean", "description": "Content that depicts death, violence, or physical injury." }, "violence/graphic": { "type": "boolean", "description": "Content that depicts death, violence, or physical injury in graphic detail." } }, "required": [ "hate", "hate/threatening", "harassment", "harassment/threatening", "self-harm", "self-harm/intent", "self-harm/instructions", "sexual", "sexual/minors", "violence", "violence/graphic" ] }, "category_scores": { "type": "object", "description": "A list of the categories along with their scores as predicted by model.", "properties": { "hate": { "type": "number", "description": "The score for the category 'hate'." }, "hate/threatening": { "type": "number", "description": "The score for the category 'hate/threatening'." }, "harassment": { "type": "number", "description": "The score for the category 'harassment'." }, "harassment/threatening": { "type": "number", "description": "The score for the category 'harassment/threatening'." }, "self-harm": { "type": "number", "description": "The score for the category 'self-harm'." }, "self-harm/intent": { "type": "number", "description": "The score for the category 'self-harm/intent'." }, "self-harm/instructions": { "type": "number", "description": "The score for the category 'self-harm/instructions'." }, "sexual": { "type": "number", "description": "The score for the category 'sexual'." }, "sexual/minors": { "type": "number", "description": "The score for the category 'sexual/minors'." }, "violence": { "type": "number", "description": "The score for the category 'violence'." }, "violence/graphic": { "type": "number", "description": "The score for the category 'violence/graphic'." } }, "required": [ "hate", "hate/threatening", "harassment", "harassment/threatening", "self-harm", "self-harm/intent", "self-harm/instructions", "sexual", "sexual/minors", "violence", "violence/graphic" ] } }, "required": [ "flagged", "categories", "category_scores" ] } } }, "required": [ "id", "model", "results" ], "x-oaiMeta": { "name": "The moderation object", "example": "{\n \"id\": \"modr-XXXXX\",\n \"model\": \"text-moderation-005\",\n \"results\": [\n {\n \"flagged\": true,\n \"categories\": {\n \"sexual\": false,\n \"hate\": false,\n \"harassment\": false,\n \"self-harm\": false,\n \"sexual/minors\": false,\n \"hate/threatening\": false,\n \"violence/graphic\": false,\n \"self-harm/intent\": false,\n \"self-harm/instructions\": false,\n \"harassment/threatening\": true,\n \"violence\": true,\n },\n \"category_scores\": {\n \"sexual\": 1.2282071e-06,\n \"hate\": 0.010696256,\n \"harassment\": 0.29842457,\n \"self-harm\": 1.5236925e-08,\n \"sexual/minors\": 5.7246268e-08,\n \"hate/threatening\": 0.0060676364,\n \"violence/graphic\": 4.435014e-06,\n \"self-harm/intent\": 8.098441e-10,\n \"self-harm/instructions\": 2.8498655e-11,\n \"harassment/threatening\": 0.63055265,\n \"violence\": 0.99011886,\n }\n }\n ]\n}\n" } }, "ListFilesResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/OpenAIFile" } }, "object": { "type": "string", "enum": [ "list" ] } }, "required": [ "object", "data" ] }, "CreateFileRequest": { "type": "object", "additionalProperties": false, "properties": { "file": { "description": "The File object (not file name) to be uploaded.\n", "type": "string", "format": "binary" }, "purpose": { "description": "The intended purpose of the uploaded file.\n\nUse \"fine-tune\" for [Fine-tuning](/docs/api-reference/fine-tuning) and \"assistants\" for [Assistants](/docs/api-reference/assistants) and [Messages](/docs/api-reference/messages). This allows us to validate the format of the uploaded file is correct for fine-tuning.\n", "type": "string", "enum": [ "fine-tune", "assistants" ] } }, "required": [ "file", "purpose" ] }, "DeleteFileResponse": { "type": "object", "properties": { "id": { "type": "string" }, "object": { "type": "string", "enum": [ "file" ] }, "deleted": { "type": "boolean" } }, "required": [ "id", "object", "deleted" ] }, "CreateFineTuningJobRequest": { "type": "object", "properties": { "model": { "description": "The name of the model to fine-tune. You can select one of the\n[supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned).\n", "example": "gpt-3.5-turbo", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "babbage-002", "davinci-002", "gpt-3.5-turbo" ] } ], "x-oaiTypeLabel": "string" }, "training_file": { "description": "The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/upload) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning) for more details.\n", "type": "string", "example": "file-abc123" }, "hyperparameters": { "type": "object", "description": "The hyperparameters used for the fine-tuning job.", "properties": { "batch_size": { "description": "Number of examples in each batch. A larger batch size means that model parameters\nare updated less frequently, but with lower variance.\n", "oneOf": [ { "type": "string", "enum": [ "auto" ] }, { "type": "integer", "minimum": 1, "maximum": 256 } ], "default": "auto" }, "learning_rate_multiplier": { "description": "Scaling factor for the learning rate. A smaller learning rate may be useful to avoid\noverfitting.\n", "oneOf": [ { "type": "string", "enum": [ "auto" ] }, { "type": "number", "minimum": 0, "exclusiveMinimum": true } ], "default": "auto" }, "n_epochs": { "description": "The number of epochs to train the model for. An epoch refers to one full cycle\nthrough the training dataset.\n", "oneOf": [ { "type": "string", "enum": [ "auto" ] }, { "type": "integer", "minimum": 1, "maximum": 50 } ], "default": "auto" } } }, "suffix": { "description": "A string of up to 18 characters that will be added to your fine-tuned model name.\n\nFor example, a `suffix` of \"custom-model-name\" would produce a model name like `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`.\n", "type": "string", "minLength": 1, "maxLength": 40, "default": null, "nullable": true }, "validation_file": { "description": "The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe fine-tuning results file.\nThe same data should not be present in both train and validation files.\n\nYour dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning) for more details.\n", "type": "string", "nullable": true, "example": "file-abc123" } }, "required": [ "model", "training_file" ] }, "ListFineTuningJobEventsResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/FineTuningJobEvent" } }, "object": { "type": "string", "enum": [ "list" ] } }, "required": [ "object", "data" ] }, "CreateFineTuneRequest": { "type": "object", "properties": { "training_file": { "description": "The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/upload) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file, where each training\nexample is a JSON object with the keys \"prompt\" and \"completion\".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/legacy-fine-tuning/creating-training-data) for more details.\n", "type": "string", "example": "file-abc123" }, "batch_size": { "description": "The batch size to use for training. The batch size is the number of\ntraining examples used to train a single forward and backward pass.\n\nBy default, the batch size will be dynamically configured to be\n~0.2% of the number of examples in the training set, capped at 256 -\nin general, we've found that larger batch sizes tend to work better\nfor larger datasets.\n", "default": null, "type": "integer", "nullable": true }, "classification_betas": { "description": "If this is provided, we calculate F-beta scores at the specified\nbeta values. The F-beta score is a generalization of F-1 score.\nThis is only used for binary classification.\n\nWith a beta of 1 (i.e. the F-1 score), precision and recall are\ngiven the same weight. A larger beta score puts more weight on\nrecall and less on precision. A smaller beta score puts more weight\non precision and less on recall.\n", "type": "array", "items": { "type": "number" }, "example": [ 0.6, 1, 1.5, 2 ], "default": null, "nullable": true }, "classification_n_classes": { "description": "The number of classes in a classification task.\n\nThis parameter is required for multiclass classification.\n", "type": "integer", "default": null, "nullable": true }, "classification_positive_class": { "description": "The positive class in binary classification.\n\nThis parameter is needed to generate precision, recall, and F1\nmetrics when doing binary classification.\n", "type": "string", "default": null, "nullable": true }, "compute_classification_metrics": { "description": "If set, we calculate classification-specific metrics such as accuracy\nand F-1 score using the validation set at the end of every epoch.\nThese metrics can be viewed in the [results file](/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model).\n\nIn order to compute classification metrics, you must provide a\n`validation_file`. Additionally, you must\nspecify `classification_n_classes` for multiclass classification or\n`classification_positive_class` for binary classification.\n", "type": "boolean", "default": false, "nullable": true }, "hyperparameters": { "type": "object", "description": "The hyperparameters used for the fine-tuning job.", "properties": { "n_epochs": { "description": "The number of epochs to train the model for. An epoch refers to one\nfull cycle through the training dataset.\n", "oneOf": [ { "type": "string", "enum": [ "auto" ] }, { "type": "integer", "minimum": 1, "maximum": 50 } ], "default": "auto" } } }, "learning_rate_multiplier": { "description": "The learning rate multiplier to use for training.\nThe fine-tuning learning rate is the original learning rate used for\npretraining multiplied by this value.\n\nBy default, the learning rate multiplier is the 0.05, 0.1, or 0.2\ndepending on final `batch_size` (larger learning rates tend to\nperform better with larger batch sizes). We recommend experimenting\nwith values in the range 0.02 to 0.2 to see what produces the best\nresults.\n", "default": null, "type": "number", "nullable": true }, "model": { "description": "The name of the base model to fine-tune. You can select one of \"ada\",\n\"babbage\", \"curie\", \"davinci\", or a fine-tuned model created after 2022-04-21 and before 2023-08-22.\nTo learn more about these models, see the\n[Models](/docs/models) documentation.\n", "default": "curie", "example": "curie", "nullable": true, "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "ada", "babbage", "curie", "davinci" ] } ], "x-oaiTypeLabel": "string" }, "prompt_loss_weight": { "description": "The weight to use for loss on the prompt tokens. This controls how\nmuch the model tries to learn to generate the prompt (as compared\nto the completion which always has a weight of 1.0), and can add\na stabilizing effect to training when completions are short.\n\nIf prompts are extremely long (relative to completions), it may make\nsense to reduce this weight so as to avoid over-prioritizing\nlearning the prompt.\n", "default": 0.01, "type": "number", "nullable": true }, "suffix": { "description": "A string of up to 40 characters that will be added to your fine-tuned model name.\n\nFor 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`.\n", "type": "string", "minLength": 1, "maxLength": 40, "default": null, "nullable": true }, "validation_file": { "description": "The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe [fine-tuning results file](/docs/guides/legacy-fine-tuning/analyzing-your-fine-tuned-model).\nYour train and validation data should be mutually exclusive.\n\nYour dataset must be formatted as a JSONL file, where each validation\nexample is a JSON object with the keys \"prompt\" and \"completion\".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/legacy-fine-tuning/creating-training-data) for more details.\n", "type": "string", "nullable": true, "example": "file-abc123" } }, "required": [ "training_file" ] }, "ListFineTunesResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/FineTune" } }, "object": { "type": "string", "enum": [ "list" ] } }, "required": [ "object", "data" ] }, "ListFineTuneEventsResponse": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/FineTuneEvent" } }, "object": { "type": "string", "enum": [ "list" ] } }, "required": [ "object", "data" ] }, "CreateEmbeddingRequest": { "type": "object", "additionalProperties": false, "properties": { "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. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.\n", "example": "The quick brown fox jumped over the lazy dog", "oneOf": [ { "type": "string", "title": "string", "description": "The string that will be turned into an embedding.", "default": "", "example": "This is a test." }, { "type": "array", "title": "array", "description": "The array of strings that will be turned into an embedding.", "minItems": 1, "maxItems": 2048, "items": { "type": "string", "default": "", "example": "['This is a test.']" } }, { "type": "array", "title": "array", "description": "The array of integers that will be turned into an embedding.", "minItems": 1, "maxItems": 2048, "items": { "type": "integer" }, "example": "[1212, 318, 257, 1332, 13]" }, { "type": "array", "title": "array", "description": "The array of arrays containing integers that will be turned into an embedding.", "minItems": 1, "maxItems": 2048, "items": { "type": "array", "minItems": 1, "items": { "type": "integer" } }, "example": "[[1212, 318, 257, 1332, 13]]" } ], "x-oaiExpandable": true }, "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.\n", "example": "text-embedding-ada-002", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "text-embedding-ada-002" ] } ], "x-oaiTypeLabel": "string" }, "encoding_format": { "description": "The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).", "example": "float", "default": "float", "type": "string", "enum": [ "float", "base64" ] }, "user": { "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).\n" } }, "required": [ "model", "input" ] }, "CreateEmbeddingResponse": { "type": "object", "properties": { "data": { "type": "array", "description": "The list of embeddings generated by the model.", "items": { "$ref": "#/components/schemas/Embedding" } }, "model": { "type": "string", "description": "The name of the model used to generate the embedding." }, "object": { "type": "string", "description": "The object type, which is always \"list\".", "enum": [ "list" ] }, "usage": { "type": "object", "description": "The usage information for the request.", "properties": { "prompt_tokens": { "type": "integer", "description": "The number of tokens used by the prompt." }, "total_tokens": { "type": "integer", "description": "The total number of tokens used by the request." } }, "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: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", "type": "string", "x-oaiTypeLabel": "file", "format": "binary" }, "model": { "description": "ID of the model to use. Only `whisper-1` is currently available.\n", "example": "whisper-1", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "whisper-1" ] } ], "x-oaiTypeLabel": "string" }, "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.\n", "type": "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.\n", "type": "string" }, "response_format": { "description": "The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.\n", "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.\n", "type": "number", "default": 0 } }, "required": [ "file", "model" ] }, "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: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.\n", "type": "string", "x-oaiTypeLabel": "file", "format": "binary" }, "model": { "description": "ID of the model to use. Only `whisper-1` is currently available.\n", "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.\n", "type": "string" }, "response_format": { "description": "The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.\n", "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.\n", "type": "number", "default": 0 } }, "required": [ "file", "model" ] }, "CreateTranslationResponse": { "type": "object", "properties": { "text": { "type": "string" } }, "required": [ "text" ] }, "CreateSpeechRequest": { "type": "object", "additionalProperties": false, "properties": { "model": { "description": "One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd`\n", "anyOf": [ { "type": "string" }, { "type": "string", "enum": [ "tts-1", "tts-1-hd" ] } ], "x-oaiTypeLabel": "string" }, "input": { "type": "string", "description": "The text to generate audio for. The maximum length is 4096 characters.", "maxLength": 4096 }, "voice": { "description": "The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options).", "type": "string", "enum": [ "alloy", "echo", "fable", "onyx", "nova", "shimmer" ] }, "response_format": { "description": "The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`.", "default": "mp3", "type": "string", "enum": [ "mp3", "opus", "aac", "flac" ] }, "speed": { "description": "The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.", "type": "number", "default": 1, "minimum": 0.25, "maximum": 4 } }, "required": [ "model", "input", "voice" ] }, "Model": { "title": "Model", "description": "Describes an OpenAI model offering that can be used with the API.", "properties": { "id": { "type": "string", "description": "The model identifier, which can be referenced in the API endpoints." }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) when the model was created." }, "object": { "type": "string", "description": "The object type, which is always \"model\".", "enum": [ "model" ] }, "owned_by": { "type": "string", "description": "The organization that owns the model." } }, "required": [ "id", "object", "created", "owned_by" ], "x-oaiMeta": { "name": "The model object", "example": "{\n \"id\": \"VAR_model_id\",\n \"object\": \"model\",\n \"created\": 1686935002,\n \"owned_by\": \"openai\"\n}\n" } }, "OpenAIFile": { "title": "OpenAIFile", "description": "The `File` object represents a document that has been uploaded to OpenAI.", "properties": { "id": { "type": "string", "description": "The file identifier, which can be referenced in the API endpoints." }, "bytes": { "type": "integer", "description": "The size of the file, in bytes." }, "created_at": { "type": "integer", "description": "The Unix timestamp (in seconds) for when the file was created." }, "filename": { "type": "string", "description": "The name of the file." }, "object": { "type": "string", "description": "The object type, which is always `file`.", "enum": [ "file" ] }, "purpose": { "type": "string", "description": "The intended purpose of the file. Supported values are `fine-tune`, `fine-tune-results`, `assistants`, and `assistants_output`.", "enum": [ "fine-tune", "fine-tune-results", "assistants", "assistants_output" ] }, "status": { "type": "string", "deprecated": true, "description": "Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.", "enum": [ "uploaded", "processed", "error" ] }, "status_details": { "type": "string", "deprecated": true, "description": "Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`." } }, "required": [ "id", "object", "bytes", "created_at", "filename", "purpose", "status" ], "x-oaiMeta": { "name": "The File object", "example": "{\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 120000,\n \"created_at\": 1677610602,\n \"filename\": \"salesOverview.pdf\",\n \"purpose\": \"assistants\",\n}\n" } }, "Embedding": { "type": "object", "description": "Represents an embedding vector returned by embedding endpoint.\n", "properties": { "index": { "type": "integer", "description": "The index of the embedding in the list of embeddings." }, "embedding": { "type": "array", "description": "The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings).\n", "items": { "type": "number" } }, "object": { "type": "string", "description": "The object type, which is always \"embedding\".", "enum": [ "embedding" ] } }, "required": [ "index", "object", "embedding" ], "x-oaiMeta": { "name": "The embedding object", "example": "{\n \"object\": \"embedding\",\n \"embedding\": [\n 0.0023064255,\n -0.009327292,\n .... (1536 floats total for ada-002)\n -0.0028842222,\n ],\n \"index\": 0\n}\n" } }, "FineTuningJob": { "type": "object", "title": "FineTuningJob", "description": "The `fine_tuning.job` object represents a fine-tuning job that has been created through the API.\n", "properties": { "id": { "type": "string", "description": "The object identifier, which can be referenced in the API endpoints." }, "created_at": { "type": "integer", "description": "The Unix timestamp (in seconds) for when the fine-tuning job was created." }, "error": { "type": "object", "nullable": true, "description": "For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure.", "properties": { "code": { "type": "string", "description": "A machine-readable error code." }, "message": { "type": "string", "description": "A human-readable error message." }, "param": { "type": "string", "description": "The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific.", "nullable": true } }, "required": [ "code", "message", "param" ] }, "fine_tuned_model": { "type": "string", "nullable": true, "description": "The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running." }, "finished_at": { "type": "integer", "nullable": true, "description": "The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running." }, "hyperparameters": { "type": "object", "description": "The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details.", "properties": { "n_epochs": { "oneOf": [ { "type": "string", "enum": [ "auto" ] }, { "type": "integer", "minimum": 1, "maximum": 50 } ], "default": "auto", "description": "The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset.\n\"auto\" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs." } }, "required": [ "n_epochs" ] }, "model": { "type": "string", "description": "The base model that is being fine-tuned." }, "object": { "type": "string", "description": "The object type, which is always \"fine_tuning.job\".", "enum": [ "fine_tuning.job" ] }, "organization_id": { "type": "string", "description": "The organization that owns the fine-tuning job." }, "result_files": { "type": "array", "description": "The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents).", "items": { "type": "string", "example": "file-abc123" } }, "status": { "type": "string", "description": "The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.", "enum": [ "validating_files", "queued", "running", "succeeded", "failed", "cancelled" ] }, "trained_tokens": { "type": "integer", "nullable": true, "description": "The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running." }, "training_file": { "type": "string", "description": "The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents)." }, "validation_file": { "type": "string", "nullable": true, "description": "The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents)." } }, "required": [ "created_at", "error", "finished_at", "fine_tuned_model", "hyperparameters", "id", "model", "object", "organization_id", "result_files", "status", "trained_tokens", "training_file", "validation_file" ], "x-oaiMeta": { "name": "The fine-tuning job object", "example": "{\n \"object\": \"fine_tuning.job\",\n \"id\": \"ftjob-abc123\",\n \"model\": \"davinci-002\",\n \"created_at\": 1692661014,\n \"finished_at\": 1692661190,\n \"fine_tuned_model\": \"ft:davinci-002:my-org:custom_suffix:7q8mpxmy\",\n \"organization_id\": \"org-123\",\n \"result_files\": [\n \"file-abc123\"\n ],\n \"status\": \"succeeded\",\n \"validation_file\": null,\n \"training_file\": \"file-abc123\",\n \"hyperparameters\": {\n \"n_epochs\": 4,\n },\n \"trained_tokens\": 5768\n}\n" } }, "FineTuningJobEvent": { "type": "object", "description": "Fine-tuning job event object", "properties": { "id": { "type": "string" }, "created_at": { "type": "integer" }, "level": { "type": "string", "enum": [ "info", "warn", "error" ] }, "message": { "type": "string" }, "object": { "type": "string", "enum": [ "fine_tuning.job.event" ] } }, "required": [ "id", "object", "created_at", "level", "message" ], "x-oaiMeta": { "name": "The fine-tuning job event object", "example": "{\n \"object\": \"fine_tuning.job.event\",\n \"id\": \"ftevent-abc123\"\n \"created_at\": 1677610602,\n \"level\": \"info\",\n \"message\": \"Created fine-tuning job\"\n}\n" } }, "FineTune": { "type": "object", "deprecated": true, "description": "The `FineTune` object represents a legacy fine-tune job that has been created through the API.\n", "properties": { "id": { "type": "string", "description": "The object identifier, which can be referenced in the API endpoints." }, "created_at": { "type": "integer", "description": "The Unix timestamp (in seconds) for when the fine-tuning job was created." }, "events": { "type": "array", "description": "The list of events that have been observed in the lifecycle of the FineTune job.", "items": { "$ref": "#/components/schemas/FineTuneEvent" } }, "fine_tuned_model": { "type": "string", "nullable": true, "description": "The name of the fine-tuned model that is being created." }, "hyperparams": { "type": "object", "description": "The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/legacy-fine-tuning/hyperparameters) for more details.", "properties": { "batch_size": { "type": "integer", "description": "The batch size to use for training. The batch size is the number of\ntraining examples used to train a single forward and backward pass.\n" }, "classification_n_classes": { "type": "integer", "description": "The number of classes to use for computing classification metrics.\n" }, "classification_positive_class": { "type": "string", "description": "The positive class to use for computing classification metrics.\n" }, "compute_classification_metrics": { "type": "boolean", "description": "The classification metrics to compute using the validation dataset at the end of every epoch.\n" }, "learning_rate_multiplier": { "type": "number", "description": "The learning rate multiplier to use for training.\n" }, "n_epochs": { "type": "integer", "description": "The number of epochs to train the model for. An epoch refers to one\nfull cycle through the training dataset.\n" }, "prompt_loss_weight": { "type": "number", "description": "The weight to use for loss on the prompt tokens.\n" } }, "required": [ "batch_size", "learning_rate_multiplier", "n_epochs", "prompt_loss_weight" ] }, "model": { "type": "string", "description": "The base model that is being fine-tuned." }, "object": { "type": "string", "description": "The object type, which is always \"fine-tune\".", "enum": [ "fine-tune" ] }, "organization_id": { "type": "string", "description": "The organization that owns the fine-tuning job." }, "result_files": { "type": "array", "description": "The compiled results files for the fine-tuning job.", "items": { "$ref": "#/components/schemas/OpenAIFile" } }, "status": { "type": "string", "description": "The current status of the fine-tuning job, which can be either `created`, `running`, `succeeded`, `failed`, or `cancelled`." }, "training_files": { "type": "array", "description": "The list of files used for training.", "items": { "$ref": "#/components/schemas/OpenAIFile" } }, "updated_at": { "type": "integer", "description": "The Unix timestamp (in seconds) for when the fine-tuning job was last updated." }, "validation_files": { "type": "array", "description": "The list of files used for validation.", "items": { "$ref": "#/components/schemas/OpenAIFile" } } }, "required": [ "created_at", "fine_tuned_model", "hyperparams", "id", "model", "object", "organization_id", "result_files", "status", "training_files", "updated_at", "validation_files" ], "x-oaiMeta": { "name": "The fine-tune object", "example": "{\n \"id\": \"ft-abc123\",\n \"object\": \"fine-tune\",\n \"model\": \"curie\",\n \"created_at\": 1614807352,\n \"events\": [\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807352,\n \"level\": \"info\",\n \"message\": \"Job enqueued. Waiting for jobs ahead to complete. Queue number: 0.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807356,\n \"level\": \"info\",\n \"message\": \"Job started.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807861,\n \"level\": \"info\",\n \"message\": \"Uploaded snapshot: curie:ft-acmeco-2021-03-03-21-44-20.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Uploaded result files: file-abc123.\"\n },\n {\n \"object\": \"fine-tune-event\",\n \"created_at\": 1614807864,\n \"level\": \"info\",\n \"message\": \"Job succeeded.\"\n }\n ],\n \"fine_tuned_model\": \"curie:ft-acmeco-2021-03-03-21-44-20\",\n \"hyperparams\": {\n \"batch_size\": 4,\n \"learning_rate_multiplier\": 0.1,\n \"n_epochs\": 4,\n \"prompt_loss_weight\": 0.1,\n },\n \"organization_id\": \"org-123\",\n \"result_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 81509,\n \"created_at\": 1614807863,\n \"filename\": \"compiled_results.csv\",\n \"purpose\": \"fine-tune-results\"\n }\n ],\n \"status\": \"succeeded\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune\"\n }\n ],\n \"updated_at\": 1614807865,\n}\n" } }, "FineTuneEvent": { "type": "object", "deprecated": true, "description": "Fine-tune event object", "properties": { "created_at": { "type": "integer" }, "level": { "type": "string" }, "message": { "type": "string" }, "object": { "type": "string", "enum": [ "fine-tune-event" ] } }, "required": [ "object", "created_at", "level", "message" ], "x-oaiMeta": { "name": "The fine-tune event object", "example": "{\n \"object\": \"fine-tune-event\",\n \"created_at\": 1677610602,\n \"level\": \"info\",\n \"message\": \"Created fine-tune job\"\n}\n" } }, "CompletionUsage": { "type": "object", "description": "Usage statistics for the completion request.", "properties": { "completion_tokens": { "type": "integer", "description": "Number of tokens in the generated completion." }, "prompt_tokens": { "type": "integer", "description": "Number of tokens in the prompt." }, "total_tokens": { "type": "integer", "description": "Total number of tokens used in the request (prompt + completion)." } }, "required": [ "prompt_tokens", "completion_tokens", "total_tokens" ] }, "AssistantObject": { "type": "object", "title": "Assistant", "description": "Represents an `assistant` that can call the model and use tools.", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `assistant`.", "type": "string", "enum": [ "assistant" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the assistant was created.", "type": "integer" }, "name": { "description": "The name of the assistant. The maximum length is 256 characters.\n", "type": "string", "maxLength": 256, "nullable": true }, "description": { "description": "The description of the assistant. The maximum length is 512 characters.\n", "type": "string", "maxLength": 512, "nullable": true }, "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.\n", "type": "string" }, "instructions": { "description": "The system instructions that the assistant uses. The maximum length is 32768 characters.\n", "type": "string", "maxLength": 32768, "nullable": true }, "tools": { "description": "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.\n", "default": [], "type": "array", "maxItems": 128, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ], "x-oaiExpandable": true } }, "file_ids": { "description": "A list of [file](/docs/api-reference/files) IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.\n", "default": [], "type": "array", "maxItems": 20, "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "id", "object", "created_at", "name", "description", "model", "instructions", "tools", "file_ids", "metadata" ], "x-oaiMeta": { "name": "The assistant object", "beta": true, "example": "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698984975,\n \"name\": \"Math Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" } }, "CreateAssistantRequest": { "type": "object", "additionalProperties": false, "properties": { "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.\n", "anyOf": [ { "type": "string" } ] }, "name": { "description": "The name of the assistant. The maximum length is 256 characters.\n", "type": "string", "nullable": true, "maxLength": 256 }, "description": { "description": "The description of the assistant. The maximum length is 512 characters.\n", "type": "string", "nullable": true, "maxLength": 512 }, "instructions": { "description": "The system instructions that the assistant uses. The maximum length is 32768 characters.\n", "type": "string", "nullable": true, "maxLength": 32768 }, "tools": { "description": "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.\n", "default": [], "type": "array", "maxItems": 128, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ], "x-oaiExpandable": true } }, "file_ids": { "description": "A list of [file](/docs/api-reference/files) IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.\n", "default": [], "maxItems": 20, "type": "array", "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "model" ] }, "ModifyAssistantRequest": { "type": "object", "additionalProperties": false, "properties": { "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.\n", "anyOf": [ { "type": "string" } ] }, "name": { "description": "The name of the assistant. The maximum length is 256 characters.\n", "type": "string", "nullable": true, "maxLength": 256 }, "description": { "description": "The description of the assistant. The maximum length is 512 characters.\n", "type": "string", "nullable": true, "maxLength": 512 }, "instructions": { "description": "The system instructions that the assistant uses. The maximum length is 32768 characters.\n", "type": "string", "nullable": true, "maxLength": 32768 }, "tools": { "description": "A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`.\n", "default": [], "type": "array", "maxItems": 128, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ], "x-oaiExpandable": true } }, "file_ids": { "description": "A list of [File](/docs/api-reference/files) IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previously attached to the list but does not show up in the list, it will be deleted from the assistant.\n", "default": [], "type": "array", "maxItems": 20, "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "DeleteAssistantResponse": { "type": "object", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" }, "object": { "type": "string", "enum": [ "assistant.deleted" ] } }, "required": [ "id", "object", "deleted" ] }, "ListAssistantsResponse": { "type": "object", "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/AssistantObject" } }, "first_id": { "type": "string", "example": "asst_abc123" }, "last_id": { "type": "string", "example": "asst_abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "first_id", "last_id", "has_more" ], "x-oaiMeta": { "name": "List assistants response object", "group": "chat", "example": "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698982736,\n \"name\": \"Coding Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc456\",\n \"object\": \"assistant\",\n \"created_at\": 1698982718,\n \"name\": \"My Assistant\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc789\",\n \"object\": \"assistant\",\n \"created_at\": 1698982643,\n \"name\": null,\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"asst_abc123\",\n \"last_id\": \"asst_abc789\",\n \"has_more\": false\n}\n" } }, "AssistantToolsCode": { "type": "object", "title": "Code interpreter tool", "properties": { "type": { "type": "string", "description": "The type of tool being defined: `code_interpreter`", "enum": [ "code_interpreter" ] } }, "required": [ "type" ] }, "AssistantToolsRetrieval": { "type": "object", "title": "Retrieval tool", "properties": { "type": { "type": "string", "description": "The type of tool being defined: `retrieval`", "enum": [ "retrieval" ] } }, "required": [ "type" ] }, "AssistantToolsFunction": { "type": "object", "title": "Function tool", "properties": { "type": { "type": "string", "description": "The type of tool being defined: `function`", "enum": [ "function" ] }, "function": { "$ref": "#/components/schemas/FunctionObject" } }, "required": [ "type", "function" ] }, "RunObject": { "type": "object", "title": "A run on a thread", "description": "Represents an execution run on a [thread](/docs/api-reference/threads).", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `thread.run`.", "type": "string", "enum": [ "thread.run" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the run was created.", "type": "integer" }, "thread_id": { "description": "The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run.", "type": "string" }, "assistant_id": { "description": "The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run.", "type": "string" }, "status": { "description": "The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, or `expired`.", "type": "string", "enum": [ "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "expired" ] }, "required_action": { "type": "object", "description": "Details on the action required to continue the run. Will be `null` if no action is required.", "nullable": true, "properties": { "type": { "description": "For now, this is always `submit_tool_outputs`.", "type": "string", "enum": [ "submit_tool_outputs" ] }, "submit_tool_outputs": { "type": "object", "description": "Details on the tool outputs needed for this run to continue.", "properties": { "tool_calls": { "type": "array", "description": "A list of the relevant tool calls.", "items": { "$ref": "#/components/schemas/RunToolCallObject" } } }, "required": [ "tool_calls" ] } }, "required": [ "type", "submit_tool_outputs" ] }, "last_error": { "type": "object", "description": "The last error associated with this run. Will be `null` if there are no errors.", "nullable": true, "properties": { "code": { "type": "string", "description": "One of `server_error` or `rate_limit_exceeded`.", "enum": [ "server_error", "rate_limit_exceeded" ] }, "message": { "type": "string", "description": "A human-readable description of the error." } }, "required": [ "code", "message" ] }, "expires_at": { "description": "The Unix timestamp (in seconds) for when the run will expire.", "type": "integer" }, "started_at": { "description": "The Unix timestamp (in seconds) for when the run was started.", "type": "integer", "nullable": true }, "cancelled_at": { "description": "The Unix timestamp (in seconds) for when the run was cancelled.", "type": "integer", "nullable": true }, "failed_at": { "description": "The Unix timestamp (in seconds) for when the run failed.", "type": "integer", "nullable": true }, "completed_at": { "description": "The Unix timestamp (in seconds) for when the run was completed.", "type": "integer", "nullable": true }, "model": { "description": "The model that the [assistant](/docs/api-reference/assistants) used for this run.", "type": "string" }, "instructions": { "description": "The instructions that the [assistant](/docs/api-reference/assistants) used for this run.", "type": "string" }, "tools": { "description": "The list of tools that the [assistant](/docs/api-reference/assistants) used for this run.", "default": [], "type": "array", "maxItems": 20, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ], "x-oaiExpandable": true } }, "file_ids": { "description": "The list of [File](/docs/api-reference/files) IDs the [assistant](/docs/api-reference/assistants) used for this run.", "default": [], "type": "array", "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "id", "object", "created_at", "thread_id", "assistant_id", "status", "required_action", "last_error", "expires_at", "started_at", "cancelled_at", "failed_at", "completed_at", "model", "instructions", "tools", "file_ids", "metadata" ], "x-oaiMeta": { "name": "The run object", "beta": true, "example": "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1698107661,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699073476,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699073498,\n \"last_error\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [{\"type\": \"retrieval\"}, {\"type\": \"code_interpreter\"}],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" } }, "CreateRunRequest": { "type": "object", "additionalProperties": false, "properties": { "assistant_id": { "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.", "type": "string" }, "model": { "description": "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.", "type": "string", "nullable": true }, "instructions": { "description": "Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.", "type": "string", "nullable": true }, "additional_instructions": { "description": "Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.", "type": "string", "nullable": true }, "tools": { "description": "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.", "nullable": true, "type": "array", "maxItems": 20, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ], "x-oaiExpandable": true } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "thread_id", "assistant_id" ] }, "ListRunsResponse": { "type": "object", "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/RunObject" } }, "first_id": { "type": "string", "example": "run_abc123" }, "last_id": { "type": "string", "example": "run_abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "first_id", "last_id", "has_more" ] }, "ModifyRunRequest": { "type": "object", "additionalProperties": false, "properties": { "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "SubmitToolOutputsRunRequest": { "type": "object", "additionalProperties": false, "properties": { "tool_outputs": { "description": "A list of tools for which the outputs are being submitted.", "type": "array", "items": { "type": "object", "properties": { "tool_call_id": { "type": "string", "description": "The ID of the tool call in the `required_action` object within the run object the output is being submitted for." }, "output": { "type": "string", "description": "The output of the tool call to be submitted to continue the run." } } } } }, "required": [ "tool_outputs" ] }, "RunToolCallObject": { "type": "object", "description": "Tool call objects", "properties": { "id": { "type": "string", "description": "The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint." }, "type": { "type": "string", "description": "The type of tool call the output is required for. For now, this is always `function`.", "enum": [ "function" ] }, "function": { "type": "object", "description": "The function definition.", "properties": { "name": { "type": "string", "description": "The name of the function." }, "arguments": { "type": "string", "description": "The arguments that the model expects you to pass to the function." } }, "required": [ "name", "arguments" ] } }, "required": [ "id", "type", "function" ] }, "CreateThreadAndRunRequest": { "type": "object", "additionalProperties": false, "properties": { "assistant_id": { "description": "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run.", "type": "string" }, "thread": { "$ref": "#/components/schemas/CreateThreadRequest", "description": "If no thread is provided, an empty thread will be created." }, "model": { "description": "The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.", "type": "string", "nullable": true }, "instructions": { "description": "Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.", "type": "string", "nullable": true }, "tools": { "description": "Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.", "nullable": true, "type": "array", "maxItems": 20, "items": { "oneOf": [ { "$ref": "#/components/schemas/AssistantToolsCode" }, { "$ref": "#/components/schemas/AssistantToolsRetrieval" }, { "$ref": "#/components/schemas/AssistantToolsFunction" } ] } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "thread_id", "assistant_id" ] }, "ThreadObject": { "type": "object", "title": "Thread", "description": "Represents a thread that contains [messages](/docs/api-reference/messages).", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `thread`.", "type": "string", "enum": [ "thread" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the thread was created.", "type": "integer" }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "id", "object", "created_at", "metadata" ], "x-oaiMeta": { "name": "The thread object", "beta": true, "example": "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1698107661,\n \"metadata\": {}\n}\n" } }, "CreateThreadRequest": { "type": "object", "additionalProperties": false, "properties": { "messages": { "description": "A list of [messages](/docs/api-reference/messages) to start the thread with.", "type": "array", "items": { "$ref": "#/components/schemas/CreateMessageRequest" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "ModifyThreadRequest": { "type": "object", "additionalProperties": false, "properties": { "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "DeleteThreadResponse": { "type": "object", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" }, "object": { "type": "string", "enum": [ "thread.deleted" ] } }, "required": [ "id", "object", "deleted" ] }, "ListThreadsResponse": { "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/ThreadObject" } }, "first_id": { "type": "string", "example": "asst_abc123" }, "last_id": { "type": "string", "example": "asst_abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "first_id", "last_id", "has_more" ] }, "MessageObject": { "type": "object", "title": "The message object", "description": "Represents a message within a [thread](/docs/api-reference/threads).", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `thread.message`.", "type": "string", "enum": [ "thread.message" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the message was created.", "type": "integer" }, "thread_id": { "description": "The [thread](/docs/api-reference/threads) ID that this message belongs to.", "type": "string" }, "role": { "description": "The entity that produced the message. One of `user` or `assistant`.", "type": "string", "enum": [ "user", "assistant" ] }, "content": { "description": "The content of the message in array of text and/or images.", "type": "array", "items": { "oneOf": [ { "$ref": "#/components/schemas/MessageContentImageFileObject" }, { "$ref": "#/components/schemas/MessageContentTextObject" } ], "x-oaiExpandable": true } }, "assistant_id": { "description": "If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message.", "type": "string", "nullable": true }, "run_id": { "description": "If applicable, the ID of the [run](/docs/api-reference/runs) associated with the authoring of this message.", "type": "string", "nullable": true }, "file_ids": { "description": "A list of [file](/docs/api-reference/files) IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files. A maximum of 10 files can be attached to a message.", "default": [], "maxItems": 10, "type": "array", "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "id", "object", "created_at", "thread_id", "role", "content", "assistant_id", "run_id", "file_ids", "metadata" ], "x-oaiMeta": { "name": "The message object", "beta": true, "example": "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1698983503,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"assistant\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"Hi! How can I help you today?\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"assistant_id\": \"asst_abc123\",\n \"run_id\": \"run_abc123\",\n \"metadata\": {}\n}\n" } }, "CreateMessageRequest": { "type": "object", "additionalProperties": false, "required": [ "role", "content" ], "properties": { "role": { "type": "string", "enum": [ "user" ], "description": "The role of the entity that is creating the message. Currently only `user` is supported." }, "content": { "type": "string", "minLength": 1, "maxLength": 32768, "description": "The content of the message." }, "file_ids": { "description": "A list of [File](/docs/api-reference/files) IDs that the message should use. There can be a maximum of 10 files attached to a message. Useful for tools like `retrieval` and `code_interpreter` that can access and use files.", "default": [], "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string" } }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "ModifyMessageRequest": { "type": "object", "additionalProperties": false, "properties": { "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } } }, "DeleteMessageResponse": { "type": "object", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" }, "object": { "type": "string", "enum": [ "thread.message.deleted" ] } }, "required": [ "id", "object", "deleted" ] }, "ListMessagesResponse": { "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/MessageObject" } }, "first_id": { "type": "string", "example": "msg_abc123" }, "last_id": { "type": "string", "example": "msg_abc123" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "first_id", "last_id", "has_more" ] }, "MessageContentImageFileObject": { "title": "Image file", "type": "object", "description": "References an image [File](/docs/api-reference/files) in the content of a message.", "properties": { "type": { "description": "Always `image_file`.", "type": "string", "enum": [ "image_file" ] }, "image_file": { "type": "object", "properties": { "file_id": { "description": "The [File](/docs/api-reference/files) ID of the image in the message content.", "type": "string" } }, "required": [ "file_id" ] } }, "required": [ "type", "image_file" ] }, "MessageContentTextObject": { "title": "Text", "type": "object", "description": "The text content that is part of a message.", "properties": { "type": { "description": "Always `text`.", "type": "string", "enum": [ "text" ] }, "text": { "type": "object", "properties": { "value": { "description": "The data that makes up the text.", "type": "string" }, "annotations": { "type": "array", "items": { "oneOf": [ { "$ref": "#/components/schemas/MessageContentTextAnnotationsFileCitationObject" }, { "$ref": "#/components/schemas/MessageContentTextAnnotationsFilePathObject" } ], "x-oaiExpandable": true } } }, "required": [ "value", "annotations" ] } }, "required": [ "type", "text" ] }, "MessageContentTextAnnotationsFileCitationObject": { "title": "File citation", "type": "object", "description": "A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the \"retrieval\" tool to search files.", "properties": { "type": { "description": "Always `file_citation`.", "type": "string", "enum": [ "file_citation" ] }, "text": { "description": "The text in the message content that needs to be replaced.", "type": "string" }, "file_citation": { "type": "object", "properties": { "file_id": { "description": "The ID of the specific File the citation is from.", "type": "string" }, "quote": { "description": "The specific quote in the file.", "type": "string" } }, "required": [ "file_id", "quote" ] }, "start_index": { "type": "integer", "minimum": 0 }, "end_index": { "type": "integer", "minimum": 0 } }, "required": [ "type", "text", "file_citation", "start_index", "end_index" ] }, "MessageContentTextAnnotationsFilePathObject": { "title": "File path", "type": "object", "description": "A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.", "properties": { "type": { "description": "Always `file_path`.", "type": "string", "enum": [ "file_path" ] }, "text": { "description": "The text in the message content that needs to be replaced.", "type": "string" }, "file_path": { "type": "object", "properties": { "file_id": { "description": "The ID of the file that was generated.", "type": "string" } }, "required": [ "file_id" ] }, "start_index": { "type": "integer", "minimum": 0 }, "end_index": { "type": "integer", "minimum": 0 } }, "required": [ "type", "text", "file_path", "start_index", "end_index" ] }, "RunStepObject": { "type": "object", "title": "Run steps", "description": "Represents a step in execution of a run.\n", "properties": { "id": { "description": "The identifier of the run step, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `thread.run.step`.", "type": "string", "enum": [ "thread.run.step" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the run step was created.", "type": "integer" }, "assistant_id": { "description": "The ID of the [assistant](/docs/api-reference/assistants) associated with the run step.", "type": "string" }, "thread_id": { "description": "The ID of the [thread](/docs/api-reference/threads) that was run.", "type": "string" }, "run_id": { "description": "The ID of the [run](/docs/api-reference/runs) that this run step is a part of.", "type": "string" }, "type": { "description": "The type of run step, which can be either `message_creation` or `tool_calls`.", "type": "string", "enum": [ "message_creation", "tool_calls" ] }, "status": { "description": "The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`.", "type": "string", "enum": [ "in_progress", "cancelled", "failed", "completed", "expired" ] }, "step_details": { "type": "object", "description": "The details of the run step.", "oneOf": [ { "$ref": "#/components/schemas/RunStepDetailsMessageCreationObject" }, { "$ref": "#/components/schemas/RunStepDetailsToolCallsObject" } ], "x-oaiExpandable": true }, "last_error": { "type": "object", "description": "The last error associated with this run step. Will be `null` if there are no errors.", "nullable": true, "properties": { "code": { "type": "string", "description": "One of `server_error` or `rate_limit_exceeded`.", "enum": [ "server_error", "rate_limit_exceeded" ] }, "message": { "type": "string", "description": "A human-readable description of the error." } }, "required": [ "code", "message" ] }, "expired_at": { "description": "The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired.", "type": "integer", "nullable": true }, "cancelled_at": { "description": "The Unix timestamp (in seconds) for when the run step was cancelled.", "type": "integer", "nullable": true }, "failed_at": { "description": "The Unix timestamp (in seconds) for when the run step failed.", "type": "integer", "nullable": true }, "completed_at": { "description": "The Unix timestamp (in seconds) for when the run step completed.", "type": "integer", "nullable": true }, "metadata": { "description": "Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.\n", "type": "object", "x-oaiTypeLabel": "map", "nullable": true } }, "required": [ "id", "object", "created_at", "assistant_id", "thread_id", "run_id", "type", "status", "step_details", "last_error", "expired_at", "cancelled_at", "failed_at", "completed_at", "metadata" ], "x-oaiMeta": { "name": "The run step object", "beta": true, "example": "{\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n }\n}\n" } }, "ListRunStepsResponse": { "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/RunStepObject" } }, "first_id": { "type": "string", "example": "step_abc123" }, "last_id": { "type": "string", "example": "step_abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "first_id", "last_id", "has_more" ] }, "RunStepDetailsMessageCreationObject": { "title": "Message creation", "type": "object", "description": "Details of the message creation by the run step.", "properties": { "type": { "description": "Always `message_creation`.", "type": "string", "enum": [ "message_creation" ] }, "message_creation": { "type": "object", "properties": { "message_id": { "type": "string", "description": "The ID of the message that was created by this run step." } }, "required": [ "message_id" ] } }, "required": [ "type", "message_creation" ] }, "RunStepDetailsToolCallsObject": { "title": "Tool calls", "type": "object", "description": "Details of the tool call.", "properties": { "type": { "description": "Always `tool_calls`.", "type": "string", "enum": [ "tool_calls" ] }, "tool_calls": { "type": "array", "description": "An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `retrieval`, or `function`.\n", "items": { "type": "object", "oneOf": [ { "$ref": "#/components/schemas/RunStepDetailsToolCallsCodeObject" }, { "$ref": "#/components/schemas/RunStepDetailsToolCallsRetrievalObject" }, { "$ref": "#/components/schemas/RunStepDetailsToolCallsFunctionObject" } ], "x-oaiExpandable": true } } }, "required": [ "type", "tool_calls" ] }, "RunStepDetailsToolCallsCodeObject": { "title": "Code interpreter tool call", "type": "object", "description": "Details of the Code Interpreter tool call the run step was involved in.", "properties": { "id": { "type": "string", "description": "The ID of the tool call." }, "type": { "type": "string", "description": "The type of tool call. This is always going to be `code_interpreter` for this type of tool call.", "enum": [ "code_interpreter" ] }, "code_interpreter": { "type": "object", "description": "The Code Interpreter tool call definition.", "required": [ "input", "outputs" ], "properties": { "input": { "type": "string", "description": "The input to the Code Interpreter tool call." }, "outputs": { "type": "array", "description": "The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type.", "items": { "type": "object", "oneOf": [ { "$ref": "#/components/schemas/RunStepDetailsToolCallsCodeOutputLogsObject" }, { "$ref": "#/components/schemas/RunStepDetailsToolCallsCodeOutputImageObject" } ], "x-oaiExpandable": true } } } } }, "required": [ "id", "type", "code_interpreter" ] }, "RunStepDetailsToolCallsCodeOutputLogsObject": { "title": "Code interpreter log output", "type": "object", "description": "Text output from the Code Interpreter tool call as part of a run step.", "properties": { "type": { "description": "Always `logs`.", "type": "string", "enum": [ "logs" ] }, "logs": { "type": "string", "description": "The text output from the Code Interpreter tool call." } }, "required": [ "type", "logs" ] }, "RunStepDetailsToolCallsCodeOutputImageObject": { "title": "Code interpreter image output", "type": "object", "properties": { "type": { "description": "Always `image`.", "type": "string", "enum": [ "image" ] }, "image": { "type": "object", "properties": { "file_id": { "description": "The [file](/docs/api-reference/files) ID of the image.", "type": "string" } }, "required": [ "file_id" ] } }, "required": [ "type", "image" ] }, "RunStepDetailsToolCallsRetrievalObject": { "title": "Retrieval tool call", "type": "object", "properties": { "id": { "type": "string", "description": "The ID of the tool call object." }, "type": { "type": "string", "description": "The type of tool call. This is always going to be `retrieval` for this type of tool call.", "enum": [ "retrieval" ] }, "retrieval": { "type": "object", "description": "For now, this is always going to be an empty object.", "x-oaiTypeLabel": "map" } }, "required": [ "id", "type", "retrieval" ] }, "RunStepDetailsToolCallsFunctionObject": { "type": "object", "title": "Function tool call", "properties": { "id": { "type": "string", "description": "The ID of the tool call object." }, "type": { "type": "string", "description": "The type of tool call. This is always going to be `function` for this type of tool call.", "enum": [ "function" ] }, "function": { "type": "object", "description": "The definition of the function that was called.", "properties": { "name": { "type": "string", "description": "The name of the function." }, "arguments": { "type": "string", "description": "The arguments passed to the function." }, "output": { "type": "string", "description": "The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet.", "nullable": true } }, "required": [ "name", "arguments", "output" ] } }, "required": [ "id", "type", "function" ] }, "AssistantFileObject": { "type": "object", "title": "Assistant files", "description": "A list of [Files](/docs/api-reference/files) attached to an `assistant`.", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `assistant.file`.", "type": "string", "enum": [ "assistant.file" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the assistant file was created.", "type": "integer" }, "assistant_id": { "description": "The assistant ID that the file is attached to.", "type": "string" } }, "required": [ "id", "object", "created_at", "assistant_id" ], "x-oaiMeta": { "name": "The assistant file object", "beta": true, "example": "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" } }, "CreateAssistantFileRequest": { "type": "object", "additionalProperties": false, "properties": { "file_id": { "description": "A [File](/docs/api-reference/files) ID (with `purpose=\"assistants\"`) that the assistant should use. Useful for tools like `retrieval` and `code_interpreter` that can access files.", "type": "string" } }, "required": [ "file_id" ] }, "DeleteAssistantFileResponse": { "type": "object", "description": "Deletes the association between the assistant and the file, but does not delete the [File](/docs/api-reference/files) object itself.", "properties": { "id": { "type": "string" }, "deleted": { "type": "boolean" }, "object": { "type": "string", "enum": [ "assistant.file.deleted" ] } }, "required": [ "id", "object", "deleted" ] }, "ListAssistantFilesResponse": { "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/AssistantFileObject" } }, "first_id": { "type": "string", "example": "file-abc123" }, "last_id": { "type": "string", "example": "file-abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "items", "first_id", "last_id", "has_more" ] }, "MessageFileObject": { "type": "object", "title": "Message files", "description": "A list of files attached to a `message`.", "properties": { "id": { "description": "The identifier, which can be referenced in API endpoints.", "type": "string" }, "object": { "description": "The object type, which is always `thread.message.file`.", "type": "string", "enum": [ "thread.message.file" ] }, "created_at": { "description": "The Unix timestamp (in seconds) for when the message file was created.", "type": "integer" }, "message_id": { "description": "The ID of the [message](/docs/api-reference/messages) that the [File](/docs/api-reference/files) is attached to.", "type": "string" } }, "required": [ "id", "object", "created_at", "message_id" ], "x-oaiMeta": { "name": "The message file object", "beta": true, "example": "{\n \"id\": \"file-abc123\",\n \"object\": \"thread.message.file\",\n \"created_at\": 1698107661,\n \"message_id\": \"message_QLoItBbqwyAJEzlTy4y9kOMM\",\n \"file_id\": \"file-abc123\"\n}\n" } }, "ListMessageFilesResponse": { "properties": { "object": { "type": "string", "example": "list" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/MessageFileObject" } }, "first_id": { "type": "string", "example": "file-abc123" }, "last_id": { "type": "string", "example": "file-abc456" }, "has_more": { "type": "boolean", "example": false } }, "required": [ "object", "data", "items", "first_id", "last_id", "has_more" ] } } }, "security": [ { "ApiKeyAuth": [] } ], "x-oaiMeta": { "groups": [ { "id": "audio", "title": "Audio", "description": "Learn how to turn audio into text or text into audio.\n\nRelated guide: [Speech to text](/docs/guides/speech-to-text)\n", "sections": [ { "type": "endpoint", "key": "createSpeech", "path": "createSpeech" }, { "type": "endpoint", "key": "createTranscription", "path": "createTranscription" }, { "type": "endpoint", "key": "createTranslation", "path": "createTranslation" } ] }, { "id": "chat", "title": "Chat", "description": "Given a list of messages comprising a conversation, the model will return a response.\n\nRelated guide: [Chat Completions](/docs/guides/text-generation)\n", "sections": [ { "type": "object", "key": "CreateChatCompletionResponse", "path": "object" }, { "type": "object", "key": "CreateChatCompletionStreamResponse", "path": "streaming" }, { "type": "endpoint", "key": "createChatCompletion", "path": "create" } ] }, { "id": "embeddings", "title": "Embeddings", "description": "Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.\n\nRelated guide: [Embeddings](/docs/guides/embeddings)\n", "sections": [ { "type": "object", "key": "Embedding", "path": "object" }, { "type": "endpoint", "key": "createEmbedding", "path": "create" } ] }, { "id": "fine-tuning", "title": "Fine-tuning", "description": "Manage fine-tuning jobs to tailor a model to your specific training data.\n\nRelated guide: [Fine-tune models](/docs/guides/fine-tuning)\n", "sections": [ { "type": "object", "key": "FineTuningJob", "path": "object" }, { "type": "endpoint", "key": "createFineTuningJob", "path": "create" }, { "type": "endpoint", "key": "listPaginatedFineTuningJobs", "path": "list" }, { "type": "endpoint", "key": "retrieveFineTuningJob", "path": "retrieve" }, { "type": "endpoint", "key": "cancelFineTuningJob", "path": "cancel" }, { "type": "object", "key": "FineTuningJobEvent", "path": "event-object" }, { "type": "endpoint", "key": "listFineTuningEvents", "path": "list-events" } ] }, { "id": "files", "title": "Files", "description": "Files are used to upload documents that can be used with features like [Assistants](/docs/api-reference/assistants) and [Fine-tuning](/docs/api-reference/fine-tuning).\n", "sections": [ { "type": "object", "key": "OpenAIFile", "path": "object" }, { "type": "endpoint", "key": "listFiles", "path": "list" }, { "type": "endpoint", "key": "createFile", "path": "create" }, { "type": "endpoint", "key": "deleteFile", "path": "delete" }, { "type": "endpoint", "key": "retrieveFile", "path": "retrieve" }, { "type": "endpoint", "key": "downloadFile", "path": "retrieve-contents" } ] }, { "id": "images", "title": "Images", "description": "Given a prompt and/or an input image, the model will generate a new image.\n\nRelated guide: [Image generation](/docs/guides/images)\n", "sections": [ { "type": "object", "key": "Image", "path": "object" }, { "type": "endpoint", "key": "createImage", "path": "create" }, { "type": "endpoint", "key": "createImageEdit", "path": "createEdit" }, { "type": "endpoint", "key": "createImageVariation", "path": "createVariation" } ] }, { "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.\n", "sections": [ { "type": "object", "key": "Model", "path": "object" }, { "type": "endpoint", "key": "listModels", "path": "list" }, { "type": "endpoint", "key": "retrieveModel", "path": "retrieve" }, { "type": "endpoint", "key": "deleteModel", "path": "delete" } ] }, { "id": "moderations", "title": "Moderations", "description": "Given a input text, outputs if the model classifies it as violating OpenAI's content policy.\n\nRelated guide: [Moderations](/docs/guides/moderation)\n", "sections": [ { "type": "object", "key": "CreateModerationResponse", "path": "object" }, { "type": "endpoint", "key": "createModeration", "path": "create" } ] }, { "id": "assistants", "title": "Assistants", "beta": true, "description": "Build assistants that can call models and use tools to perform tasks.\n\n[Get started with the Assistants API](/docs/assistants)\n", "sections": [ { "type": "object", "key": "AssistantObject", "path": "object" }, { "type": "endpoint", "key": "createAssistant", "path": "createAssistant" }, { "type": "endpoint", "key": "getAssistant", "path": "getAssistant" }, { "type": "endpoint", "key": "modifyAssistant", "path": "modifyAssistant" }, { "type": "endpoint", "key": "deleteAssistant", "path": "deleteAssistant" }, { "type": "endpoint", "key": "listAssistants", "path": "listAssistants" }, { "type": "object", "key": "AssistantFileObject", "path": "file-object" }, { "type": "endpoint", "key": "createAssistantFile", "path": "createAssistantFile" }, { "type": "endpoint", "key": "getAssistantFile", "path": "getAssistantFile" }, { "type": "endpoint", "key": "deleteAssistantFile", "path": "deleteAssistantFile" }, { "type": "endpoint", "key": "listAssistantFiles", "path": "listAssistantFiles" } ] }, { "id": "threads", "title": "Threads", "beta": true, "description": "Create threads that assistants can interact with.\n\nRelated guide: [Assistants](/docs/assistants/overview)\n", "sections": [ { "type": "object", "key": "ThreadObject", "path": "object" }, { "type": "endpoint", "key": "createThread", "path": "createThread" }, { "type": "endpoint", "key": "getThread", "path": "getThread" }, { "type": "endpoint", "key": "modifyThread", "path": "modifyThread" }, { "type": "endpoint", "key": "deleteThread", "path": "deleteThread" } ] }, { "id": "messages", "title": "Messages", "beta": true, "description": "Create messages within threads\n\nRelated guide: [Assistants](/docs/assistants/overview)\n", "sections": [ { "type": "object", "key": "MessageObject", "path": "object" }, { "type": "endpoint", "key": "createMessage", "path": "createMessage" }, { "type": "endpoint", "key": "getMessage", "path": "getMessage" }, { "type": "endpoint", "key": "modifyMessage", "path": "modifyMessage" }, { "type": "endpoint", "key": "listMessages", "path": "listMessages" }, { "type": "object", "key": "MessageFileObject", "path": "file-object" }, { "type": "endpoint", "key": "getMessageFile", "path": "getMessageFile" }, { "type": "endpoint", "key": "listMessageFiles", "path": "listMessageFiles" } ] }, { "id": "runs", "title": "Runs", "beta": true, "description": "Represents an execution run on a thread.\n\nRelated guide: [Assistants](/docs/assistants/overview)\n", "sections": [ { "type": "object", "key": "RunObject", "path": "object" }, { "type": "endpoint", "key": "createRun", "path": "createRun" }, { "type": "endpoint", "key": "getRun", "path": "getRun" }, { "type": "endpoint", "key": "modifyRun", "path": "modifyRun" }, { "type": "endpoint", "key": "listRuns", "path": "listRuns" }, { "type": "endpoint", "key": "submitToolOuputsToRun", "path": "submitToolOutputs" }, { "type": "endpoint", "key": "cancelRun", "path": "cancelRun" }, { "type": "endpoint", "key": "createThreadAndRun", "path": "createThreadAndRun" }, { "type": "object", "key": "RunStepObject", "path": "step-object" }, { "type": "endpoint", "key": "getRunStep", "path": "getRunStep" }, { "type": "endpoint", "key": "listRunSteps", "path": "listRunSteps" } ] }, { "id": "completions", "title": "Completions", "legacy": true, "description": "Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. Most models that support the legacy Completions endpoint [will be shut off on January 4th, 2024](/docs/deprecations/2023-07-06-gpt-and-embeddings).\n", "sections": [ { "type": "object", "key": "CreateCompletionResponse", "path": "object" }, { "type": "endpoint", "key": "createCompletion", "path": "create" } ] }, { "id": "edits", "title": "Edits", "deprecated": true, "description": "Given a prompt and an instruction, the model will return an edited version of the prompt. The Edits endpoint is deprecated will be [shut off on January 4th, 2024](/docs/deprecations/edit-models-endpoint).\n", "sections": [ { "type": "object", "key": "CreateEditResponse", "path": "object" }, { "type": "endpoint", "key": "createEdit", "path": "create" } ] }, { "id": "fine-tunes", "title": "Fine-tunes", "deprecated": true, "description": "Manage fine-tuning jobs to tailor a model to your specific training data. The [updated Fine-tuning endpoint](/docs/guides/fine-tuning) offers more capabilites and newer models.\n\nThe Fine-tunes endpoint will be [shut off on January 4th, 2024](/docs/deprecations/2023-08-22-fine-tunes-endpoint).\n", "sections": [ { "type": "object", "key": "FineTune", "path": "object" }, { "type": "endpoint", "key": "createFineTune", "path": "create" }, { "type": "endpoint", "key": "listFineTunes", "path": "list" }, { "type": "endpoint", "key": "retrieveFineTune", "path": "retrieve" }, { "type": "endpoint", "key": "cancelFineTune", "path": "cancel" }, { "type": "object", "key": "FineTuneEvent", "path": "event-object" }, { "type": "endpoint", "key": "listFineTuneEvents", "path": "list-events" } ] } ] } }