diff --git a/openapi.yaml b/openapi.yaml index 6731e0fa..f80e6cb3 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2322,294 +2322,6 @@ paths: "has_more": true } - /batches: - post: - summary: Creates and executes a batch from an uploaded file of requests - operationId: createBatch - tags: - - Batch - requestBody: - required: true - content: - application/json: - schema: - type: object - required: - - input_file_id - - endpoint - - completion_window - properties: - input_file_id: - type: string - description: | - The ID of an uploaded file that contains requests for the new batch. - - See [upload file](/docs/api-reference/files/create) for how to upload a file. - - Your input file must be formatted as a JSONL file, and must be uploaded with the purpose `batch`. - endpoint: - type: string - enum: ["/v1/chat/completions"] - description: The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported. - completion_window: - type: string - enum: ["24h"] - description: The time frame within which the batch should be processed. Currently only `24h` is supported. - metadata: - type: object - additionalProperties: - type: string - description: Optional custom metadata for the batch. - nullable: true - responses: - '200': - description: Batch created successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Create batch - group: batch - returns: The created [Batch](/docs/api-reference/batch/object) object. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -d '{ - "input_file_id": "file-abc123", - "endpoint": "/v1/chat/completions", - "completion_window": "24h" - }' - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "validating", - "output_file_id": null, - "error_file_id": null, - "created_at": 1711471533, - "in_progress_at": null, - "expires_at": null, - "finalizing_at": null, - "completed_at": null, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 0, - "completed": 0, - "failed": 0 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - get: - operationId: listBatches - tags: - - Batch - summary: List your organization's batches. - parameters: - - in: query - name: after - required: false - schema: - type: string - description: Identifier for the last batch from the previous pagination request. - - name: limit - in: query - description: Number of batches to retrieve. - required: false - schema: - type: integer - default: 20 - responses: - '200': - description: Batch listed successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/ListBatchesResponse' - x-oaiMeta: - name: List batch - group: batch - returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches?limit=2 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" - response: &batch_object | - { - "object": "list", - "data": [ - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly job", - } - }, - { ... }, - ], - "has_more": true - } - - /batches/{batch_id}: - get: - operationId: retrieveBatch - tags: - - Batch - summary: Retrieves a batch. - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to retrieve. - responses: - '200': - description: Batch retrieved successfully. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Retrieve batch - group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123 \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - response: &batch_object | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "completed", - "output_file_id": "file-cvaTdG", - "error_file_id": "file-HOWS94", - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": 1711493133, - "completed_at": 1711493163, - "failed_at": null, - "expired_at": null, - "cancelling_at": null, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 95, - "failed": 5 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - - /batches/{batch_id}/cancel: - post: - operationId: cancelBatch - tags: - - Batch - summary: Cancels an in-progress batch. - parameters: - - in: path - name: batch_id - required: true - schema: - type: string - description: The ID of the batch to cancel. - responses: - '200': - description: Batch is cancelling. Returns the cancelling batch's details. - content: - application/json: - schema: - $ref: '#/components/schemas/Batch' - x-oaiMeta: - name: Cancel batch - group: batch - returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. - examples: - request: - curl: | - curl https://api.openai.com/v1/batches/batch_abc123/cancel \ - -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -X POST - response: | - { - "id": "batch_abc123", - "object": "batch", - "endpoint": "/v1/completions", - "errors": null, - "input_file_id": "file-abc123", - "completion_window": "24h", - "status": "cancelling", - "output_file_id": null, - "error_file_id": null, - "created_at": 1711471533, - "in_progress_at": 1711471538, - "expires_at": 1711557933, - "finalizing_at": null, - "completed_at": null, - "failed_at": null, - "expired_at": null, - "cancelling_at": 1711475133, - "cancelled_at": null, - "request_counts": { - "total": 100, - "completed": 23, - "failed": 1 - }, - "metadata": { - "customer_id": "user_123456789", - "batch_description": "Nightly eval job", - } - } - /models: get: operationId: listModels @@ -5976,141 +5688,410 @@ paths: required: true schema: type: string - description: The ID of the assistant who the file belongs to. - - in: path - name: file_id + description: The ID of the assistant who the file belongs to. + - in: path + name: file_id + required: true + schema: + type: string + description: The ID of the file we're getting. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/AssistantFileObject" + x-oaiMeta: + name: Retrieve assistant file + group: assistants + beta: true + returns: The [assistant file](/docs/api-reference/assistants/file-object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \ + -H 'Authorization: Bearer $OPENAI_API_KEY"' \ + -H 'Content-Type: application/json' \ + -H 'OpenAI-Beta: assistants=v1' + python: | + from openai import OpenAI + client = OpenAI() + + assistant_file = client.beta.assistants.files.retrieve( + assistant_id="asst_abc123", + file_id="file-abc123" + ) + print(assistant_file) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const myAssistantFile = await openai.beta.assistants.files.retrieve( + "asst_abc123", + "file-abc123" + ); + console.log(myAssistantFile); + } + + main(); + response: *assistant_file_object + delete: + operationId: deleteAssistantFile + tags: + - Assistants + summary: Delete an assistant file. + parameters: + - in: path + name: assistant_id + required: true + schema: + type: string + description: The ID of the assistant that the file belongs to. + - in: path + name: file_id + required: true + schema: + type: string + description: The ID of the file to delete. + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteAssistantFileResponse" + x-oaiMeta: + name: Delete assistant file + group: assistants + beta: true + returns: Deletion status + examples: + request: + curl: | + curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v1" \ + -X DELETE + python: | + from openai import OpenAI + client = OpenAI() + + deleted_assistant_file = client.beta.assistants.files.delete( + assistant_id="asst_abc123", + file_id="file-abc123" + ) + print(deleted_assistant_file) + node.js: | + import OpenAI from "openai"; + const openai = new OpenAI(); + + async function main() { + const deletedAssistantFile = await openai.beta.assistants.files.del( + "asst_abc123", + "file-abc123" + ); + console.log(deletedAssistantFile); + } + + main(); + response: | + { + id: "file-abc123", + object: "assistant.file.deleted", + deleted: true + } + + /threads/{thread_id}/messages/{message_id}/files: + get: + operationId: listMessageFiles + tags: + - Assistants + summary: Returns a list of message files. + parameters: + - name: thread_id + in: path + description: The ID of the thread that the message and files belong to. + required: true + schema: + type: string + - name: message_id + in: path + description: The ID of the message that the files belongs to. required: true schema: type: string - description: The ID of the file we're getting. + - name: limit + in: query + description: *pagination_limit_param_description + required: false + schema: + type: integer + default: 20 + - name: order + in: query + description: *pagination_order_param_description + schema: + type: string + default: desc + enum: ["asc", "desc"] + - name: after + in: query + description: *pagination_after_param_description + schema: + type: string + - name: before + in: query + description: *pagination_before_param_description + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/AssistantFileObject" + $ref: "#/components/schemas/ListMessageFilesResponse" x-oaiMeta: - name: Retrieve assistant file - group: assistants + name: List message files + group: threads beta: true - returns: The [assistant file](/docs/api-reference/assistants/file-object) object matching the specified ID. + returns: A list of [message file](/docs/api-reference/messages/file-object) objects. examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \ - -H 'Authorization: Bearer $OPENAI_API_KEY"' \ - -H 'Content-Type: application/json' \ - -H 'OpenAI-Beta: assistants=v1' + curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -H "OpenAI-Beta: assistants=v1" python: | from openai import OpenAI client = OpenAI() - assistant_file = client.beta.assistants.files.retrieve( - assistant_id="asst_abc123", - file_id="file-abc123" + message_files = client.beta.threads.messages.files.list( + thread_id="thread_abc123", + message_id="msg_abc123" ) - print(assistant_file) + print(message_files) node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const myAssistantFile = await openai.beta.assistants.files.retrieve( - "asst_abc123", - "file-abc123" + const messageFiles = await openai.beta.threads.messages.files.list( + "thread_abc123", + "msg_abc123" ); - console.log(myAssistantFile); + console.log(messageFiles); } main(); - response: *assistant_file_object - delete: - operationId: deleteAssistantFile + response: | + { + "object": "list", + "data": [ + { + "id": "file-abc123", + "object": "thread.message.file", + "created_at": 1699061776, + "message_id": "msg_abc123" + }, + { + "id": "file-abc123", + "object": "thread.message.file", + "created_at": 1699061776, + "message_id": "msg_abc123" + } + ], + "first_id": "file-abc123", + "last_id": "file-abc123", + "has_more": false + } + + /threads/{thread_id}/messages/{message_id}/files/{file_id}: + get: + operationId: getMessageFile tags: - Assistants - summary: Delete an assistant file. + summary: Retrieves a message file. parameters: - in: path - name: assistant_id + name: thread_id required: true schema: type: string - description: The ID of the assistant that the file belongs to. + example: thread_abc123 + description: The ID of the thread to which the message and File belong. + - in: path + name: message_id + required: true + schema: + type: string + example: msg_abc123 + description: The ID of the message the file belongs to. - in: path name: file_id required: true schema: type: string - description: The ID of the file to delete. + example: file-abc123 + description: The ID of the file being retrieved. responses: "200": description: OK content: application/json: schema: - $ref: "#/components/schemas/DeleteAssistantFileResponse" + $ref: "#/components/schemas/MessageFileObject" x-oaiMeta: - name: Delete assistant file - group: assistants + name: Retrieve message file + group: threads beta: true - returns: Deletion status + returns: The [message file](/docs/api-reference/messages/file-object) object. examples: request: curl: | - curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \ + curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files/file-abc123 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v1" \ - -X DELETE + -H "OpenAI-Beta: assistants=v1" python: | from openai import OpenAI client = OpenAI() - deleted_assistant_file = client.beta.assistants.files.delete( - assistant_id="asst_abc123", + message_files = client.beta.threads.messages.files.retrieve( + thread_id="thread_abc123", + message_id="msg_abc123", file_id="file-abc123" ) - print(deleted_assistant_file) + print(message_files) node.js: | import OpenAI from "openai"; const openai = new OpenAI(); async function main() { - const deletedAssistantFile = await openai.beta.assistants.files.del( - "asst_abc123", + const messageFile = await openai.beta.threads.messages.files.retrieve( + "thread_abc123", + "msg_abc123", "file-abc123" ); - console.log(deletedAssistantFile); + console.log(messageFile); } main(); response: | { - id: "file-abc123", - object: "assistant.file.deleted", - deleted: true + "id": "file-abc123", + "object": "thread.message.file", + "created_at": 1699061776, + "message_id": "msg_abc123" } - /threads/{thread_id}/messages/{message_id}/files: + /batches: + post: + summary: Creates and executes a batch from an uploaded file of requests + operationId: createBatch + tags: + - Batch + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - input_file_id + - endpoint + - completion_window + properties: + input_file_id: + type: string + description: | + The ID of an uploaded file that contains requests for the new batch. + + See [upload file](/docs/api-reference/files/create) for how to upload a file. + + Your input file must be formatted as a JSONL file, and must be uploaded with the purpose `batch`. + endpoint: + type: string + enum: ["/v1/chat/completions"] + description: The endpoint to be used for all requests in the batch. Currently only `/v1/chat/completions` is supported. + completion_window: + type: string + enum: ["24h"] + description: The time frame within which the batch should be processed. Currently only `24h` is supported. + metadata: + type: object + additionalProperties: + type: string + description: Optional custom metadata for the batch. + nullable: true + responses: + '200': + description: Batch created successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Create batch + group: batch + returns: The created [Batch](/docs/api-reference/batch/object) object. + examples: + request: + curl: | + curl https://api.openai.com/v1/batches \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "input_file_id": "file-abc123", + "endpoint": "/v1/chat/completions", + "completion_window": "24h" + }' + response: | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "validating", + "output_file_id": null, + "error_file_id": null, + "created_at": 1711471533, + "in_progress_at": null, + "expires_at": null, + "finalizing_at": null, + "completed_at": null, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 0, + "completed": 0, + "failed": 0 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } get: - operationId: listMessageFiles + operationId: listBatches tags: - - Assistants - summary: Returns a list of message files. + - Batch + summary: List your organization's batches. parameters: - - name: thread_id - in: path - description: The ID of the thread that the message and files belong to. - required: true - schema: - type: string - - name: message_id - in: path - description: The ID of the message that the files belongs to. - required: true + - in: query + name: after + required: false schema: type: string + description: *pagination_after_param_description - name: limit in: query description: *pagination_limit_param_description @@ -6118,163 +6099,184 @@ paths: schema: type: integer default: 20 - - name: order - in: query - description: *pagination_order_param_description - schema: - type: string - default: desc - enum: ["asc", "desc"] - - name: after - in: query - description: *pagination_after_param_description - schema: - type: string - - name: before - in: query - description: *pagination_before_param_description - schema: - type: string responses: - "200": - description: OK + '200': + description: Batch listed successfully. content: application/json: schema: - $ref: "#/components/schemas/ListMessageFilesResponse" + $ref: '#/components/schemas/ListBatchesResponse' x-oaiMeta: - name: List message files - group: threads - beta: true - returns: A list of [message file](/docs/api-reference/messages/file-object) objects. + name: List batch + group: batch + returns: A list of paginated [Batch](/docs/api-reference/batch/object) objects. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files \ + curl https://api.openai.com/v1/batches?limit=2 \ -H "Authorization: Bearer $OPENAI_API_KEY" \ - -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v1" - python: | - from openai import OpenAI - client = OpenAI() - - message_files = client.beta.threads.messages.files.list( - thread_id="thread_abc123", - message_id="msg_abc123" - ) - print(message_files) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const messageFiles = await openai.beta.threads.messages.files.list( - "thread_abc123", - "msg_abc123" - ); - console.log(messageFiles); - } - - main(); + -H "Content-Type: application/json" response: | { "object": "list", "data": [ { - "id": "file-abc123", - "object": "thread.message.file", - "created_at": 1699061776, - "message_id": "msg_abc123" + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly job", + } }, - { - "id": "file-abc123", - "object": "thread.message.file", - "created_at": 1699061776, - "message_id": "msg_abc123" - } + { ... }, ], - "first_id": "file-abc123", - "last_id": "file-abc123", - "has_more": false + "first_id": "batch_abc123", + "last_id": "batch_abc456", + "has_more": true } - /threads/{thread_id}/messages/{message_id}/files/{file_id}: + /batches/{batch_id}: get: - operationId: getMessageFile + operationId: retrieveBatch tags: - - Assistants - summary: Retrieves a message file. + - Batch + summary: Retrieves a batch. parameters: - in: path - name: thread_id - required: true - schema: - type: string - example: thread_abc123 - description: The ID of the thread to which the message and File belong. - - in: path - name: message_id + name: batch_id required: true schema: type: string - example: msg_abc123 - description: The ID of the message the file belongs to. + description: The ID of the batch to retrieve. + responses: + '200': + description: Batch retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Batch' + x-oaiMeta: + name: Retrieve batch + group: batch + returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. + examples: + request: + curl: | + curl https://api.openai.com/v1/batches/batch_abc123 \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -H "Content-Type: application/json" \ + response: &batch_object | + { + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "completed", + "output_file_id": "file-cvaTdG", + "error_file_id": "file-HOWS94", + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": 1711493133, + "completed_at": 1711493163, + "failed_at": null, + "expired_at": null, + "cancelling_at": null, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 95, + "failed": 5 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } + } + + /batches/{batch_id}/cancel: + post: + operationId: cancelBatch + tags: + - Batch + summary: Cancels an in-progress batch. + parameters: - in: path - name: file_id + name: batch_id required: true schema: type: string - example: file-abc123 - description: The ID of the file being retrieved. + description: The ID of the batch to cancel. responses: - "200": - description: OK + '200': + description: Batch is cancelling. Returns the cancelling batch's details. content: application/json: schema: - $ref: "#/components/schemas/MessageFileObject" + $ref: '#/components/schemas/Batch' x-oaiMeta: - name: Retrieve message file - group: threads - beta: true - returns: The [message file](/docs/api-reference/messages/file-object) object. + name: Cancel batch + group: batch + returns: The [Batch](/docs/api-reference/batch/object) object matching the specified ID. examples: request: curl: | - curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123/files/file-abc123 \ + curl https://api.openai.com/v1/batches/batch_abc123/cancel \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ - -H "OpenAI-Beta: assistants=v1" - python: | - from openai import OpenAI - client = OpenAI() - - message_files = client.beta.threads.messages.files.retrieve( - thread_id="thread_abc123", - message_id="msg_abc123", - file_id="file-abc123" - ) - print(message_files) - node.js: | - import OpenAI from "openai"; - const openai = new OpenAI(); - - async function main() { - const messageFile = await openai.beta.threads.messages.files.retrieve( - "thread_abc123", - "msg_abc123", - "file-abc123" - ); - console.log(messageFile); - } - - main(); + -X POST response: | { - "id": "file-abc123", - "object": "thread.message.file", - "created_at": 1699061776, - "message_id": "msg_abc123" + "id": "batch_abc123", + "object": "batch", + "endpoint": "/v1/completions", + "errors": null, + "input_file_id": "file-abc123", + "completion_window": "24h", + "status": "cancelling", + "output_file_id": null, + "error_file_id": null, + "created_at": 1711471533, + "in_progress_at": 1711471538, + "expires_at": 1711557933, + "finalizing_at": null, + "completed_at": null, + "failed_at": null, + "expired_at": null, + "cancelling_at": 1711475133, + "cancelled_at": null, + "request_counts": { + "total": 100, + "completed": 23, + "failed": 1 + }, + "metadata": { + "customer_id": "user_123456789", + "batch_description": "Nightly eval job", + } } components: @@ -11615,6 +11617,12 @@ components: type: array items: $ref: "#/components/schemas/Batch" + first_id: + type: string + example: "batch_abc123" + last_id: + type: string + example: "batch_abc456" has_more: type: boolean object: