From 1d78a78b1dfdcda805bab91a9bc642be8c00427f Mon Sep 17 00:00:00 2001 From: Kyle Corbitt Date: Mon, 26 Jun 2023 12:36:34 -0700 Subject: [PATCH] validate json schema for openai api --- .eslintrc.cjs | 1 + package.json | 7 +- pnpm-lock.yaml | 78 +- src/codegen/export-openai-schema.ts | 45 + src/codegen/openai.schema.json | 2879 +++++++++++++++++ .../OutputsTable/ScenarioEditor.tsx | 2 +- .../OutputsTable/VariantConfigEditor.tsx | 25 +- 7 files changed, 3027 insertions(+), 10 deletions(-) create mode 100644 src/codegen/export-openai-schema.ts create mode 100644 src/codegen/openai.schema.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs index cf5257c..016e2dd 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -28,6 +28,7 @@ const config = { ], "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-unsafe-assignment": "off", }, }; diff --git a/package.json b/package.json index 41e89b9..5fcedb2 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "dev": "next dev", "postinstall": "prisma generate", "lint": "next lint", - "start": "next start" + "start": "next start", + "codegen": "tsx src/codegen/export-openai-schema.ts" }, "dependencies": { "@chakra-ui/next-js": "^2.1.4", @@ -41,6 +42,7 @@ "zod": "^3.21.4" }, "devDependencies": { + "@openapi-contrib/openapi-schema-to-json-schema": "^4.0.5", "@types/eslint": "^8.37.0", "@types/lodash": "^4.14.195", "@types/node": "^18.16.0", @@ -51,7 +53,8 @@ "eslint": "^8.40.0", "eslint-config-next": "^13.4.2", "prisma": "^4.14.0", - "typescript": "^5.0.4" + "typescript": "^5.0.4", + "yaml": "^2.3.1" }, "ct3aMetadata": { "initVersion": "7.14.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 809385a..1e3f488 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -91,6 +91,9 @@ dependencies: version: 3.21.4 devDependencies: + '@openapi-contrib/openapi-schema-to-json-schema': + specifier: ^4.0.5 + version: 4.0.5 '@types/eslint': specifier: ^8.37.0 version: 8.37.0 @@ -124,6 +127,9 @@ devDependencies: typescript: specifier: ^5.0.4 version: 5.0.4 + yaml: + specifier: ^2.3.1 + version: 2.3.1 packages: @@ -1840,6 +1846,15 @@ packages: fastq: 1.15.0 dev: true + /@openapi-contrib/openapi-schema-to-json-schema@4.0.5: + resolution: {integrity: sha512-E6s9hfQx125CfGXW5896s0ZtUEecTS69KvqkNDPxKomeZ/Y2rNsG90yO8K47uchXqKw5RhD/rCNcOJ2VODfQiw==} + dependencies: + '@types/json-schema': 7.0.12 + '@types/node': 20.3.1 + fast-deep-equal: 3.1.3 + openapi-typescript: 5.4.1 + dev: true + /@panva/hkdf@1.1.1: resolution: {integrity: sha512-dhPeilub1NuIG0X5Kvhh9lH4iW3ZsHlnzwgwbOlgwQ2wG1IqFzsgHqmKPk3WzsdWAeaxKJxgM0+W433RmN45GA==} dev: false @@ -2030,6 +2045,10 @@ packages: resolution: {integrity: sha512-BsAaKhB+7X+H4GnSjGhJG9Qi8Tw+inU9nJDwmD5CgOmBLEI6ArdhikpLX7DjbjDRDTbqZzU2LSQNZg8WGPiSZQ==} dev: true + /@types/node@20.3.1: + resolution: {integrity: sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==} + dev: true + /@types/parse-json@4.0.0: resolution: {integrity: sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==} dev: false @@ -2386,7 +2405,6 @@ packages: engines: {node: '>=10.16.0'} dependencies: streamsearch: 1.1.0 - dev: false /call-bind@1.0.2: resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} @@ -3273,6 +3291,10 @@ packages: define-properties: 1.2.0 dev: true + /globalyzer@0.1.0: + resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} + dev: true + /globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -3296,6 +3318,10 @@ packages: slash: 4.0.0 dev: true + /globrex@0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + dev: true + /gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} dependencies: @@ -3713,6 +3739,12 @@ packages: picomatch: 2.3.1 dev: true + /mime@3.0.0: + resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} + engines: {node: '>=10.0.0'} + hasBin: true + dev: true + /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -3954,6 +3986,19 @@ packages: is-wsl: 2.2.0 dev: true + /openapi-typescript@5.4.1: + resolution: {integrity: sha512-AGB2QiZPz4rE7zIwV3dRHtoUC/CWHhUjuzGXvtmMQN2AFV8xCTLKcZUHLcdPQmt/83i22nRE7+TxXOXkK+gf4Q==} + engines: {node: '>= 14.0.0'} + hasBin: true + dependencies: + js-yaml: 4.1.0 + mime: 3.0.0 + prettier: 2.8.8 + tiny-glob: 0.2.9 + undici: 5.22.1 + yargs-parser: 21.1.1 + dev: true + /openid-client@5.4.2: resolution: {integrity: sha512-lIhsdPvJ2RneBm3nGBBhQchpe3Uka//xf7WPHTIglery8gnckvW7Bd9IaQzekzXJvWthCMyi/xVEyGW0RFPytw==} dependencies: @@ -4067,6 +4112,12 @@ packages: engines: {node: '>= 0.8.0'} dev: true + /prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} + engines: {node: '>=10.13.0'} + hasBin: true + dev: true + /pretty-format@3.8.0: resolution: {integrity: sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==} dev: false @@ -4409,7 +4460,6 @@ packages: /streamsearch@1.1.0: resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} engines: {node: '>=10.0.0'} - dev: false /string.prototype.matchall@4.0.8: resolution: {integrity: sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==} @@ -4560,6 +4610,13 @@ packages: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: false + /tiny-glob@0.2.9: + resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} + dependencies: + globalyzer: 0.1.0 + globrex: 0.1.2 + dev: true + /tiny-invariant@1.3.1: resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==} dev: false @@ -4660,6 +4717,13 @@ packages: which-boxed-primitive: 1.0.2 dev: true + /undici@5.22.1: + resolution: {integrity: sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw==} + engines: {node: '>=14.0'} + dependencies: + busboy: 1.6.0 + dev: true + /untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} engines: {node: '>=8'} @@ -4808,6 +4872,16 @@ packages: engines: {node: '>= 6'} dev: false + /yaml@2.3.1: + resolution: {integrity: sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==} + engines: {node: '>= 14'} + dev: true + + /yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + dev: true + /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} diff --git a/src/codegen/export-openai-schema.ts b/src/codegen/export-openai-schema.ts new file mode 100644 index 0000000..60bba8f --- /dev/null +++ b/src/codegen/export-openai-schema.ts @@ -0,0 +1,45 @@ +import YAML from "yaml"; +import fs from "fs"; +import path from "path"; +import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema"; +import assert from "assert"; + +const OPENAPI_URL = + "https://raw.githubusercontent.com/openai/openai-openapi/0c432eb66fd0c758fd8b9bd69db41c1096e5f4db/openapi.yaml"; + +const convertOpenApiToJsonSchema = async (url: string) => { + // Fetch the openapi document + const response = await fetch(url); + const openApiYaml = await response.text(); + + // Parse the yaml document + const openApiDocument = YAML.parse(openApiYaml) as unknown; + + // Convert the openapi schema to json schema + const jsonSchema = openapiSchemaToJsonSchema(openApiDocument); + + const modelProperty = jsonSchema.components.schemas.CreateChatCompletionRequest.properties.model; + + assert(modelProperty.oneOf.length === 2, "Expected model to have oneOf length of 2"); + + // We need to do a bit of surgery here since the Monaco editor doesn't like + // the fact that the schema says `model` can be either a string or an enum, + // and displays a warning in the editor. Let's stick with just an enum for + // now and drop the string option. + modelProperty.type = "string"; + modelProperty.enum = modelProperty.oneOf[1].enum; + modelProperty.oneOf = undefined; + + // Get the directory of the current script + const currentDirectory = path.dirname(import.meta.url).replace("file://", ""); + + // Write the JSON schema to a file in the current directory + fs.writeFileSync( + path.join(currentDirectory, "openai.schema.json"), + JSON.stringify(jsonSchema, null, 2) + ); +}; + +convertOpenApiToJsonSchema(OPENAPI_URL) + .then(() => console.log("JSON schema has been written successfully.")) + .catch((err) => console.error(err)); diff --git a/src/codegen/openai.schema.json b/src/codegen/openai.schema.json new file mode 100644 index 0000000..c4aa4ff --- /dev/null +++ b/src/codegen/openai.schema.json @@ -0,0 +1,2879 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "OpenAI API", + "description": "APIs for sampling from and fine-tuning language models", + "version": "2.0.0" + }, + "servers": [ + { + "url": "https://api.openai.com/v1" + } + ], + "tags": [ + { + "name": "OpenAI", + "description": "The OpenAI REST API" + } + ], + "paths": { + "/chat/completions": { + "post": { + "operationId": "createChatCompletion", + "tags": [ + "OpenAI" + ], + "summary": "Creates a model response for the given chat conversation.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateChatCompletionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateChatCompletionResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create chat completion", + "group": "chat", + "path": "create", + "beta": true, + "examples": { + "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\": [{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, {\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\n\ncompletion = openai.ChatCompletion.create(\n model=\"gpt-3.5-turbo\",\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": "const { Configuration, OpenAIApi } = require(\"openai\");\n\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\n\nconst completion = await openai.createChatCompletion({\n model: \"gpt-3.5-turbo\",\n messages: [{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, {role: \"user\", content: \"Hello world\"}],\n});\nconsole.log(completion.data.choices[0].message);\n" + }, + "parameters": "{\n \"model\": \"gpt-3.5-turbo\",\n \"messages\": [{\"role\": \"system\", \"content\": \"You are a helpful assistant.\"}, {\"role\": \"user\", \"content\": \"Hello!\"}]\n}\n", + "response": "{\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"\\n\\nHello there, how may I assist you today?\",\n },\n \"finish_reason\": \"stop\"\n }],\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n}\n" + } + } + }, + "/completions": { + "post": { + "operationId": "createCompletion", + "tags": [ + "OpenAI" + ], + "summary": "Creates a completion for the provided prompt and parameters.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCompletionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateCompletionResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create completion", + "group": "completions", + "path": "create", + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Completion.create(\n model=\"VAR_model_id\",\n prompt=\"Say this is a test\",\n max_tokens=7,\n temperature=0\n)\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createCompletion({\n model: \"VAR_model_id\",\n prompt: \"Say this is a test\",\n max_tokens: 7,\n temperature: 0,\n});\n" + }, + "parameters": "{\n \"model\": \"VAR_model_id\",\n \"prompt\": \"Say this is a test\",\n \"max_tokens\": 7,\n \"temperature\": 0,\n \"top_p\": 1,\n \"n\": 1,\n \"stream\": false,\n \"logprobs\": null,\n \"stop\": \"\\n\"\n}\n", + "response": "{\n \"id\": \"cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7\",\n \"object\": \"text_completion\",\n \"created\": 1589478378,\n \"model\": \"VAR_model_id\",\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" + } + } + }, + "/edits": { + "post": { + "operationId": "createEdit", + "tags": [ + "OpenAI" + ], + "summary": "Creates a new edit for the provided input, instruction, and parameters.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEditRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEditResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create edit", + "group": "edits", + "path": "create", + "examples": { + "curl": "curl https://api.openai.com/v1/edits \\\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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Edit.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": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createEdit({\n model: \"VAR_model_id\",\n input: \"What day of the wek is it?\",\n instruction: \"Fix the spelling mistakes\",\n});\n" + }, + "parameters": "{\n \"model\": \"VAR_model_id\",\n \"input\": \"What day of the wek is it?\",\n \"instruction\": \"Fix the spelling mistakes\"\n}\n", + "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": [ + "OpenAI" + ], + "summary": "Creates an image given a prompt.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateImageRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create image", + "group": "images", + "path": "create", + "beta": true, + "examples": { + "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 \"prompt\": \"A cute baby sea otter\",\n \"n\": 2,\n \"size\": \"1024x1024\"\n }'\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create(\n prompt=\"A cute baby sea otter\",\n n=2,\n size=\"1024x1024\"\n)\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImage({\n prompt: \"A cute baby sea otter\",\n n: 2,\n size: \"1024x1024\",\n});\n" + }, + "parameters": "{\n \"prompt\": \"A cute baby sea otter\",\n \"n\": 2,\n \"size\": \"1024x1024\"\n}\n", + "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": [ + "OpenAI" + ], + "summary": "Creates an edited or extended image given an original image and a prompt.", + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateImageEditRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create image edit", + "group": "images", + "path": "create-edit", + "beta": true, + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create_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": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImageEdit(\n fs.createReadStream(\"otter.png\"),\n fs.createReadStream(\"mask.png\"),\n \"A cute baby sea otter wearing a beret\",\n 2,\n \"1024x1024\"\n);\n" + }, + "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": [ + "OpenAI" + ], + "summary": "Creates a variation of a given image.", + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateImageVariationRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ImagesResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create image variation", + "group": "images", + "path": "create-variation", + "beta": true, + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Image.create_variation(\n image=open(\"otter.png\", \"rb\"),\n n=2,\n size=\"1024x1024\"\n)\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createImageVariation(\n fs.createReadStream(\"otter.png\"),\n 2,\n \"1024x1024\"\n);\n" + }, + "response": "{\n \"created\": 1589478378,\n \"data\": [\n {\n \"url\": \"https://...\"\n },\n {\n \"url\": \"https://...\"\n }\n ]\n}\n" + } + } + }, + "/embeddings": { + "post": { + "operationId": "createEmbedding", + "tags": [ + "OpenAI" + ], + "summary": "Creates an embedding vector representing the input text.", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEmbeddingRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateEmbeddingResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create embeddings", + "group": "embeddings", + "path": "create", + "examples": { + "curl": "curl https://api.openai.com/v1/embeddings \\\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 }'\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Embedding.create(\n model=\"text-embedding-ada-002\",\n input=\"The food was delicious and the waiter...\"\n)\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createEmbedding({\n model: \"text-embedding-ada-002\",\n input: \"The food was delicious and the waiter...\",\n});\n" + }, + "parameters": "{\n \"model\": \"text-embedding-ada-002\",\n \"input\": \"The food was delicious and the waiter...\"\n}\n", + "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/transcriptions": { + "post": { + "operationId": "createTranscription", + "tags": [ + "OpenAI" + ], + "summary": "Transcribes audio into the input language.", + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateTranscriptionRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTranscriptionResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create transcription", + "group": "audio", + "path": "create", + "beta": true, + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\naudio_file = open(\"audio.mp3\", \"rb\")\ntranscript = openai.Audio.transcribe(\"whisper-1\", audio_file)\n", + "node": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst resp = await openai.createTranscription(\n fs.createReadStream(\"audio.mp3\"),\n \"whisper-1\"\n);\n" + }, + "parameters": "{\n \"file\": \"audio.mp3\",\n \"model\": \"whisper-1\"\n}\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": [ + "OpenAI" + ], + "summary": "Translates audio into English.", + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateTranslationRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTranslationResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create translation", + "group": "audio", + "path": "create", + "beta": true, + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\naudio_file = open(\"german.m4a\", \"rb\")\ntranscript = openai.Audio.translate(\"whisper-1\", audio_file)\n", + "node": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst resp = await openai.createTranslation(\n fs.createReadStream(\"audio.mp3\"),\n \"whisper-1\"\n);\n" + }, + "parameters": "{\n \"file\": \"german.m4a\",\n \"model\": \"whisper-1\"\n}\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": [ + "OpenAI" + ], + "summary": "Returns a list of files that belong to the user's organization.", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListFilesResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "List files", + "group": "files", + "path": "list", + "examples": { + "curl": "curl https://api.openai.com/v1/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.list()\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFiles();\n" + }, + "response": "{\n \"data\": [\n {\n \"id\": \"file-ccdDZrC3iZVNiQVeEA6Z66wf\",\n \"object\": \"file\",\n \"bytes\": 175,\n \"created_at\": 1613677385,\n \"filename\": \"train.jsonl\",\n \"purpose\": \"search\"\n },\n {\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"puppy.jsonl\",\n \"purpose\": \"search\"\n }\n ],\n \"object\": \"list\"\n}\n" + } + }, + "post": { + "operationId": "createFile", + "tags": [ + "OpenAI" + ], + "summary": "Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.\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", + "path": "upload", + "examples": { + "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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.create(\n file=open(\"mydata.jsonl\", \"rb\"),\n purpose='fine-tune'\n)\n", + "node.js": "const fs = require(\"fs\");\nconst { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createFile(\n fs.createReadStream(\"mydata.jsonl\"),\n \"fine-tune\"\n);\n" + }, + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779121,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\"\n}\n" + } + } + }, + "/files/{file_id}": { + "delete": { + "operationId": "deleteFile", + "tags": [ + "OpenAI" + ], + "summary": "Delete a file.", + "parameters": [ + { + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + }, + "description": "The ID of the file to use for this request" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteFileResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Delete file", + "group": "files", + "path": "delete", + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.delete(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.deleteFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n" + }, + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"deleted\": true\n}\n" + } + }, + "get": { + "operationId": "retrieveFile", + "tags": [ + "OpenAI" + ], + "summary": "Returns information about a specific file.", + "parameters": [ + { + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + }, + "description": "The ID of the file to use for this request" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OpenAIFile" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Retrieve file", + "group": "files", + "path": "retrieve", + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.File.retrieve(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n" + }, + "response": "{\n \"id\": \"file-XjGxS3KTG0uNmNOK362iJua3\",\n \"object\": \"file\",\n \"bytes\": 140,\n \"created_at\": 1613779657,\n \"filename\": \"mydata.jsonl\",\n \"purpose\": \"fine-tune\"\n}\n" + } + } + }, + "/files/{file_id}/content": { + "get": { + "operationId": "downloadFile", + "tags": [ + "OpenAI" + ], + "summary": "Returns the contents of the specified file", + "parameters": [ + { + "in": "path", + "name": "file_id", + "required": true, + "schema": { + "type": "string" + }, + "description": "The ID of the file to use for this request" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Retrieve file content", + "group": "files", + "path": "retrieve-content", + "examples": { + "curl": "curl https://api.openai.com/v1/files/file-XjGxS3KTG0uNmNOK362iJua3/content \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" > file.jsonl\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\ncontent = openai.File.download(\"file-XjGxS3KTG0uNmNOK362iJua3\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.downloadFile(\"file-XjGxS3KTG0uNmNOK362iJua3\");\n" + } + } + } + }, + "/fine-tunes": { + "post": { + "operationId": "createFineTune", + "tags": [ + "OpenAI" + ], + "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/CreateFineTuneRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FineTune" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create fine-tune", + "group": "fine-tunes", + "path": "create", + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -d '{\n \"training_file\": \"file-XGinujblHPwGLSztz8cPS8XY\"\n }'\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.create(training_file=\"file-XGinujblHPwGLSztz8cPS8XY\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createFineTune({\n training_file: \"file-XGinujblHPwGLSztz8cPS8XY\",\n});\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-...\",\n \"result_files\": [],\n \"status\": \"pending\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807352,\n}\n" + } + }, + "get": { + "operationId": "listFineTunes", + "tags": [ + "OpenAI" + ], + "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", + "path": "list", + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.list()\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFineTunes();\n" + }, + "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-...\",\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", + "tags": [ + "OpenAI" + ], + "summary": "Gets info about the fine-tune job.\n\n[Learn more about Fine-tuning](/docs/guides/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", + "path": "retrieve", + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.retrieve(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveFineTune(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\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 \"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-QQm6ZpqdNwAaVC3aSz5sWwLT.\"\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-...\",\n \"result_files\": [\n {\n \"id\": \"file-QQm6ZpqdNwAaVC3aSz5sWwLT\",\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-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807865,\n}\n" + } + } + }, + "/fine-tunes/{fine_tune_id}/cancel": { + "post": { + "operationId": "cancelFineTune", + "tags": [ + "OpenAI" + ], + "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", + "path": "cancel", + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.cancel(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.cancelFineTune(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n" + }, + "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-...\",\n \"result_files\": [],\n \"status\": \"cancelled\",\n \"validation_files\": [],\n \"training_files\": [\n {\n \"id\": \"file-XGinujblHPwGLSztz8cPS8XY\",\n \"object\": \"file\",\n \"bytes\": 1547276,\n \"created_at\": 1610062281,\n \"filename\": \"my-data-train.jsonl\",\n \"purpose\": \"fine-tune-train\"\n }\n ],\n \"updated_at\": 1614807789,\n}\n" + } + } + }, + "/fine-tunes/{fine_tune_id}/events": { + "get": { + "operationId": "listFineTuneEvents", + "tags": [ + "OpenAI" + ], + "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", + "path": "events", + "examples": { + "curl": "curl https://api.openai.com/v1/fine-tunes/ft-AF1WoRqd3aJAHsqc9NY7iL8F/events \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.FineTune.list_events(id=\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listFineTuneEvents(\"ft-AF1WoRqd3aJAHsqc9NY7iL8F\");\n" + }, + "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-QQm6ZpqdNwAaVC3aSz5sWwLT.\"\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": [ + "OpenAI" + ], + "summary": "Lists the currently available models, and provides basic information about each one such as the owner and availability.", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListModelsResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "List models", + "group": "models", + "path": "list", + "examples": { + "curl": "curl https://api.openai.com/v1/models \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.list()\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.listModels();\n" + }, + "response": "{\n \"data\": [\n {\n \"id\": \"model-id-0\",\n \"object\": \"model\",\n \"owned_by\": \"organization-owner\",\n \"permission\": [...]\n },\n {\n \"id\": \"model-id-1\",\n \"object\": \"model\",\n \"owned_by\": \"organization-owner\",\n \"permission\": [...]\n },\n {\n \"id\": \"model-id-2\",\n \"object\": \"model\",\n \"owned_by\": \"openai\",\n \"permission\": [...]\n },\n ],\n \"object\": \"list\"\n}\n" + } + } + }, + "/models/{model}": { + "get": { + "operationId": "retrieveModel", + "tags": [ + "OpenAI" + ], + "summary": "Retrieves a model instance, providing basic information about the model such as the owner and permissioning.", + "parameters": [ + { + "in": "path", + "name": "model", + "required": true, + "schema": { + "type": "string", + "example": "text-davinci-001" + }, + "description": "The ID of the model to use for this request" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Model" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Retrieve model", + "group": "models", + "path": "retrieve", + "examples": { + "curl": "curl https://api.openai.com/v1/models/VAR_model_id \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.retrieve(\"VAR_model_id\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.retrieveModel(\"VAR_model_id\");\n" + }, + "response": "{\n \"id\": \"VAR_model_id\",\n \"object\": \"model\",\n \"owned_by\": \"openai\",\n \"permission\": [...]\n}\n" + } + }, + "delete": { + "operationId": "deleteModel", + "tags": [ + "OpenAI" + ], + "summary": "Delete a fine-tuned model. You must have the Owner role in your organization.", + "parameters": [ + { + "in": "path", + "name": "model", + "required": true, + "schema": { + "type": "string", + "example": "curie:ft-acmeco-2021-03-03-21-44-20" + }, + "description": "The model to delete" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteModelResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Delete fine-tune model", + "group": "fine-tunes", + "path": "delete-model", + "examples": { + "curl": "curl https://api.openai.com/v1/models/curie:ft-acmeco-2021-03-03-21-44-20 \\\n -X DELETE \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\"\n", + "python": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Model.delete(\"curie:ft-acmeco-2021-03-03-21-44-20\")\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.deleteModel('curie:ft-acmeco-2021-03-03-21-44-20');\n" + }, + "response": "{\n \"id\": \"curie:ft-acmeco-2021-03-03-21-44-20\",\n \"object\": \"model\",\n \"deleted\": true\n}\n" + } + } + }, + "/moderations": { + "post": { + "operationId": "createModeration", + "tags": [ + "OpenAI" + ], + "summary": "Classifies if text violates OpenAI's Content Policy", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateModerationRequest" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateModerationResponse" + } + } + } + } + }, + "x-oaiMeta": { + "name": "Create moderation", + "group": "moderations", + "path": "create", + "examples": { + "curl": "curl https://api.openai.com/v1/moderations \\\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": "import os\nimport openai\nopenai.api_key = os.getenv(\"OPENAI_API_KEY\")\nopenai.Moderation.create(\n input=\"I want to kill them.\",\n)\n", + "node.js": "const { Configuration, OpenAIApi } = require(\"openai\");\nconst configuration = new Configuration({\n apiKey: process.env.OPENAI_API_KEY,\n});\nconst openai = new OpenAIApi(configuration);\nconst response = await openai.createModeration({\n input: \"I want to kill them.\",\n});\n" + }, + "parameters": "{\n \"input\": \"I want to kill them.\"\n}\n", + "response": "{\n \"id\": \"modr-5MWoLO\",\n \"model\": \"text-moderation-001\",\n \"results\": [\n {\n \"categories\": {\n \"hate\": false,\n \"hate/threatening\": true,\n \"self-harm\": false,\n \"sexual\": false,\n \"sexual/minors\": false,\n \"violence\": true,\n \"violence/graphic\": false\n },\n \"category_scores\": {\n \"hate\": 0.22714105248451233,\n \"hate/threatening\": 0.4132447838783264,\n \"self-harm\": 0.005232391878962517,\n \"sexual\": 0.01407341007143259,\n \"sexual/minors\": 0.0038522258400917053,\n \"violence\": 0.9223177433013916,\n \"violence/graphic\": 0.036865197122097015\n },\n \"flagged\": true\n }\n ]\n}\n" + } + } + } + }, + "components": { + "schemas": { + "Error": { + "type": "object", + "properties": { + "type": { + "type": "string", + "nullable": false + }, + "message": { + "type": "string", + "nullable": false + }, + "param": { + "type": "string", + "nullable": true + }, + "code": { + "type": "string", + "nullable": true + } + }, + "required": [ + "type", + "message", + "param", + "code" + ] + }, + "ErrorResponse": { + "type": "object", + "properties": { + "error": { + "$ref": "#/components/schemas/Error" + } + }, + "required": [ + "error" + ] + }, + "ListModelsResponse": { + "type": "object", + "properties": { + "object": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Model" + } + } + }, + "required": [ + "object", + "data" + ] + }, + "DeleteModelResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "deleted": { + "type": "boolean" + } + }, + "required": [ + "id", + "object", + "deleted" + ] + }, + "CreateCompletionRequest": { + "type": "object", + "properties": { + "model": { + "description": "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", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "text-davinci-003", + "text-davinci-002", + "text-davinci-001", + "code-davinci-002", + "text-curie-001", + "text-babbage-001", + "text-ada-001" + ] + } + ] + }, + "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]]" + } + ] + }, + "suffix": { + "description": "The suffix that comes after a completion of inserted text.", + "default": null, + "nullable": true, + "type": "string", + "example": "test." + }, + "max_tokens": { + "type": "integer", + "minimum": 0, + "default": 16, + "example": 16, + "nullable": true, + "description": "The maximum number of [tokens](/tokenizer) to generate in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.\n" + }, + "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" + }, + "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" + }, + "stream": { + "description": "Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).\n", + "type": "boolean", + "nullable": true, + "default": false + }, + "logprobs": { + "type": "integer", + "minimum": 0, + "maximum": 5, + "default": null, + "nullable": true, + "description": "Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5.\n" + }, + "echo": { + "type": "boolean", + "default": false, + "nullable": true, + "description": "Echo back the prompt in addition to the completion\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\"]" + } + } + ] + }, + "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/api-reference/parameter-details)\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/api-reference/parameter-details)\n" + }, + "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" + }, + "logit_bias": { + "type": "object", + "x-oaiTypeLabel": "map", + "default": null, + "nullable": true, + "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" + }, + "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", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "created": { + "type": "integer" + }, + "model": { + "type": "string" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "required": [ + "text", + "index", + "logprobs", + "finish_reason" + ], + "properties": { + "text": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "logprobs": { + "type": "object", + "nullable": true, + "properties": { + "tokens": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_logprobs": { + "type": "array", + "items": { + "type": "number" + } + }, + "top_logprobs": { + "type": "array", + "items": { + "type": "object" + } + }, + "text_offset": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "finish_reason": { + "type": "string", + "enum": [ + "stop", + "length" + ] + } + } + } + }, + "usage": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "completion_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ] + } + }, + "required": [ + "id", + "object", + "created", + "model", + "choices" + ] + }, + "ChatCompletionRequestMessage": { + "type": "object", + "properties": { + "role": { + "type": "string", + "enum": [ + "system", + "user", + "assistant", + "function" + ], + "description": "The role of the messages author. One of `system`, `user`, `assistant`, or `function`." + }, + "content": { + "type": "string", + "description": "The contents of the message. `content` is required for all messages except assistant messages with function calls." + }, + "name": { + "type": "string", + "description": "The name of the author of this message. `name` is required if role is `function`, and it should be the name of the function whose response is in the `content`. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters." + }, + "function_call": { + "type": "object", + "description": "The name and arguments of a function that should be called, as generated by the model.", + "properties": { + "name": { + "type": "string", + "description": "The name of the function to call." + }, + "arguments": { + "type": "string", + "description": "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + } + } + } + }, + "required": [ + "role" + ] + }, + "ChatCompletionFunctionParameters": { + "type": "object", + "description": "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.", + "additionalProperties": true + }, + "ChatCompletionFunctions": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64." + }, + "description": { + "type": "string", + "description": "The description of what the function does." + }, + "parameters": { + "$ref": "#/components/schemas/ChatCompletionFunctionParameters" + } + }, + "required": [ + "name" + ] + }, + "ChatCompletionResponseMessage": { + "type": "object", + "properties": { + "role": { + "type": "string", + "enum": [ + "system", + "user", + "assistant", + "function" + ], + "description": "The role of the author of this message." + }, + "content": { + "type": "string", + "description": "The contents of the message.", + "nullable": true + }, + "function_call": { + "type": "object", + "description": "The name and arguments of a function that should be called, as generated by the model.", + "properties": { + "name": { + "type": "string", + "description": "The name of the function to call." + }, + "arguments": { + "type": "string", + "description": "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + } + } + } + }, + "required": [ + "role" + ] + }, + "ChatCompletionStreamResponseDelta": { + "type": "object", + "properties": { + "role": { + "type": "string", + "enum": [ + "system", + "user", + "assistant", + "function" + ], + "description": "The role of the author of this message." + }, + "content": { + "type": "string", + "description": "The contents of the chunk message.", + "nullable": true + }, + "function_call": { + "type": "object", + "description": "The name and arguments of a function that should be called, as generated by the model.", + "properties": { + "name": { + "type": "string", + "description": "The name of the function to call." + }, + "arguments": { + "type": "string", + "description": "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function." + } + } + } + } + }, + "CreateChatCompletionRequest": { + "type": "object", + "properties": { + "model": { + "description": "ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.", + "example": "gpt-3.5-turbo", + "type": "string", + "enum": [ + "gpt-4", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-16k-0613" + ] + }, + "messages": { + "description": "A list of messages comprising the conversation so far. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb).", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/components/schemas/ChatCompletionRequestMessage" + } + }, + "functions": { + "description": "A list of functions the model may generate JSON inputs for.", + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/components/schemas/ChatCompletionFunctions" + } + }, + "function_call": { + "description": "Controls how the model responds to function calls. \"none\" means the model does not call a function, and responds to the end-user. \"auto\" means the model can pick between an end-user or calling a function. Specifying a particular function via `{\"name\":\\ \"my_function\"}` forces the model to call that function. \"none\" is the default when no functions are present. \"auto\" is the default if functions are present.", + "oneOf": [ + { + "type": "string", + "enum": [ + "none", + "auto" + ] + }, + { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the function to call." + } + }, + "required": [ + "name" + ] + } + ] + }, + "temperature": { + "type": "number", + "minimum": 0, + "maximum": 2, + "default": 1, + "example": 1, + "nullable": true, + "description": "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" + }, + "n": { + "type": "integer", + "minimum": 1, + "maximum": 128, + "default": 1, + "example": 1, + "nullable": true, + "description": "How many chat completion choices to generate for each input message." + }, + "stream": { + "description": "If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb).\n", + "type": "boolean", + "nullable": true, + "default": false + }, + "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" + } + } + ] + }, + "max_tokens": { + "description": "The maximum number of [tokens](/tokenizer) to generate 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://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.\n", + "default": "inf", + "type": "integer" + }, + "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/api-reference/parameter-details)\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/api-reference/parameter-details)\n" + }, + "logit_bias": { + "type": "object", + "x-oaiTypeLabel": "map", + "default": null, + "nullable": true, + "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" + }, + "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", + "messages" + ] + }, + "CreateChatCompletionResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "created": { + "type": "integer" + }, + "model": { + "type": "string" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "index": { + "type": "integer" + }, + "message": { + "$ref": "#/components/schemas/ChatCompletionResponseMessage" + }, + "finish_reason": { + "type": "string", + "enum": [ + "stop", + "length", + "function_call" + ] + } + } + } + }, + "usage": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "completion_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ] + } + }, + "required": [ + "id", + "object", + "created", + "model", + "choices" + ] + }, + "CreateChatCompletionStreamResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "created": { + "type": "integer" + }, + "model": { + "type": "string" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "index": { + "type": "integer" + }, + "delta": { + "$ref": "#/components/schemas/ChatCompletionStreamResponseDelta" + }, + "finish_reason": { + "type": "string", + "enum": [ + "stop", + "length", + "function_call" + ] + } + } + } + } + }, + "required": [ + "id", + "object", + "created", + "model", + "choices" + ] + }, + "CreateEditRequest": { + "type": "object", + "properties": { + "model": { + "description": "ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint.", + "type": "string", + "example": "text-davinci-edit-001", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "text-davinci-edit-001", + "code-davinci-edit-001" + ] + } + ] + }, + "input": { + "description": "The input text to use as a starting point for the edit.", + "type": "string", + "default": "", + "nullable": true, + "example": "What day of the wek is it?" + }, + "instruction": { + "description": "The instruction that tells the model how to edit the prompt.", + "type": "string", + "example": "Fix the spelling mistakes." + }, + "n": { + "type": "integer", + "minimum": 1, + "maximum": 20, + "default": 1, + "example": 1, + "nullable": true, + "description": "How many edits to generate for the input and instruction." + }, + "temperature": { + "type": "number", + "minimum": 0, + "maximum": 2, + "default": 1, + "example": 1, + "nullable": true, + "description": "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", + "properties": { + "object": { + "type": "string" + }, + "created": { + "type": "integer" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "index": { + "type": "integer" + }, + "logprobs": { + "type": "object", + "nullable": true, + "properties": { + "tokens": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_logprobs": { + "type": "array", + "items": { + "type": "number" + } + }, + "top_logprobs": { + "type": "array", + "items": { + "type": "object" + } + }, + "text_offset": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "finish_reason": { + "type": "string", + "enum": [ + "stop", + "length" + ] + } + } + } + }, + "usage": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "completion_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "completion_tokens", + "total_tokens" + ] + } + }, + "required": [ + "object", + "created", + "choices", + "usage" + ] + }, + "CreateImageRequest": { + "type": "object", + "properties": { + "prompt": { + "description": "A text description of the desired image(s). The maximum length is 1000 characters.", + "type": "string", + "example": "A cute baby sea otter" + }, + "n": { + "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" + ] + }, + "ImagesResponse": { + "properties": { + "created": { + "type": "integer" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "b64_json": { + "type": "string" + } + } + } + } + }, + "required": [ + "created", + "data" + ] + }, + "CreateImageEditRequest": { + "type": "object", + "properties": { + "image": { + "description": "The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.", + "type": "string", + "format": "binary" + }, + "mask": { + "description": "An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.", + "type": "string", + "format": "binary" + }, + "prompt": { + "description": "A text description of the desired image(s). The maximum length is 1000 characters.", + "type": "string", + "example": "A cute baby sea otter wearing a beret" + }, + "n": { + "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" + }, + "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": [ + "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", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "text-moderation-latest", + "text-moderation-stable" + ] + } + ] + } + }, + "required": [ + "input" + ] + }, + "CreateModerationResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "model": { + "type": "string" + }, + "results": { + "type": "array", + "items": { + "type": "object", + "properties": { + "flagged": { + "type": "boolean" + }, + "categories": { + "type": "object", + "properties": { + "hate": { + "type": "boolean" + }, + "hate/threatening": { + "type": "boolean" + }, + "self-harm": { + "type": "boolean" + }, + "sexual": { + "type": "boolean" + }, + "sexual/minors": { + "type": "boolean" + }, + "violence": { + "type": "boolean" + }, + "violence/graphic": { + "type": "boolean" + } + }, + "required": [ + "hate", + "hate/threatening", + "self-harm", + "sexual", + "sexual/minors", + "violence", + "violence/graphic" + ] + }, + "category_scores": { + "type": "object", + "properties": { + "hate": { + "type": "number" + }, + "hate/threatening": { + "type": "number" + }, + "self-harm": { + "type": "number" + }, + "sexual": { + "type": "number" + }, + "sexual/minors": { + "type": "number" + }, + "violence": { + "type": "number" + }, + "violence/graphic": { + "type": "number" + } + }, + "required": [ + "hate", + "hate/threatening", + "self-harm", + "sexual", + "sexual/minors", + "violence", + "violence/graphic" + ] + } + }, + "required": [ + "flagged", + "categories", + "category_scores" + ] + } + } + }, + "required": [ + "id", + "model", + "results" + ] + }, + "ListFilesResponse": { + "type": "object", + "properties": { + "object": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAIFile" + } + } + }, + "required": [ + "object", + "data" + ] + }, + "CreateFileRequest": { + "type": "object", + "additionalProperties": false, + "properties": { + "file": { + "description": "Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded.\n\nIf the `purpose` is set to \"fine-tune\", each line is a JSON record with \"prompt\" and \"completion\" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).\n", + "type": "string", + "format": "binary" + }, + "purpose": { + "description": "The intended purpose of the uploaded documents.\n\nUse \"fine-tune\" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.\n", + "type": "string" + } + }, + "required": [ + "file", + "purpose" + ] + }, + "DeleteFileResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "deleted": { + "type": "boolean" + } + }, + "required": [ + "id", + "object", + "deleted" + ] + }, + "CreateFineTuneRequest": { + "type": "object", + "properties": { + "training_file": { + "description": "The ID of an uploaded file that contains training data.\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/fine-tuning/creating-training-data) for more details.\n", + "type": "string", + "example": "file-ajSREls59WBbvgSzJSVWxMCB" + }, + "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/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/fine-tuning/creating-training-data) for more details.\n", + "type": "string", + "nullable": true, + "example": "file-XjSREls59WBbvgSzJSVWxMCa" + }, + "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.\nTo learn more about these models, see the\n[Models](https://platform.openai.com/docs/models) documentation.\n", + "default": "curie", + "example": "curie", + "nullable": true, + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "ada", + "babbage", + "curie", + "davinci" + ] + } + ] + }, + "n_epochs": { + "description": "The number of epochs to train the model for. An epoch refers to one\nfull cycle through the training dataset.\n", + "default": 4, + "type": "integer", + "nullable": true + }, + "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 + }, + "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 + }, + "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 + }, + "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/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 + }, + "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 + }, + "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 + }, + "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 + } + }, + "required": [ + "training_file" + ] + }, + "ListFineTunesResponse": { + "type": "object", + "properties": { + "object": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FineTune" + } + } + }, + "required": [ + "object", + "data" + ] + }, + "ListFineTuneEventsResponse": { + "type": "object", + "properties": { + "object": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FineTuneEvent" + } + } + }, + "required": [ + "object", + "data" + ] + }, + "CreateEmbeddingRequest": { + "type": "object", + "additionalProperties": false, + "properties": { + "model": { + "description": "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", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "text-embedding-ada-002" + ] + } + ] + }, + "input": { + "description": "Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed the max input tokens for the model (8191 tokens for `text-embedding-ada-002`). [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens.\n", + "example": "The quick brown fox jumped over the lazy dog", + "oneOf": [ + { + "type": "string", + "default": "", + "example": "This is a test." + }, + { + "type": "array", + "items": { + "type": "string", + "default": "", + "example": "This is a test." + } + }, + { + "type": "array", + "minItems": 1, + "items": { + "type": "integer" + }, + "example": "[1212, 318, 257, 1332, 13]" + }, + { + "type": "array", + "minItems": 1, + "items": { + "type": "array", + "minItems": 1, + "items": { + "type": "integer" + } + }, + "example": "[[1212, 318, 257, 1332, 13]]" + } + ] + }, + "user": { + "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": { + "object": { + "type": "string" + }, + "model": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "index": { + "type": "integer" + }, + "object": { + "type": "string" + }, + "embedding": { + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "index", + "object", + "embedding" + ] + } + }, + "usage": { + "type": "object", + "properties": { + "prompt_tokens": { + "type": "integer" + }, + "total_tokens": { + "type": "integer" + } + }, + "required": [ + "prompt_tokens", + "total_tokens" + ] + } + }, + "required": [ + "object", + "model", + "data", + "usage" + ] + }, + "CreateTranscriptionRequest": { + "type": "object", + "additionalProperties": false, + "properties": { + "file": { + "description": "The audio file object (not file name) to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.\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", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "whisper-1" + ] + } + ] + }, + "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", + "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 + }, + "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" + } + }, + "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: mp3, mp4, mpeg, mpga, m4a, 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", + "oneOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "whisper-1" + ] + } + ] + }, + "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" + ] + }, + "Model": { + "title": "Model", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "created": { + "type": "integer" + }, + "owned_by": { + "type": "string" + } + }, + "required": [ + "id", + "object", + "created", + "owned_by" + ] + }, + "OpenAIFile": { + "title": "OpenAIFile", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "bytes": { + "type": "integer" + }, + "created_at": { + "type": "integer" + }, + "filename": { + "type": "string" + }, + "purpose": { + "type": "string" + }, + "status": { + "type": "string" + }, + "status_details": { + "type": "object", + "nullable": true + } + }, + "required": [ + "id", + "object", + "bytes", + "created_at", + "filename", + "purpose" + ] + }, + "FineTune": { + "title": "FineTune", + "properties": { + "id": { + "type": "string" + }, + "object": { + "type": "string" + }, + "created_at": { + "type": "integer" + }, + "updated_at": { + "type": "integer" + }, + "model": { + "type": "string" + }, + "fine_tuned_model": { + "type": "string", + "nullable": true + }, + "organization_id": { + "type": "string" + }, + "status": { + "type": "string" + }, + "hyperparams": { + "type": "object" + }, + "training_files": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAIFile" + } + }, + "validation_files": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAIFile" + } + }, + "result_files": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OpenAIFile" + } + }, + "events": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FineTuneEvent" + } + } + }, + "required": [ + "id", + "object", + "created_at", + "updated_at", + "model", + "fine_tuned_model", + "organization_id", + "status", + "hyperparams", + "training_files", + "validation_files", + "result_files" + ] + }, + "FineTuneEvent": { + "title": "FineTuneEvent", + "properties": { + "object": { + "type": "string" + }, + "created_at": { + "type": "integer" + }, + "level": { + "type": "string" + }, + "message": { + "type": "string" + } + }, + "required": [ + "object", + "created_at", + "level", + "message" + ] + } + } + }, + "x-oaiMeta": { + "groups": [ + { + "id": "models", + "title": "Models", + "description": "List and describe the various models available in the API. You can refer to the [Models](/docs/models) documentation to understand what models are available and the differences between them.\n" + }, + { + "id": "chat", + "title": "Chat", + "description": "Given a list of messages comprising a conversation, the model will return a response.\n" + }, + { + "id": "completions", + "title": "Completions", + "description": "Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.\n" + }, + { + "id": "edits", + "title": "Edits", + "description": "Given a prompt and an instruction, the model will return an edited version of the prompt.\n" + }, + { + "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" + }, + { + "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" + }, + { + "id": "audio", + "title": "Audio", + "description": "Learn how to turn audio into text.\n\nRelated guide: [Speech to text](/docs/guides/speech-to-text)\n" + }, + { + "id": "files", + "title": "Files", + "description": "Files are used to upload documents that can be used with features like [Fine-tuning](/docs/api-reference/fine-tunes).\n" + }, + { + "id": "fine-tunes", + "title": "Fine-tunes", + "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" + }, + { + "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" + } + ] + }, + "$schema": "http://json-schema.org/draft-04/schema#" +} \ No newline at end of file diff --git a/src/components/OutputsTable/ScenarioEditor.tsx b/src/components/OutputsTable/ScenarioEditor.tsx index febd102..3ae4a9e 100644 --- a/src/components/OutputsTable/ScenarioEditor.tsx +++ b/src/components/OutputsTable/ScenarioEditor.tsx @@ -88,7 +88,7 @@ export default function ScenarioEditor({ onDrop={onReorder} backgroundColor={isDragTarget ? "gray.100" : "transparent"} > - + {/* for some reason the tooltip can't position itself properly relative to the icon without the wrapping box */}