openapi: 3.0.0 info: title: OpenAI Assistants API description: The Assistants API allows you to build AI assistants within your own applications. An Assistant has instructions and can leverage models, tools, and knowledge to respond to user queries. The Assistants API currently supports three types of tools - Code Interpreter, Retrieval, and Function calling. In the future, we plan to release more OpenAI-built tools, and allow you to provide your own tools on our platform. version: 2.0.0 termsOfService: https://openai.com/policies/terms-of-use contact: name: OpenAI Support url: https://help.openai.com/ license: name: MIT url: https://github.com/openai/openai-openapi/blob/master/LICENSE servers: - url: https://api.openai.com/v1 security: - ApiKeyAuth: [] tags: - name: Assistants description: Build Assistants that can call models and use tools. paths: /assistants: get: operationId: listAssistants tags: - Assistants summary: OpenAI Returns a list of assistants. parameters: - name: limit in: query description: 'A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ' required: false schema: type: integer default: 20 - name: order in: query description: 'Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. ' schema: type: string default: desc enum: - asc - desc - name: after in: query description: 'A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. ' schema: type: string - name: before in: query description: 'A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. ' schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListAssistantsResponse' x-oaiMeta: name: List assistants group: assistants beta: true returns: A list of [assistant](/docs/api-reference/assistants/object) objects. examples: request: curl: "curl \"https://api.openai.com/v1/assistants?order=desc&limit=20\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistants = client.beta.assistants.list(\n order=\"desc\",\n limit=\"20\",\n)\nprint(my_assistants.data)\n" node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistants = await openai.beta.assistants.list({\n order: \"desc\",\n limit: \"20\",\n });\n\n console.log(myAssistants.data);\n}\n\nmain();" response: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698982736,\n \"name\": \"Coding Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc456\",\n \"object\": \"assistant\",\n \"created_at\": 1698982718,\n \"name\": \"My Assistant\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc789\",\n \"object\": \"assistant\",\n \"created_at\": 1698982643,\n \"name\": null,\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"asst_abc123\",\n \"last_id\": \"asst_abc789\",\n \"has_more\": false\n}\n" post: operationId: createAssistant tags: - Assistants summary: OpenAI Create an assistant with a model and instructions. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateAssistantRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AssistantObject' x-oaiMeta: name: Create assistant group: assistants beta: true returns: An [assistant](/docs/api-reference/assistants/object) object. examples: - title: Code Interpreter request: curl: "curl \"https://api.openai.com/v1/assistants\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"name\": \"Math Tutor\",\n \"tools\": [{\"type\": \"code_interpreter\"}],\n \"model\": \"gpt-4\"\n }'\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistant = client.beta.assistants.create(\n instructions=\"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n name=\"Math Tutor\",\n tools=[{\"type\": \"code_interpreter\"}],\n model=\"gpt-4\",\n)\nprint(my_assistant)\n" node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n name: \"Math Tutor\",\n tools: [{ type: \"code_interpreter\" }],\n model: \"gpt-4\",\n });\n\n console.log(myAssistant);\n}\n\nmain();" response: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698984975,\n \"name\": \"Math Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" - title: Files request: curl: "curl https://api.openai.com/v1/assistants \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [{\"type\": \"retrieval\"}],\n \"model\": \"gpt-4\",\n \"file_ids\": [\"file-abc123\"]\n }'\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nmy_assistant = client.beta.assistants.create(\n instructions=\"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n name=\"HR Helper\",\n tools=[{\"type\": \"retrieval\"}],\n model=\"gpt-4\",\n file_ids=[\"file-abc123\"],\n)\nprint(my_assistant)\n" node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.create({\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n name: \"HR Helper\",\n tools: [{ type: \"retrieval\" }],\n model: \"gpt-4\",\n file_ids: [\"file-abc123\"],\n });\n\n console.log(myAssistant);\n}\n\nmain();" response: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009403,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\"\n ],\n \"metadata\": {}\n}\n" /assistants/{assistant_id}: get: operationId: getAssistant tags: - Assistants summary: OpenAI Retrieves an assistant. parameters: - in: path name: assistant_id required: true schema: type: string description: The ID of the assistant to retrieve. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AssistantObject' x-oaiMeta: name: Retrieve assistant group: assistants beta: true returns: The [assistant](/docs/api-reference/assistants/object) object matching the specified ID. examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n" python: 'from openai import OpenAI client = OpenAI() my_assistant = client.beta.assistants.retrieve("asst_abc123") print(my_assistant) ' node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistant = await openai.beta.assistants.retrieve(\n \"asst_abc123\"\n );\n\n console.log(myAssistant);\n}\n\nmain();" response: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\"\n ],\n \"metadata\": {}\n}\n" post: operationId: modifyAssistant tags: - Assistants summary: OpenAI Modifies an assistant. parameters: - in: path name: assistant_id required: true schema: type: string description: The ID of the assistant to modify. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ModifyAssistantRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AssistantObject' x-oaiMeta: name: Modify assistant group: assistants beta: true returns: The modified [assistant](/docs/api-reference/assistants/object) object. examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -d '{\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [{\"type\": \"retrieval\"}],\n \"model\": \"gpt-4\",\n \"file_ids\": [\"file-abc123\", \"file-abc456\"]\n }'\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nmy_updated_assistant = client.beta.assistants.update(\n \"asst_abc123\",\n instructions=\"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n name=\"HR Helper\",\n tools=[{\"type\": \"retrieval\"}],\n model=\"gpt-4\",\n file_ids=[\"file-abc123\", \"file-abc456\"],\n)\n\nprint(my_updated_assistant)\n" node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myUpdatedAssistant = await openai.beta.assistants.update(\n \"asst_abc123\",\n {\n instructions:\n \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n name: \"HR Helper\",\n tools: [{ type: \"retrieval\" }],\n model: \"gpt-4\",\n file_ids: [\n \"file-abc123\",\n \"file-abc456\",\n ],\n }\n );\n\n console.log(myUpdatedAssistant);\n}\n\nmain();" response: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1699009709,\n \"name\": \"HR Helper\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are an HR bot, and you have access to files to answer employee questions about company policies. Always response with info from either of the files.\",\n \"tools\": [\n {\n \"type\": \"retrieval\"\n }\n ],\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ],\n \"metadata\": {}\n}\n" delete: operationId: deleteAssistant tags: - Assistants summary: OpenAI Delete an assistant. parameters: - in: path name: assistant_id required: true schema: type: string description: The ID of the assistant to delete. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DeleteAssistantResponse' x-oaiMeta: name: Delete assistant group: assistants beta: true returns: Deletion status examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X DELETE\n" python: 'from openai import OpenAI client = OpenAI() response = client.beta.assistants.delete("asst_abc123") print(response) ' node.js: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.beta.assistants.del(\"asst_abc123\");\n\n console.log(response);\n}\nmain();" response: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant.deleted\",\n \"deleted\": true\n}\n" /assistants/{assistant_id}/files: get: operationId: listAssistantFiles tags: - Assistants summary: OpenAI Returns a list of assistant files. parameters: - name: assistant_id in: path description: The ID of the assistant the file belongs to. required: true schema: type: string - name: limit in: query description: 'A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ' required: false schema: type: integer default: 20 - name: order in: query description: 'Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. ' schema: type: string default: desc enum: - asc - desc - name: after in: query description: 'A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. ' schema: type: string - name: before in: query description: 'A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. ' schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListAssistantFilesResponse' x-oaiMeta: name: List assistant files group: assistants beta: true returns: A list of [assistant file](/docs/api-reference/assistants/file-object) objects. examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123/files \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\"\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nassistant_files = client.beta.assistants.files.list(\n assistant_id=\"asst_abc123\"\n)\nprint(assistant_files)\n" node.js: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const assistantFiles = await openai.beta.assistants.files.list(\n \"asst_abc123\"\n );\n console.log(assistantFiles);\n}\n\nmain();\n" response: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699060412,\n \"assistant_id\": \"asst_abc123\"\n },\n {\n \"id\": \"file-abc456\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699060412,\n \"assistant_id\": \"asst_abc123\"\n }\n ],\n \"first_id\": \"file-abc123\",\n \"last_id\": \"file-abc456\",\n \"has_more\": false\n}\n" post: operationId: createAssistantFile tags: - Assistants summary: OpenAI Create an assistant file by attaching a [File](/docs/api-reference/files) to an [assistant](/docs/api-reference/assistants). parameters: - in: path name: assistant_id required: true schema: type: string example: file-abc123 description: 'The ID of the assistant for which to create a File. ' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateAssistantFileRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AssistantFileObject' x-oaiMeta: name: Create assistant file group: assistants beta: true returns: An [assistant file](/docs/api-reference/assistants/file-object) object. examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123/files \\\n -H 'Authorization: Bearer $OPENAI_API_KEY\"' \\\n -H 'Content-Type: application/json' \\\n -H 'OpenAI-Beta: assistants=v1' \\\n -d '{\n \"file_id\": \"file-abc123\"\n }'\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nassistant_file = client.beta.assistants.files.create(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(assistant_file)\n" node.js: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistantFile = await openai.beta.assistants.files.create(\n \"asst_abc123\",\n {\n file_id: \"file-abc123\"\n }\n );\n console.log(myAssistantFile);\n}\n\nmain();\n" response: "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" /assistants/{assistant_id}/files/{file_id}: get: operationId: getAssistantFile tags: - Assistants summary: OpenAI Retrieves an AssistantFile. parameters: - in: path name: assistant_id required: true schema: type: string description: The ID of the assistant who the file belongs to. - in: path name: file_id required: true schema: type: string description: The ID of the file we're getting. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AssistantFileObject' x-oaiMeta: name: Retrieve assistant file group: assistants beta: true returns: The [assistant file](/docs/api-reference/assistants/file-object) object matching the specified ID. examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \\\n -H 'Authorization: Bearer $OPENAI_API_KEY\"' \\\n -H 'Content-Type: application/json' \\\n -H 'OpenAI-Beta: assistants=v1'\n" python: "from openai import OpenAI\nclient = OpenAI()\n\nassistant_file = client.beta.assistants.files.retrieve(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(assistant_file)\n" node.js: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const myAssistantFile = await openai.beta.assistants.files.retrieve(\n \"asst_abc123\",\n \"file-abc123\"\n );\n console.log(myAssistantFile);\n}\n\nmain();\n" response: "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" delete: operationId: deleteAssistantFile tags: - Assistants summary: OpenAI Delete an assistant file. parameters: - in: path name: assistant_id required: true schema: type: string description: The ID of the assistant that the file belongs to. - in: path name: file_id required: true schema: type: string description: The ID of the file to delete. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DeleteAssistantFileResponse' x-oaiMeta: name: Delete assistant file group: assistants beta: true returns: Deletion status examples: request: curl: "curl https://api.openai.com/v1/assistants/asst_abc123/files/file-abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v1\" \\\n -X DELETE\n" python: "from openai import OpenAI\nclient = OpenAI()\n\ndeleted_assistant_file = client.beta.assistants.files.delete(\n assistant_id=\"asst_abc123\",\n file_id=\"file-abc123\"\n)\nprint(deleted_assistant_file)\n" node.js: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const deletedAssistantFile = await openai.beta.assistants.files.del(\n \"asst_abc123\",\n \"file-abc123\"\n );\n console.log(deletedAssistantFile);\n}\n\nmain();\n" response: "{\n id: \"file-abc123\",\n object: \"assistant.file.deleted\",\n deleted: true\n}\n" /threads: post: operationId: createThread tags: - Assistants summary: Create a thread. requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateThreadRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ThreadObject' x-oaiMeta: name: Create thread group: threads beta: true examples: - title: Empty request: curl: "curl https://api.openai.com/v1/threads \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d ''\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nthread = client.beta.threads.create()\nprint(thread.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const emptyThread = await openai.beta.threads.create();\n\n console.log(emptyThread);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst thread = await client.beta.threads.create();\n\nconsole.log(thread.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tthread, err := client.Beta.Threads.New(context.TODO(), openai.BetaThreadNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.Thread;\nimport com.openai.models.beta.threads.ThreadCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Thread thread = client.beta().threads().create();\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") thread = openai.beta.threads.create puts(thread)' response: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699012949,\n \"metadata\": {},\n \"tool_resources\": {}\n}\n" - title: Messages request: curl: "curl https://api.openai.com/v1/threads \\\n-H \"Content-Type: application/json\" \\\n-H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n-H \"OpenAI-Beta: assistants=v2\" \\\n-d '{\n \"messages\": [{\n \"role\": \"user\",\n \"content\": \"Hello, what is AI?\"\n }, {\n \"role\": \"user\",\n \"content\": \"How does AI work? Explain it in simple terms.\"\n }]\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nthread = client.beta.threads.create()\nprint(thread.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const messageThread = await openai.beta.threads.create({\n messages: [\n {\n role: \"user\",\n content: \"Hello, what is AI?\"\n },\n {\n role: \"user\",\n content: \"How does AI work? Explain it in simple terms.\",\n },\n ],\n });\n\n console.log(messageThread);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst thread = await client.beta.threads.create();\n\nconsole.log(thread.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tthread, err := client.Beta.Threads.New(context.TODO(), openai.BetaThreadNewParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.Thread;\nimport com.openai.models.beta.threads.ThreadCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Thread thread = client.beta().threads().create();\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") thread = openai.beta.threads.create puts(thread)' response: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699014083,\n \"metadata\": {},\n \"tool_resources\": {}\n}\n" /threads/runs: post: operationId: createThreadAndRun tags: - Assistants summary: Create a thread and run it in one request. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateThreadAndRunRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Create thread and run group: threads beta: true examples: - title: Default request: curl: "curl https://api.openai.com/v1/threads/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\",\n \"thread\": {\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Explain deep learning to a 5 year old.\"}\n ]\n }\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor thread in client.beta.threads.create_and_run(\n assistant_id=\"assistant_id\",\n):\n print(thread)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.createAndRun({\n assistant_id: \"asst_abc123\",\n thread: {\n messages: [\n { role: \"user\", content: \"Explain deep learning to a 5 year old.\" },\n ],\n },\n });\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.createAndRun({ assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.ThreadCreateAndRunParams;\nimport com.openai.models.beta.threads.runs.Run;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder()\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().createAndRun(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.create_and_run(assistant_id: "assistant_id") puts(run)' response: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699076792,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"queued\",\n \"started_at\": null,\n \"expires_at\": 1699077392,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"required_action\": null,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You are a helpful assistant.\",\n \"tools\": [],\n \"tool_resources\": {},\n \"metadata\": {},\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_completion_tokens\": null,\n \"max_prompt_tokens\": null,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"incomplete_details\": null,\n \"usage\": null,\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" - title: Streaming request: curl: "curl https://api.openai.com/v1/threads/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_123\",\n \"thread\": {\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Hello\"}\n ]\n },\n \"stream\": true\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor thread in client.beta.threads.create_and_run(\n assistant_id=\"assistant_id\",\n):\n print(thread)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.beta.threads.createAndRun({\n assistant_id: \"asst_123\",\n thread: {\n messages: [\n { role: \"user\", content: \"Hello\" },\n ],\n },\n stream: true\n });\n\n for await (const event of stream) {\n console.log(event);\n }\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.createAndRun({ assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.ThreadCreateAndRunParams;\nimport com.openai.models.beta.threads.runs.Run;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder()\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().createAndRun(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.create_and_run(assistant_id: "assistant_id") puts(run)' response: 'event: thread.created data: {"id":"thread_123","object":"thread","created_at":1710348075,"metadata":{}} event: thread.run.created data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.queued data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.in_progress data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"tool_resources":{},"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: thread.run.step.created data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} event: thread.message.in_progress data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[], "metadata":{}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}], "metadata":{}} event: thread.run.step.completed data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed {"id":"run_123","object":"thread.run","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1713226836,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1713226837,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true} event: done data: [DONE] ' - title: Streaming with Functions request: curl: "curl https://api.openai.com/v1/threads/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\",\n \"thread\": {\n \"messages\": [\n {\"role\": \"user\", \"content\": \"What is the weather like in San Francisco?\"}\n ]\n },\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n }\n ],\n \"stream\": true\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor thread in client.beta.threads.create_and_run(\n assistant_id=\"assistant_id\",\n):\n print(thread)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst tools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n }\n];\n\nasync function main() {\n const stream = await openai.beta.threads.createAndRun({\n assistant_id: \"asst_123\",\n thread: {\n messages: [\n { role: \"user\", content: \"What is the weather like in San Francisco?\" },\n ],\n },\n tools: tools,\n stream: true\n });\n\n for await (const event of stream) {\n console.log(event);\n }\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.createAndRun({ assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.NewAndRun(context.TODO(), openai.BetaThreadNewAndRunParams{\n\t\tAssistantID: \"assistant_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.ThreadCreateAndRunParams;\nimport com.openai.models.beta.threads.runs.Run;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder()\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().createAndRun(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.create_and_run(assistant_id: "assistant_id") puts(run)' response: 'event: thread.created data: {"id":"thread_123","object":"thread","created_at":1710351818,"metadata":{}} event: thread.run.created data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} event: thread.run.step.in_progress data: {"id":"step_001","object":"thread.run.step","created_at":1710351819,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710352418,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[]},"usage":null} event: thread.run.step.delta data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"","output":null}}]}}} event: thread.run.step.delta data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"{\""}}]}}} event: thread.run.step.delta data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"location"}}]}}} ... event: thread.run.step.delta data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"ahrenheit"}}]}}} event: thread.run.step.delta data: {"id":"step_001","object":"thread.run.step.delta","delta":{"step_details":{"type":"tool_calls","tool_calls":[{"index":0,"type":"function","function":{"arguments":"\"}"}}]}}} event: thread.run.requires_action data: {"id":"run_123","object":"thread.run","created_at":1710351818,"assistant_id":"asst_123","thread_id":"thread_123","status":"requires_action","started_at":1710351818,"expires_at":1710352418,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":{"type":"submit_tool_outputs","submit_tool_outputs":{"tool_calls":[{"id":"call_XXNp8YGaFrjrSjgqxtC8JJ1B","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}"}}]}},"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":345,"completion_tokens":11,"total_tokens":356},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done data: [DONE] ' /threads/{thread_id}: get: operationId: getThread tags: - Assistants summary: Retrieves a thread. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to retrieve. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ThreadObject' x-oaiMeta: name: Retrieve thread group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nthread = client.beta.threads.retrieve(\n \"thread_id\",\n)\nprint(thread.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const myThread = await openai.beta.threads.retrieve(\n \"thread_abc123\"\n );\n\n console.log(myThread);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst thread = await client.beta.threads.retrieve('thread_id');\n\nconsole.log(thread.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tthread, err := client.Beta.Threads.Get(context.TODO(), \"thread_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.Thread;\nimport com.openai.models.beta.threads.ThreadRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Thread thread = client.beta().threads().retrieve(\"thread_id\");\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") thread = openai.beta.threads.retrieve("thread_id") puts(thread)' response: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699014083,\n \"metadata\": {},\n \"tool_resources\": {\n \"code_interpreter\": {\n \"file_ids\": []\n }\n }\n}\n" post: operationId: modifyThread tags: - Assistants summary: Modifies a thread. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to modify. Only the `metadata` can be modified. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ModifyThreadRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ThreadObject' x-oaiMeta: name: Modify thread group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nthread = client.beta.threads.update(\n thread_id=\"thread_id\",\n)\nprint(thread.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const updatedThread = await openai.beta.threads.update(\n \"thread_abc123\",\n {\n metadata: { modified: \"true\", user: \"abc123\" },\n }\n );\n\n console.log(updatedThread);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst thread = await client.beta.threads.update('thread_id');\n\nconsole.log(thread.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tthread, err := client.Beta.Threads.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", thread.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.Thread;\nimport com.openai.models.beta.threads.ThreadUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n Thread thread = client.beta().threads().update(\"thread_id\");\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") thread = openai.beta.threads.update("thread_id") puts(thread)' response: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1699014083,\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n },\n \"tool_resources\": {}\n}\n" delete: operationId: deleteThread tags: - Assistants summary: Delete a thread. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to delete. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DeleteThreadResponse' x-oaiMeta: name: Delete thread group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -X DELETE\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nthread_deleted = client.beta.threads.delete(\n \"thread_id\",\n)\nprint(thread_deleted.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const response = await openai.beta.threads.delete(\"thread_abc123\");\n\n console.log(response);\n}\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst threadDeleted = await client.beta.threads.delete('thread_id');\n\nconsole.log(threadDeleted.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tthreadDeleted, err := client.Beta.Threads.Delete(context.TODO(), \"thread_id\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", threadDeleted.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.ThreadDeleteParams;\nimport com.openai.models.beta.threads.ThreadDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n ThreadDeleted threadDeleted = client.beta().threads().delete(\"thread_id\");\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") thread_deleted = openai.beta.threads.delete("thread_id") puts(thread_deleted)' response: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread.deleted\",\n \"deleted\": true\n}\n" /threads/{thread_id}/messages: get: operationId: listMessages tags: - Assistants summary: Returns a list of messages for a given thread. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) the messages belong to. - name: limit in: query description: 'A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ' required: false schema: type: integer default: 20 - name: order in: query description: 'Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. ' schema: type: string default: desc enum: - asc - desc - name: after in: query description: 'A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. ' schema: type: string - name: before in: query description: 'A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. ' schema: type: string - name: run_id in: query description: 'Filter messages by the run ID that generated them. ' schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListMessagesResponse' x-oaiMeta: name: List messages group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/messages \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.beta.threads.messages.list(\n thread_id=\"thread_id\",\n)\npage = page.data[0]\nprint(page.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const threadMessages = await openai.beta.threads.messages.list(\n \"thread_abc123\"\n );\n\n console.log(threadMessages.data);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const message of client.beta.threads.messages.list('thread_id')) {\n console.log(message.id);\n}" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Beta.Threads.Messages.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadMessageListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.messages.MessageListPage;\nimport com.openai.models.beta.threads.messages.MessageListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageListPage page = client.beta().threads().messages().list(\"thread_id\");\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") page = openai.beta.threads.messages.list("thread_id") puts(page)' response: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699016383,\n \"assistant_id\": null,\n \"thread_id\": \"thread_abc123\",\n \"run_id\": null,\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"attachments\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"msg_abc456\",\n \"object\": \"thread.message\",\n \"created_at\": 1699016383,\n \"assistant_id\": null,\n \"thread_id\": \"thread_abc123\",\n \"run_id\": null,\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"Hello, what is AI?\",\n \"annotations\": []\n }\n }\n ],\n \"attachments\": [],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"msg_abc123\",\n \"last_id\": \"msg_abc456\",\n \"has_more\": false\n}\n" post: operationId: createMessage tags: - Assistants summary: Create a message. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) to create a message for. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateMessageRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/MessageObject' x-oaiMeta: name: Create message group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/messages \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"role\": \"user\",\n \"content\": \"How does AI work? Explain it in simple terms.\"\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.beta.threads.messages.create(\n thread_id=\"thread_id\",\n content=\"string\",\n role=\"user\",\n)\nprint(message.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const threadMessages = await openai.beta.threads.messages.create(\n \"thread_abc123\",\n { role: \"user\", content: \"How does AI work? Explain it in simple terms.\" }\n );\n\n console.log(threadMessages);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst message = await client.beta.threads.messages.create('thread_id', {\n content: 'string',\n role: 'user',\n});\n\nconsole.log(message.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmessage, err := client.Beta.Threads.Messages.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadMessageNewParams{\n\t\t\tContent: openai.BetaThreadMessageNewParamsContentUnion{\n\t\t\t\tOfString: openai.String(\"string\"),\n\t\t\t},\n\t\t\tRole: openai.BetaThreadMessageNewParamsRoleUser,\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.messages.Message;\nimport com.openai.models.beta.threads.messages.MessageCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageCreateParams params = MessageCreateParams.builder()\n .threadId(\"thread_id\")\n .content(\"string\")\n .role(MessageCreateParams.Role.USER)\n .build();\n Message message = client.beta().threads().messages().create(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") message = openai.beta.threads.messages.create("thread_id", content: "string", role: :user) puts(message)' response: "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1713226573,\n \"assistant_id\": null,\n \"thread_id\": \"thread_abc123\",\n \"run_id\": null,\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"attachments\": [],\n \"metadata\": {}\n}\n" /threads/{thread_id}/messages/{message_id}: get: operationId: getMessage tags: - Assistants summary: Retrieve a message. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) to which this message belongs. - in: path name: message_id required: true schema: type: string description: The ID of the message to retrieve. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/MessageObject' x-oaiMeta: name: Retrieve message group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.beta.threads.messages.retrieve(\n message_id=\"message_id\",\n thread_id=\"thread_id\",\n)\nprint(message.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const message = await openai.beta.threads.messages.retrieve(\n \"msg_abc123\",\n { thread_id: \"thread_abc123\" }\n );\n\n console.log(message);\n}\n\nmain();" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst message = await client.beta.threads.messages.retrieve('message_id', {\n thread_id: 'thread_id',\n});\n\nconsole.log(message.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmessage, err := client.Beta.Threads.Messages.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.messages.Message;\nimport com.openai.models.beta.threads.messages.MessageRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageRetrieveParams params = MessageRetrieveParams.builder()\n .threadId(\"thread_id\")\n .messageId(\"message_id\")\n .build();\n Message message = client.beta().threads().messages().retrieve(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") message = openai.beta.threads.messages.retrieve("message_id", thread_id: "thread_id") puts(message)' response: "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699017614,\n \"assistant_id\": null,\n \"thread_id\": \"thread_abc123\",\n \"run_id\": null,\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"attachments\": [],\n \"metadata\": {}\n}\n" post: operationId: modifyMessage tags: - Assistants summary: Modifies a message. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to which this message belongs. - in: path name: message_id required: true schema: type: string description: The ID of the message to modify. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ModifyMessageRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/MessageObject' x-oaiMeta: name: Modify message group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmessage = client.beta.threads.messages.update(\n message_id=\"message_id\",\n thread_id=\"thread_id\",\n)\nprint(message.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const message = await openai.beta.threads.messages.update(\n \"thread_abc123\",\n \"msg_abc123\",\n {\n metadata: {\n modified: \"true\",\n user: \"abc123\",\n },\n }\n }'" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst message = await client.beta.threads.messages.update('message_id', { thread_id: 'thread_id' });\n\nconsole.log(message.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmessage, err := client.Beta.Threads.Messages.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t\topenai.BetaThreadMessageUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", message.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.messages.Message;\nimport com.openai.models.beta.threads.messages.MessageUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageUpdateParams params = MessageUpdateParams.builder()\n .threadId(\"thread_id\")\n .messageId(\"message_id\")\n .build();\n Message message = client.beta().threads().messages().update(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") message = openai.beta.threads.messages.update("message_id", thread_id: "thread_id") puts(message)' response: "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1699017614,\n \"assistant_id\": null,\n \"thread_id\": \"thread_abc123\",\n \"run_id\": null,\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"How does AI work? Explain it in simple terms.\",\n \"annotations\": []\n }\n }\n ],\n \"file_ids\": [],\n \"metadata\": {\n \"modified\": \"true\",\n \"user\": \"abc123\"\n }\n}\n" delete: operationId: deleteMessage tags: - Assistants summary: Deletes a message. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to which this message belongs. - in: path name: message_id required: true schema: type: string description: The ID of the message to delete. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DeleteMessageResponse' x-oaiMeta: name: Delete message group: threads beta: true examples: request: curl: "curl -X DELETE https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nmessage_deleted = client.beta.threads.messages.delete(\n message_id=\"message_id\",\n thread_id=\"thread_id\",\n)\nprint(message_deleted.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const deletedMessage = await openai.beta.threads.messages.delete(\n \"msg_abc123\",\n { thread_id: \"thread_abc123\" }\n );\n\n console.log(deletedMessage);\n}" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst messageDeleted = await client.beta.threads.messages.delete('message_id', {\n thread_id: 'thread_id',\n});\n\nconsole.log(messageDeleted.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmessageDeleted, err := client.Beta.Threads.Messages.Delete(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"message_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", messageDeleted.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.messages.MessageDeleteParams;\nimport com.openai.models.beta.threads.messages.MessageDeleted;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n MessageDeleteParams params = MessageDeleteParams.builder()\n .threadId(\"thread_id\")\n .messageId(\"message_id\")\n .build();\n MessageDeleted messageDeleted = client.beta().threads().messages().delete(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") message_deleted = openai.beta.threads.messages.delete("message_id", thread_id: "thread_id") puts(message_deleted)' response: "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message.deleted\",\n \"deleted\": true\n}\n" /threads/{thread_id}/runs: get: operationId: listRuns tags: - Assistants summary: Returns a list of runs belonging to a thread. parameters: - name: thread_id in: path required: true schema: type: string description: The ID of the thread the run belongs to. - name: limit in: query description: 'A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ' required: false schema: type: integer default: 20 - name: order in: query description: 'Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. ' schema: type: string default: desc enum: - asc - desc - name: after in: query description: 'A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. ' schema: type: string - name: before in: query description: 'A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. ' schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListRunsResponse' x-oaiMeta: name: List runs group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.beta.threads.runs.list(\n thread_id=\"thread_id\",\n)\npage = page.data[0]\nprint(page.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const runs = await openai.beta.threads.runs.list(\n \"thread_abc123\"\n );\n\n console.log(runs);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const run of client.beta.threads.runs.list('thread_id')) {\n console.log(run.id);\n}" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Beta.Threads.Runs.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.RunListPage;\nimport com.openai.models.beta.threads.runs.RunListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunListPage page = client.beta().threads().runs().list(\"thread_id\");\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") page = openai.beta.threads.runs.list("thread_id") puts(page)' response: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"incomplete_details\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"tool_resources\": {\n \"code_interpreter\": {\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ]\n }\n },\n \"metadata\": {},\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n },\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n },\n {\n \"id\": \"run_abc456\",\n \"object\": \"thread.run\",\n \"created_at\": 1699063290,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699063290,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699063291,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"incomplete_details\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"tool_resources\": {\n \"code_interpreter\": {\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ]\n }\n },\n \"metadata\": {},\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n },\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n }\n ],\n \"first_id\": \"run_abc123\",\n \"last_id\": \"run_abc456\",\n \"has_more\": false\n}\n" post: operationId: createRun tags: - Assistants summary: Create a run. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to run. - name: include[] in: query description: 'A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ' schema: type: array items: type: string enum: - step_details.tool_calls[*].file_search.results[*].content requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateRunRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Create run group: threads beta: true examples: - title: Default request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\"\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor run in client.beta.threads.runs.create(\n thread_id=\"thread_id\",\n assistant_id=\"assistant_id\",\n):\n print(run)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.create(\n \"thread_abc123\",\n { assistant_id: \"asst_abc123\" }\n );\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.create('thread_id', { assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCreateParams params = RunCreateParams.builder()\n .threadId(\"thread_id\")\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().runs().create(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.create("thread_id", assistant_id: "assistant_id") puts(run)' response: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699063290,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"queued\",\n \"started_at\": 1699063290,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699063291,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"incomplete_details\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"metadata\": {},\n \"usage\": null,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" - title: Streaming request: curl: "curl https://api.openai.com/v1/threads/thread_123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_123\",\n \"stream\": true\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor run in client.beta.threads.runs.create(\n thread_id=\"thread_id\",\n assistant_id=\"assistant_id\",\n):\n print(run)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.beta.threads.runs.create(\n \"thread_123\",\n { assistant_id: \"asst_123\", stream: true }\n );\n\n for await (const event of stream) {\n console.log(event);\n }\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.create('thread_id', { assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCreateParams params = RunCreateParams.builder()\n .threadId(\"thread_id\")\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().runs().create(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.create("thread_id", assistant_id: "assistant_id") puts(run)' response: 'event: thread.run.created data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710330641,"expires_at":1710331240,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710330642,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} event: thread.run.step.completed data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710330642,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed data: {"id":"run_123","object":"thread.run","created_at":1710330640,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710330641,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710330642,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done data: [DONE] ' - title: Streaming with Functions request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"assistant_id\": \"asst_abc123\",\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n }\n ],\n \"stream\": true\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor run in client.beta.threads.runs.create(\n thread_id=\"thread_id\",\n assistant_id=\"assistant_id\",\n):\n print(run)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nconst tools = [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\",\n },\n \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]},\n },\n \"required\": [\"location\"],\n },\n }\n }\n];\n\nasync function main() {\n const stream = await openai.beta.threads.runs.create(\n \"thread_abc123\",\n {\n assistant_id: \"asst_abc123\",\n tools: tools,\n stream: true\n }\n );\n\n for await (const event of stream) {\n console.log(event);\n }\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.create('thread_id', { assistant_id: 'assistant_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.New(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\topenai.BetaThreadRunNewParams{\n\t\t\tAssistantID: \"assistant_id\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCreateParams params = RunCreateParams.builder()\n .threadId(\"thread_id\")\n .assistantId(\"assistant_id\")\n .build();\n Run run = client.beta().threads().runs().create(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.create("thread_id", assistant_id: "assistant_id") puts(run)' response: 'event: thread.run.created data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.queued data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":null,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710348075,"expires_at":1710348675,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.run.step.in_progress data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null} event: thread.message.created data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"Hello","annotations":[]}}]}} ... event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" today"}}]}} event: thread.message.delta data: {"id":"msg_001","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"?"}}]}} event: thread.message.completed data: {"id":"msg_001","object":"thread.message","created_at":1710348076,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710348077,"role":"assistant","content":[{"type":"text","text":{"value":"Hello! How can I assist you today?","annotations":[]}}],"metadata":{}} event: thread.run.step.completed data: {"id":"step_001","object":"thread.run.step","created_at":1710348076,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710348077,"expires_at":1710348675,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31}} event: thread.run.completed data: {"id":"run_123","object":"thread.run","created_at":1710348075,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710348075,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710348077,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done data: [DONE] ' /threads/{thread_id}/runs/{run_id}: get: operationId: getRun tags: - Assistants summary: Retrieves a run. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) that was run. - in: path name: run_id required: true schema: type: string description: The ID of the run to retrieve. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Retrieve run group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.beta.threads.runs.retrieve(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n)\nprint(run.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.retrieve(\n \"run_abc123\",\n { thread_id: \"thread_abc123\" }\n );\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.retrieve('run_id', { thread_id: 'thread_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunRetrieveParams params = RunRetrieveParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .build();\n Run run = client.beta().threads().runs().retrieve(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.retrieve("run_id", thread_id: "thread_id") puts(run)' response: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"incomplete_details\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"metadata\": {},\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n },\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" post: operationId: modifyRun tags: - Assistants summary: Modifies a run. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) that was run. - in: path name: run_id required: true schema: type: string description: The ID of the run to modify. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ModifyRunRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Modify run group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"metadata\": {\n \"user_id\": \"user_abc123\"\n }\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.beta.threads.runs.update(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n)\nprint(run.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.update(\n \"run_abc123\",\n {\n thread_id: \"thread_abc123\",\n metadata: {\n user_id: \"user_abc123\",\n },\n }\n );\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.update('run_id', { thread_id: 'thread_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.Update(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunUpdateParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunUpdateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunUpdateParams params = RunUpdateParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .build();\n Run run = client.beta().threads().runs().update(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.update("run_id", thread_id: "thread_id") puts(run)' response: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075072,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699075072,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699075073,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"incomplete_details\": null,\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"tool_resources\": {\n \"code_interpreter\": {\n \"file_ids\": [\n \"file-abc123\",\n \"file-abc456\"\n ]\n }\n },\n \"metadata\": {\n \"user_id\": \"user_abc123\"\n },\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n },\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" /threads/{thread_id}/runs/{run_id}/cancel: post: operationId: cancelRun tags: - Assistants summary: Cancels a run that is `in_progress`. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to which this run belongs. - in: path name: run_id required: true schema: type: string description: The ID of the run to cancel. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Cancel a run group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/cancel \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -X POST\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun = client.beta.threads.runs.cancel(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n)\nprint(run.id)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.cancel(\n \"run_abc123\",\n { thread_id: \"thread_abc123\" }\n );\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.cancel('run_id', { thread_id: 'thread_id' });\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.Cancel(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunCancelParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunCancelParams params = RunCancelParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .build();\n Run run = client.beta().threads().runs().cancel(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.cancel("run_id", thread_id: "thread_id") puts(run)' response: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699076126,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"cancelling\",\n \"started_at\": 1699076126,\n \"expires_at\": 1699076726,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": \"You summarize books.\",\n \"tools\": [\n {\n \"type\": \"file_search\"\n }\n ],\n \"tool_resources\": {\n \"file_search\": {\n \"vector_store_ids\": [\"vs_123\"]\n }\n },\n \"metadata\": {},\n \"usage\": null,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" /threads/{thread_id}/runs/{run_id}/steps: get: operationId: listRunSteps tags: - Assistants summary: Returns a list of run steps belonging to a run. parameters: - name: thread_id in: path required: true schema: type: string description: The ID of the thread the run and run steps belong to. - name: run_id in: path required: true schema: type: string description: The ID of the run the run steps belong to. - name: limit in: query description: 'A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ' required: false schema: type: integer default: 20 - name: order in: query description: 'Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. ' schema: type: string default: desc enum: - asc - desc - name: after in: query description: 'A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. ' schema: type: string - name: before in: query description: 'A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. ' schema: type: string - name: include[] in: query description: 'A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ' schema: type: array items: type: string enum: - step_details.tool_calls[*].file_search.results[*].content responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ListRunStepsResponse' x-oaiMeta: name: List run steps group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\npage = client.beta.threads.runs.steps.list(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n)\npage = page.data[0]\nprint(page.id)" javascript: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const runStep = await openai.beta.threads.runs.steps.list(\n \"run_abc123\",\n { thread_id: \"thread_abc123\" }\n );\n console.log(runStep);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const runStep of client.beta.threads.runs.steps.list('run_id', {\n thread_id: 'thread_id',\n})) {\n console.log(runStep.id);\n}" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.Beta.Threads.Runs.Steps.List(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunStepListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.steps.StepListPage;\nimport com.openai.models.beta.threads.runs.steps.StepListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n StepListParams params = StepListParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .build();\n StepListPage page = client.beta().threads().runs().steps().list(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") page = openai.beta.threads.runs.steps.list("run_id", thread_id: "thread_id") puts(page)' response: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n },\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n }\n }\n ],\n \"first_id\": \"step_abc123\",\n \"last_id\": \"step_abc456\",\n \"has_more\": false\n}\n" /threads/{thread_id}/runs/{run_id}/steps/{step_id}: get: operationId: getRunStep tags: - Assistants summary: Retrieves a run step. parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the thread to which the run and run step belongs. - in: path name: run_id required: true schema: type: string description: The ID of the run to which the run step belongs. - in: path name: step_id required: true schema: type: string description: The ID of the run step to retrieve. - name: include[] in: query description: 'A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ' schema: type: array items: type: string enum: - step_details.tool_calls[*].file_search.results[*].content responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunStepObject' x-oaiMeta: name: Retrieve run step group: threads beta: true examples: request: curl: "curl https://api.openai.com/v1/threads/thread_abc123/runs/run_abc123/steps/step_abc123 \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\"\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nrun_step = client.beta.threads.runs.steps.retrieve(\n step_id=\"step_id\",\n thread_id=\"thread_id\",\n run_id=\"run_id\",\n)\nprint(run_step.id)" javascript: "import OpenAI from \"openai\";\nconst openai = new OpenAI();\n\nasync function main() {\n const runStep = await openai.beta.threads.runs.steps.retrieve(\n \"step_abc123\",\n { thread_id: \"thread_abc123\", run_id: \"run_abc123\" }\n );\n console.log(runStep);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst runStep = await client.beta.threads.runs.steps.retrieve('step_id', {\n thread_id: 'thread_id',\n run_id: 'run_id',\n});\n\nconsole.log(runStep.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trunStep, err := client.Beta.Threads.Runs.Steps.Get(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\t\"step_id\",\n\t\topenai.BetaThreadRunStepGetParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", runStep.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.steps.RunStep;\nimport com.openai.models.beta.threads.runs.steps.StepRetrieveParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n StepRetrieveParams params = StepRetrieveParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .stepId(\"step_id\")\n .build();\n RunStep runStep = client.beta().threads().runs().steps().retrieve(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run_step = openai.beta.threads.runs.steps.retrieve("step_id", thread_id: "thread_id", run_id: "run_id") puts(run_step)' response: "{\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n },\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n }\n}\n" /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: post: operationId: submitToolOuputsToRun tags: - Assistants summary: 'When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they''re all completed. All outputs must be submitted in a single request. ' parameters: - in: path name: thread_id required: true schema: type: string description: The ID of the [thread](/docs/api-reference/threads) to which this run belongs. - in: path name: run_id required: true schema: type: string description: The ID of the run that requires the tool output submission. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SubmitToolOutputsRunRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/RunObject' x-oaiMeta: name: Submit tool outputs to run group: threads beta: true examples: - title: Default request: curl: "curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"tool_outputs\": [\n {\n \"tool_call_id\": \"call_001\",\n \"output\": \"70 degrees and sunny.\"\n }\n ]\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor run in client.beta.threads.runs.submit_tool_outputs(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n tool_outputs=[{}],\n):\n print(run)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const run = await openai.beta.threads.runs.submitToolOutputs(\n \"run_123\",\n {\n thread_id: \"thread_123\",\n tool_outputs: [\n {\n tool_call_id: \"call_001\",\n output: \"70 degrees and sunny.\",\n },\n ],\n }\n );\n\n console.log(run);\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.submitToolOutputs('run_id', {\n thread_id: 'thread_id',\n tool_outputs: [{}],\n});\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.SubmitToolOutputs(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunSubmitToolOutputsParams{\n\t\t\tToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{{}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunSubmitToolOutputsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunSubmitToolOutputsParams params = RunSubmitToolOutputsParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .addToolOutput(RunSubmitToolOutputsParams.ToolOutput.builder().build())\n .build();\n Run run = client.beta().threads().runs().submitToolOutputs(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.submit_tool_outputs("run_id", thread_id: "thread_id", tool_outputs: [{}]) puts(run)' response: "{\n \"id\": \"run_123\",\n \"object\": \"thread.run\",\n \"created_at\": 1699075592,\n \"assistant_id\": \"asst_123\",\n \"thread_id\": \"thread_123\",\n \"status\": \"queued\",\n \"started_at\": 1699075592,\n \"expires_at\": 1699076192,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": null,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {\n \"name\": \"get_current_weather\",\n \"description\": \"Get the current weather in a given location\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"The city and state, e.g. San Francisco, CA\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"enum\": [\"celsius\", \"fahrenheit\"]\n }\n },\n \"required\": [\"location\"]\n }\n }\n }\n ],\n \"metadata\": {},\n \"usage\": null,\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" - title: Streaming request: curl: "curl https://api.openai.com/v1/threads/thread_123/runs/run_123/submit_tool_outputs \\\n -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -H \"OpenAI-Beta: assistants=v2\" \\\n -d '{\n \"tool_outputs\": [\n {\n \"tool_call_id\": \"call_001\",\n \"output\": \"70 degrees and sunny.\"\n }\n ],\n \"stream\": true\n }'\n" python: "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n api_key=os.environ.get(\"OPENAI_API_KEY\"), # This is the default and can be omitted\n)\nfor run in client.beta.threads.runs.submit_tool_outputs(\n run_id=\"run_id\",\n thread_id=\"thread_id\",\n tool_outputs=[{}],\n):\n print(run)" javascript: "import OpenAI from \"openai\";\n\nconst openai = new OpenAI();\n\nasync function main() {\n const stream = await openai.beta.threads.runs.submitToolOutputs(\n \"run_123\",\n {\n thread_id: \"thread_123\",\n tool_outputs: [\n {\n tool_call_id: \"call_001\",\n output: \"70 degrees and sunny.\",\n },\n ],\n }\n );\n\n for await (const event of stream) {\n console.log(event);\n }\n}\n\nmain();\n" node.js: "import OpenAI from 'openai';\n\nconst client = new OpenAI({\n apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted\n});\n\nconst run = await client.beta.threads.runs.submitToolOutputs('run_id', {\n thread_id: 'thread_id',\n tool_outputs: [{}],\n});\n\nconsole.log(run.id);" go: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openai/openai-go\"\n\t\"github.com/openai/openai-go/option\"\n)\n\nfunc main() {\n\tclient := openai.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\trun, err := client.Beta.Threads.Runs.SubmitToolOutputs(\n\t\tcontext.TODO(),\n\t\t\"thread_id\",\n\t\t\"run_id\",\n\t\topenai.BetaThreadRunSubmitToolOutputsParams{\n\t\t\tToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{{}},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", run.ID)\n}\n" java: "package com.openai.example;\n\nimport com.openai.client.OpenAIClient;\nimport com.openai.client.okhttp.OpenAIOkHttpClient;\nimport com.openai.models.beta.threads.runs.Run;\nimport com.openai.models.beta.threads.runs.RunSubmitToolOutputsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n OpenAIClient client = OpenAIOkHttpClient.fromEnv();\n\n RunSubmitToolOutputsParams params = RunSubmitToolOutputsParams.builder()\n .threadId(\"thread_id\")\n .runId(\"run_id\")\n .addToolOutput(RunSubmitToolOutputsParams.ToolOutput.builder().build())\n .build();\n Run run = client.beta().threads().runs().submitToolOutputs(params);\n }\n}" ruby: 'require "openai" openai = OpenAI::Client.new(api_key: "My API Key") run = openai.beta.threads.runs.submit_tool_outputs("run_id", thread_id: "thread_id", tool_outputs: [{}]) puts(run)' response: 'event: thread.run.step.completed data: {"id":"step_001","object":"thread.run.step","created_at":1710352449,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"tool_calls","status":"completed","cancelled_at":null,"completed_at":1710352475,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"tool_calls","tool_calls":[{"id":"call_iWr0kQ2EaYMaxNdl0v3KYkx7","type":"function","function":{"name":"get_current_weather","arguments":"{\"location\":\"San Francisco, CA\",\"unit\":\"fahrenheit\"}","output":"70 degrees and sunny."}}]},"usage":{"prompt_tokens":291,"completion_tokens":24,"total_tokens":315}} event: thread.run.queued data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"queued","started_at":1710352448,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.in_progress data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"in_progress","started_at":1710352475,"expires_at":1710353047,"cancelled_at":null,"failed_at":null,"completed_at":null,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":null,"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: thread.run.step.created data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} event: thread.run.step.in_progress data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":null} event: thread.message.created data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.in_progress data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}} event: thread.message.delta data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"The","annotations":[]}}]}} event: thread.message.delta data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" current"}}]}} event: thread.message.delta data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" weather"}}]}} ... event: thread.message.delta data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":" sunny"}}]}} event: thread.message.delta data: {"id":"msg_002","object":"thread.message.delta","delta":{"content":[{"index":0,"type":"text","text":{"value":"."}}]}} event: thread.message.completed data: {"id":"msg_002","object":"thread.message","created_at":1710352476,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"completed","incomplete_details":null,"incomplete_at":null,"completed_at":1710352477,"role":"assistant","content":[{"type":"text","text":{"value":"The current weather in San Francisco, CA is 70 degrees Fahrenheit and sunny.","annotations":[]}}],"metadata":{}} event: thread.run.step.completed data: {"id":"step_002","object":"thread.run.step","created_at":1710352476,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"completed","cancelled_at":null,"completed_at":1710352477,"expires_at":1710353047,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_002"}},"usage":{"prompt_tokens":329,"completion_tokens":18,"total_tokens":347}} event: thread.run.completed data: {"id":"run_123","object":"thread.run","created_at":1710352447,"assistant_id":"asst_123","thread_id":"thread_123","status":"completed","started_at":1710352475,"expires_at":null,"cancelled_at":null,"failed_at":null,"completed_at":1710352477,"required_action":null,"last_error":null,"model":"gpt-4o","instructions":null,"tools":[{"type":"function","function":{"name":"get_current_weather","description":"Get the current weather in a given location","parameters":{"type":"object","properties":{"location":{"type":"string","description":"The city and state, e.g. San Francisco, CA"},"unit":{"type":"string","enum":["celsius","fahrenheit"]}},"required":["location"]}}}],"metadata":{},"temperature":1.0,"top_p":1.0,"max_completion_tokens":null,"max_prompt_tokens":null,"truncation_strategy":{"type":"auto","last_messages":null},"incomplete_details":null,"usage":{"prompt_tokens":20,"completion_tokens":11,"total_tokens":31},"response_format":"auto","tool_choice":"auto","parallel_tool_calls":true}} event: done data: [DONE] ' components: schemas: RunStepDetailsToolCallsCodeObject: title: Code Interpreter tool call type: object description: Details of the Code Interpreter tool call the run step was involved in. properties: id: type: string description: The ID of the tool call. type: type: string description: The type of tool call. This is always going to be `code_interpreter` for this type of tool call. enum: - code_interpreter x-stainless-const: true code_interpreter: type: object description: The Code Interpreter tool call definition. required: - input - outputs properties: input: type: string description: The input to the Code Interpreter tool call. outputs: type: array description: The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. items: type: object oneOf: - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeOutputLogsObject' - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeOutputImageObject' required: - id - type - code_interpreter RunStepDetailsToolCallsObject: title: Tool calls type: object description: Details of the tool call. properties: type: description: Always `tool_calls`. type: string enum: - tool_calls x-stainless-const: true tool_calls: type: array description: 'An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. ' items: oneOf: - $ref: '#/components/schemas/RunStepDetailsToolCallsCodeObject' - $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchObject' - $ref: '#/components/schemas/RunStepDetailsToolCallsFunctionObject' required: - type - tool_calls AssistantsApiResponseFormatOption: description: 'Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models#gpt-4o), [GPT-4 Turbo](/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. ' oneOf: - type: string description: '`auto` is the default value ' enum: - auto x-stainless-const: true - $ref: '#/components/schemas/ResponseFormatText' - $ref: '#/components/schemas/ResponseFormatJsonObject' - $ref: '#/components/schemas/ResponseFormatJsonSchema' MessageContentTextObject: title: Text type: object description: The text content that is part of a message. properties: type: description: Always `text`. type: string enum: - text x-stainless-const: true text: type: object properties: value: description: The data that makes up the text. type: string annotations: type: array items: oneOf: - $ref: '#/components/schemas/MessageContentTextAnnotationsFileCitationObject' - $ref: '#/components/schemas/MessageContentTextAnnotationsFilePathObject' required: - value - annotations required: - type - text CreateRunRequest: type: object additionalProperties: false properties: assistant_id: description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. type: string model: description: The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. example: gpt-4o anyOf: - type: string - $ref: '#/components/schemas/AssistantSupportedModels' x-oaiTypeLabel: string nullable: true reasoning_effort: $ref: '#/components/schemas/ReasoningEffort' instructions: description: Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis. type: string nullable: true additional_instructions: description: Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. type: string nullable: true additional_messages: description: Adds additional messages to the thread before creating the run. type: array items: $ref: '#/components/schemas/CreateMessageRequest' nullable: true tools: description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. nullable: true type: array maxItems: 20 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode_2' - $ref: '#/components/schemas/AssistantToolsFileSearch' - $ref: '#/components/schemas/AssistantToolsFunction_2' metadata: $ref: '#/components/schemas/Metadata' 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. ' 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. We generally recommend altering this or temperature but not both. ' stream: type: boolean nullable: true description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. ' max_prompt_tokens: type: integer nullable: true description: 'The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. ' minimum: 256 max_completion_tokens: type: integer nullable: true description: 'The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. ' minimum: 256 truncation_strategy: allOf: - $ref: '#/components/schemas/TruncationObject' - nullable: true tool_choice: allOf: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true parallel_tool_calls: $ref: '#/components/schemas/ParallelToolCalls' response_format: $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true required: - assistant_id CreateThreadRequest: type: object description: 'Options to create a new thread. If no thread is provided when running a request, an empty thread will be created. ' additionalProperties: false properties: messages: description: A list of [messages](/docs/api-reference/messages) to start the thread with. type: array items: $ref: '#/components/schemas/CreateMessageRequest' tool_resources: anyOf: - type: object description: 'A set of resources that are made available to the assistant''s tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. ' properties: code_interpreter: type: object properties: file_ids: type: array description: 'A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. ' default: [] maxItems: 20 items: type: string file_search: type: object properties: vector_store_ids: type: array description: 'The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. ' maxItems: 1 items: type: string vector_stores: type: array description: 'A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. ' maxItems: 1 items: type: object properties: file_ids: type: array description: 'A list of [file](/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files. ' maxItems: 100000000 items: type: string chunking_strategy: type: object description: The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. oneOf: - type: object title: Auto Chunking Strategy description: The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. additionalProperties: false properties: type: type: string description: Always `auto`. enum: - auto x-stainless-const: true required: - type - type: object title: Static Chunking Strategy additionalProperties: false properties: type: type: string description: Always `static`. enum: - static x-stainless-const: true static: type: object additionalProperties: false properties: max_chunk_size_tokens: type: integer minimum: 100 maximum: 4096 description: The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. chunk_overlap_tokens: type: integer description: 'The number of tokens that overlap between chunks. The default value is `400`. Note that the overlap must not exceed half of `max_chunk_size_tokens`. ' required: - max_chunk_size_tokens - chunk_overlap_tokens required: - type - static metadata: $ref: '#/components/schemas/Metadata' oneOf: - required: - vector_store_ids - required: - vector_stores - type: 'null' metadata: $ref: '#/components/schemas/Metadata' CreateMessageRequest: type: object additionalProperties: false required: - role - content properties: role: type: string enum: - user - assistant description: 'The role of the entity that is creating the message. Allowed values include: - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. ' content: oneOf: - type: string description: The text contents of the message. title: Text content - type: array description: An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](/docs/models). title: Array of content parts items: oneOf: - $ref: '#/components/schemas/MessageContentImageFileObject' - $ref: '#/components/schemas/MessageContentImageUrlObject' - $ref: '#/components/schemas/MessageRequestContentTextObject' minItems: 1 attachments: anyOf: - type: array items: type: object properties: file_id: type: string description: The ID of the file to attach to the message. tools: description: The tools to add this file to. type: array items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode_2' - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' description: A list of files attached to the message, and the tools they should be added to. required: - file_id - tools - type: 'null' metadata: $ref: '#/components/schemas/Metadata' ListAssistantFilesResponse: properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/AssistantFileObject' first_id: type: string example: file-abc123 last_id: type: string example: file-abc456 has_more: type: boolean example: false required: - object - data - items - first_id - last_id - has_more MessageContentTextAnnotationsFilePathObject: title: File path type: object description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. properties: type: description: Always `file_path`. type: string enum: - file_path x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string file_path: type: object properties: file_id: description: The ID of the file that was generated. type: string required: - file_id start_index: type: integer minimum: 0 end_index: type: integer minimum: 0 required: - type - text - file_path - start_index - end_index AssistantFileObject: type: object title: Assistant files description: A list of [Files](/docs/api-reference/files) attached to an `assistant`. properties: id: description: The identifier, which can be referenced in API endpoints. type: string object: description: The object type, which is always `assistant.file`. type: string enum: - assistant.file created_at: description: The Unix timestamp (in seconds) for when the assistant file was created. type: integer assistant_id: description: The assistant ID that the file is attached to. type: string required: - id - object - created_at - assistant_id x-oaiMeta: name: The assistant file object beta: true example: "{\n \"id\": \"file-abc123\",\n \"object\": \"assistant.file\",\n \"created_at\": 1699055364,\n \"assistant_id\": \"asst_abc123\"\n}\n" RunStepDetailsMessageCreationObject: title: Message creation type: object description: Details of the message creation by the run step. properties: type: description: Always `message_creation`. type: string enum: - message_creation x-stainless-const: true message_creation: type: object properties: message_id: type: string description: The ID of the message that was created by this run step. required: - message_id required: - type - message_creation CreateAssistantFileRequest: type: object additionalProperties: false properties: file_id: description: A [File](/docs/api-reference/files) ID (with `purpose="assistants"`) that the assistant should use. Useful for tools like `retrieval` and `code_interpreter` that can access files. type: string required: - file_id ResponseFormatJsonSchema: type: object title: JSON schema description: 'JSON Schema response format. Used to generate structured JSON responses. Learn more about [Structured Outputs](/docs/guides/structured-outputs). ' properties: type: type: string description: The type of response format being defined. Always `json_schema`. enum: - json_schema x-stainless-const: true json_schema: type: object title: JSON schema description: 'Structured Outputs configuration options, including a JSON Schema. ' properties: description: type: string description: 'A description of what the response format is for, used by the model to determine how to respond in the format. ' name: type: string description: 'The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. ' schema: $ref: '#/components/schemas/ResponseFormatJsonSchemaSchema' strict: anyOf: - type: boolean default: false description: 'Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). ' - type: 'null' required: - name required: - type - json_schema AssistantToolsFileSearchTypeOnly: type: object title: FileSearch tool properties: type: type: string description: 'The type of tool being defined: `file_search`' enum: - file_search x-stainless-const: true required: - type MessageContentTextAnnotationsFileCitationObject: title: File citation type: object description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. properties: type: description: Always `file_citation`. type: string enum: - file_citation x-stainless-const: true text: description: The text in the message content that needs to be replaced. type: string file_citation: type: object properties: file_id: description: The ID of the specific File the citation is from. type: string required: - file_id start_index: type: integer minimum: 0 end_index: type: integer minimum: 0 required: - type - text - file_citation - start_index - end_index AssistantsApiToolChoiceOption: description: 'Controls which (if any) tool is called by the model. `none` means the model will not call any tools and instead generates a message. `auto` is the default value and means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. ' oneOf: - type: string description: '`none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user. ' enum: - none - auto - required - $ref: '#/components/schemas/AssistantsNamedToolChoice' RunStepDetailsToolCallsFileSearchRankingOptionsObject: title: File search tool call ranking options type: object description: The ranking options for the file search. properties: ranker: $ref: '#/components/schemas/FileSearchRanker' score_threshold: type: number description: The score threshold for the file search. All values must be a floating point number between 0 and 1. minimum: 0 maximum: 1 required: - ranker - score_threshold AssistantsNamedToolChoice: type: object description: Specifies a tool the model should use. Use to force the model to call a specific tool. properties: type: type: string enum: - function - code_interpreter - file_search description: The type of the tool. If type is `function`, the function name must be set function: type: object properties: name: type: string description: The name of the function to call. required: - name required: - type RunStepDetailsToolCallsCodeOutputLogsObject: title: Code Interpreter log output type: object description: Text output from the Code Interpreter tool call as part of a run step. properties: type: description: Always `logs`. type: string enum: - logs x-stainless-const: true logs: type: string description: The text output from the Code Interpreter tool call. required: - type - logs AssistantToolsRetrieval: type: object title: Retrieval tool properties: type: type: string description: 'The type of tool being defined: `retrieval`' enum: - retrieval required: - type AssistantToolsCode: type: object title: Code interpreter tool properties: type: type: string description: 'The type of tool being defined: `code_interpreter`' enum: - code_interpreter required: - type ListRunsResponse: type: object properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/RunObject' first_id: type: string example: run_abc123 last_id: type: string example: run_abc456 has_more: type: boolean example: false required: - object - data - first_id - last_id - has_more ModifyAssistantRequest: type: object additionalProperties: false properties: model: description: model_description anyOf: - type: string name: description: assistant_name_param_description type: string nullable: true maxLength: 256 description: description: assistant_description_param_description type: string nullable: true maxLength: 512 instructions: description: assistant_instructions_param_description type: string nullable: true maxLength: 32768 tools: description: assistant_tools_param_description default: [] type: array maxItems: 128 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode' - $ref: '#/components/schemas/AssistantToolsRetrieval' - $ref: '#/components/schemas/AssistantToolsFunction' x-oaiExpandable: true file_ids: description: 'A list of [File](/docs/api-reference/files) IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previously attached to the list but does not show up in the list, it will be deleted from the assistant. ' default: [] type: array maxItems: 20 items: type: string metadata: description: metadata_description type: object x-oaiTypeLabel: map nullable: true CreateThreadAndRunRequest: type: object additionalProperties: false properties: assistant_id: description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. type: string thread: $ref: '#/components/schemas/CreateThreadRequest' model: description: The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. example: gpt-4o anyOf: - type: string - type: string enum: - gpt-5 - gpt-5-mini - gpt-5-nano - gpt-5-2025-08-07 - gpt-5-mini-2025-08-07 - gpt-5-nano-2025-08-07 - gpt-4.1 - gpt-4.1-mini - gpt-4.1-nano - gpt-4.1-2025-04-14 - gpt-4.1-mini-2025-04-14 - gpt-4.1-nano-2025-04-14 - gpt-4o - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - gpt-4o-mini - gpt-4o-mini-2024-07-18 - gpt-4.5-preview - gpt-4.5-preview-2025-02-27 - gpt-4-turbo - gpt-4-turbo-2024-04-09 - gpt-4-0125-preview - gpt-4-turbo-preview - gpt-4-1106-preview - gpt-4-vision-preview - gpt-4 - gpt-4-0314 - gpt-4-0613 - gpt-4-32k - gpt-4-32k-0314 - gpt-4-32k-0613 - gpt-3.5-turbo - gpt-3.5-turbo-16k - gpt-3.5-turbo-0613 - gpt-3.5-turbo-1106 - gpt-3.5-turbo-0125 - gpt-3.5-turbo-16k-0613 x-oaiTypeLabel: string nullable: true instructions: description: Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. type: string nullable: true tools: description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. nullable: true type: array maxItems: 20 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode_2' - $ref: '#/components/schemas/AssistantToolsFileSearch' - $ref: '#/components/schemas/AssistantToolsFunction_2' tool_resources: type: object description: 'A set of resources that are used by the assistant''s tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. ' properties: code_interpreter: type: object properties: file_ids: type: array description: 'A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. ' default: [] maxItems: 20 items: type: string file_search: type: object properties: vector_store_ids: type: array description: 'The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. ' maxItems: 1 items: type: string nullable: true metadata: $ref: '#/components/schemas/Metadata' 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. ' 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. We generally recommend altering this or temperature but not both. ' stream: type: boolean nullable: true description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. ' max_prompt_tokens: type: integer nullable: true description: 'The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. ' minimum: 256 max_completion_tokens: type: integer nullable: true description: 'The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. ' minimum: 256 truncation_strategy: allOf: - $ref: '#/components/schemas/TruncationObject' - nullable: true tool_choice: allOf: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true parallel_tool_calls: $ref: '#/components/schemas/ParallelToolCalls' response_format: $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true required: - assistant_id MessageContentRefusalObject: title: Refusal type: object description: The refusal content generated by the assistant. properties: type: description: Always `refusal`. type: string enum: - refusal x-stainless-const: true refusal: type: string required: - type - refusal MessageObject: type: object title: The message object description: Represents a message within a [thread](/docs/api-reference/threads). properties: id: description: The identifier, which can be referenced in API endpoints. type: string object: description: The object type, which is always `thread.message`. type: string enum: - thread.message x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the message was created. type: integer format: unixtime thread_id: description: The [thread](/docs/api-reference/threads) ID that this message belongs to. type: string status: description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. type: string enum: - in_progress - incomplete - completed incomplete_details: anyOf: - description: On an incomplete message, details about why the message is incomplete. type: object properties: reason: type: string description: The reason the message is incomplete. enum: - content_filter - max_tokens - run_cancelled - run_expired - run_failed required: - reason - type: 'null' completed_at: anyOf: - description: The Unix timestamp (in seconds) for when the message was completed. type: integer format: unixtime - type: 'null' incomplete_at: anyOf: - description: The Unix timestamp (in seconds) for when the message was marked as incomplete. type: integer format: unixtime - type: 'null' role: description: The entity that produced the message. One of `user` or `assistant`. type: string enum: - user - assistant content: description: The content of the message in array of text and/or images. type: array items: oneOf: - $ref: '#/components/schemas/MessageContentImageFileObject' - $ref: '#/components/schemas/MessageContentImageUrlObject' - $ref: '#/components/schemas/MessageContentTextObject' - $ref: '#/components/schemas/MessageContentRefusalObject' assistant_id: anyOf: - description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. type: string - type: 'null' run_id: anyOf: - description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. type: string - type: 'null' attachments: anyOf: - type: array items: type: object properties: file_id: type: string description: The ID of the file to attach to the message. tools: description: The tools to add this file to. type: array items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode_2' - $ref: '#/components/schemas/AssistantToolsFileSearchTypeOnly' description: A list of files attached to the message, and the tools they were added to. - type: 'null' metadata: $ref: '#/components/schemas/Metadata' required: - id - object - created_at - thread_id - status - incomplete_details - completed_at - incomplete_at - role - content - assistant_id - run_id - attachments - metadata x-oaiMeta: name: The message object beta: true example: "{\n \"id\": \"msg_abc123\",\n \"object\": \"thread.message\",\n \"created_at\": 1698983503,\n \"thread_id\": \"thread_abc123\",\n \"role\": \"assistant\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"value\": \"Hi! How can I help you today?\",\n \"annotations\": []\n }\n }\n ],\n \"assistant_id\": \"asst_abc123\",\n \"run_id\": \"run_abc123\",\n \"attachments\": [],\n \"metadata\": {}\n}\n" ReasoningEffort: anyOf: - type: string enum: - none - minimal - low - medium - high - xhigh default: medium description: 'Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1. - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`. - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort. - `xhigh` is supported for all models after `gpt-5.1-codex-max`. ' - type: 'null' SubmitToolOutputsRunRequest: type: object additionalProperties: false properties: tool_outputs: description: A list of tools for which the outputs are being submitted. type: array items: type: object properties: tool_call_id: type: string description: The ID of the tool call in the `required_action` object within the run object the output is being submitted for. output: type: string description: The output of the tool call to be submitted to continue the run. stream: anyOf: - type: boolean description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. ' - type: 'null' required: - tool_outputs DeleteAssistantFileResponse: type: object description: Deletes the association between the assistant and the file, but does not delete the [File](/docs/api-reference/files) object itself. properties: id: type: string deleted: type: boolean object: type: string enum: - assistant.file.deleted required: - id - object - deleted ResponseFormatText: type: object title: Text description: 'Default response format. Used to generate text responses. ' properties: type: type: string description: The type of response format being defined. Always `text`. enum: - text x-stainless-const: true required: - type ModifyThreadRequest: type: object additionalProperties: false properties: tool_resources: anyOf: - type: object description: 'A set of resources that are made available to the assistant''s tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. ' properties: code_interpreter: type: object properties: file_ids: type: array description: 'A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. ' default: [] maxItems: 20 items: type: string file_search: type: object properties: vector_store_ids: type: array description: 'The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. ' maxItems: 1 items: type: string - type: 'null' metadata: $ref: '#/components/schemas/Metadata' AssistantToolsFileSearch: type: object title: FileSearch tool properties: type: type: string description: 'The type of tool being defined: `file_search`' enum: - file_search x-stainless-const: true file_search: type: object description: Overrides for the file search tool. properties: max_num_results: type: integer minimum: 1 maximum: 50 description: 'The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ' ranking_options: $ref: '#/components/schemas/FileSearchRankingOptions' required: - type RunStepCompletionUsage: anyOf: - type: object description: Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. properties: completion_tokens: type: integer description: Number of completion tokens used over the course of the run step. prompt_tokens: type: integer description: Number of prompt tokens used over the course of the run step. total_tokens: type: integer description: Total number of tokens used (prompt + completion). required: - prompt_tokens - completion_tokens - total_tokens - type: 'null' RunStepDetailsToolCallsFunctionObject: type: object title: Function tool call properties: id: type: string description: The ID of the tool call object. type: type: string description: The type of tool call. This is always going to be `function` for this type of tool call. enum: - function x-stainless-const: true function: type: object description: The definition of the function that was called. properties: name: type: string description: The name of the function. arguments: type: string description: The arguments passed to the function. output: anyOf: - type: string description: The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - type: 'null' required: - name - arguments - output required: - id - type - function RunObject: type: object title: A run on a thread description: Represents an execution run on a [thread](/docs/api-reference/threads). properties: id: description: The identifier, which can be referenced in API endpoints. type: string object: description: The object type, which is always `thread.run`. type: string enum: - thread.run x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the run was created. type: integer format: unixtime thread_id: description: The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. type: string assistant_id: description: The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. type: string status: description: The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. type: string enum: - queued - in_progress - requires_action - cancelling - cancelled - failed - completed - incomplete - expired required_action: type: object description: Details on the action required to continue the run. Will be `null` if no action is required. nullable: true properties: type: description: For now, this is always `submit_tool_outputs`. type: string enum: - submit_tool_outputs x-stainless-const: true submit_tool_outputs: type: object description: Details on the tool outputs needed for this run to continue. properties: tool_calls: type: array description: A list of the relevant tool calls. items: $ref: '#/components/schemas/RunToolCallObject' required: - tool_calls required: - type - submit_tool_outputs last_error: type: object description: The last error associated with this run. Will be `null` if there are no errors. nullable: true properties: code: type: string description: One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. enum: - server_error - rate_limit_exceeded - invalid_prompt message: type: string description: A human-readable description of the error. required: - code - message expires_at: description: The Unix timestamp (in seconds) for when the run will expire. type: integer format: unixtime nullable: true started_at: description: The Unix timestamp (in seconds) for when the run was started. type: integer format: unixtime nullable: true cancelled_at: description: The Unix timestamp (in seconds) for when the run was cancelled. type: integer format: unixtime nullable: true failed_at: description: The Unix timestamp (in seconds) for when the run failed. type: integer format: unixtime nullable: true completed_at: description: The Unix timestamp (in seconds) for when the run was completed. type: integer format: unixtime nullable: true incomplete_details: description: Details on why the run is incomplete. Will be `null` if the run is not incomplete. type: object nullable: true properties: reason: description: The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. type: string enum: - max_completion_tokens - max_prompt_tokens model: description: The model that the [assistant](/docs/api-reference/assistants) used for this run. type: string instructions: description: The instructions that the [assistant](/docs/api-reference/assistants) used for this run. type: string tools: description: The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. default: [] type: array maxItems: 20 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode_2' - $ref: '#/components/schemas/AssistantToolsFileSearch' - $ref: '#/components/schemas/AssistantToolsFunction_2' metadata: $ref: '#/components/schemas/Metadata' usage: $ref: '#/components/schemas/RunCompletionUsage' temperature: description: The sampling temperature used for this run. If not set, defaults to 1. type: number nullable: true top_p: description: The nucleus sampling value used for this run. If not set, defaults to 1. type: number nullable: true max_prompt_tokens: type: integer nullable: true description: 'The maximum number of prompt tokens specified to have been used over the course of the run. ' minimum: 256 max_completion_tokens: type: integer nullable: true description: 'The maximum number of completion tokens specified to have been used over the course of the run. ' minimum: 256 truncation_strategy: allOf: - $ref: '#/components/schemas/TruncationObject' - nullable: true tool_choice: allOf: - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true parallel_tool_calls: $ref: '#/components/schemas/ParallelToolCalls' response_format: $ref: '#/components/schemas/AssistantsApiResponseFormatOption' nullable: true required: - id - object - created_at - thread_id - assistant_id - status - required_action - last_error - expires_at - started_at - cancelled_at - failed_at - completed_at - model - instructions - tools - metadata - usage - incomplete_details - max_prompt_tokens - max_completion_tokens - truncation_strategy - tool_choice - parallel_tool_calls - response_format x-oaiMeta: name: The run object beta: true example: "{\n \"id\": \"run_abc123\",\n \"object\": \"thread.run\",\n \"created_at\": 1698107661,\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"status\": \"completed\",\n \"started_at\": 1699073476,\n \"expires_at\": null,\n \"cancelled_at\": null,\n \"failed_at\": null,\n \"completed_at\": 1699073498,\n \"last_error\": null,\n \"model\": \"gpt-4o\",\n \"instructions\": null,\n \"tools\": [{\"type\": \"file_search\"}, {\"type\": \"code_interpreter\"}],\n \"metadata\": {},\n \"incomplete_details\": null,\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n },\n \"temperature\": 1.0,\n \"top_p\": 1.0,\n \"max_prompt_tokens\": 1000,\n \"max_completion_tokens\": 1000,\n \"truncation_strategy\": {\n \"type\": \"auto\",\n \"last_messages\": null\n },\n \"response_format\": \"auto\",\n \"tool_choice\": \"auto\",\n \"parallel_tool_calls\": true\n}\n" DeleteMessageResponse: type: object properties: id: type: string deleted: type: boolean object: type: string enum: - thread.message.deleted x-stainless-const: true required: - id - object - deleted ListMessagesResponse: properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/MessageObject' first_id: type: string example: msg_abc123 last_id: type: string example: msg_abc123 has_more: type: boolean example: false required: - object - data - first_id - last_id - has_more MessageContentImageFileObject: title: Image file type: object description: References an image [File](/docs/api-reference/files) in the content of a message. properties: type: description: Always `image_file`. type: string enum: - image_file x-stainless-const: true image_file: type: object properties: file_id: description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. type: string detail: type: string description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. enum: - auto - low - high default: auto required: - file_id required: - type - image_file ParallelToolCalls: description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. type: boolean default: true DeleteThreadResponse: type: object properties: id: type: string deleted: type: boolean object: type: string enum: - thread.deleted x-stainless-const: true required: - id - object - deleted AssistantObject: type: object title: Assistant description: Represents an `assistant` that can call the model and use tools. properties: id: description: The identifier, which can be referenced in API endpoints. type: string object: description: The object type, which is always `assistant`. type: string enum: - assistant created_at: description: The Unix timestamp (in seconds) for when the assistant was created. type: integer name: description: 'The name of the assistant. The maximum length is 256 characters. ' type: string maxLength: 256 nullable: true description: description: 'The description of the assistant. The maximum length is 512 characters. ' type: string maxLength: 512 nullable: true model: description: 'ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. ' type: string instructions: description: 'The system instructions that the assistant uses. The maximum length is 32768 characters. ' type: string maxLength: 32768 nullable: true tools: description: 'A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `retrieval`, or `function`. ' default: [] type: array maxItems: 128 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode' - $ref: '#/components/schemas/AssistantToolsRetrieval' - $ref: '#/components/schemas/AssistantToolsFunction' x-oaiExpandable: true file_ids: description: 'A list of [file](/docs/api-reference/files) IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. ' default: [] type: array maxItems: 20 items: type: string metadata: description: 'Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. ' type: object x-oaiTypeLabel: map nullable: true required: - id - object - created_at - name - description - model - instructions - tools - file_ids - metadata x-oaiMeta: name: The assistant object beta: true example: "{\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698984975,\n \"name\": \"Math Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a personal math tutor. When asked a question, write and run Python code to answer the question.\",\n \"tools\": [\n {\n \"type\": \"code_interpreter\"\n }\n ],\n \"file_ids\": [],\n \"metadata\": {}\n}\n" ListRunStepsResponse: properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/RunStepObject' first_id: type: string example: step_abc123 last_id: type: string example: step_abc456 has_more: type: boolean example: false required: - object - data - first_id - last_id - has_more ModifyMessageRequest: type: object additionalProperties: false properties: metadata: $ref: '#/components/schemas/Metadata' FunctionParameters_2: type: object description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list." additionalProperties: true RunStepObject: type: object title: Run steps description: 'Represents a step in execution of a run. ' properties: id: description: The identifier of the run step, which can be referenced in API endpoints. type: string object: description: The object type, which is always `thread.run.step`. type: string enum: - thread.run.step x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the run step was created. type: integer format: unixtime assistant_id: description: The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. type: string thread_id: description: The ID of the [thread](/docs/api-reference/threads) that was run. type: string run_id: description: The ID of the [run](/docs/api-reference/runs) that this run step is a part of. type: string type: description: The type of run step, which can be either `message_creation` or `tool_calls`. type: string enum: - message_creation - tool_calls status: description: The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. type: string enum: - in_progress - cancelled - failed - completed - expired step_details: type: object description: The details of the run step. oneOf: - $ref: '#/components/schemas/RunStepDetailsMessageCreationObject' - $ref: '#/components/schemas/RunStepDetailsToolCallsObject' last_error: anyOf: - type: object description: The last error associated with this run step. Will be `null` if there are no errors. properties: code: type: string description: One of `server_error` or `rate_limit_exceeded`. enum: - server_error - rate_limit_exceeded message: type: string description: A human-readable description of the error. required: - code - message - type: 'null' expired_at: anyOf: - description: The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. type: integer format: unixtime - type: 'null' cancelled_at: anyOf: - description: The Unix timestamp (in seconds) for when the run step was cancelled. type: integer format: unixtime - type: 'null' failed_at: anyOf: - description: The Unix timestamp (in seconds) for when the run step failed. type: integer format: unixtime - type: 'null' completed_at: anyOf: - description: The Unix timestamp (in seconds) for when the run step completed. type: integer format: unixtime - type: 'null' metadata: $ref: '#/components/schemas/Metadata' usage: $ref: '#/components/schemas/RunStepCompletionUsage' required: - id - object - created_at - assistant_id - thread_id - run_id - type - status - step_details - last_error - expired_at - cancelled_at - failed_at - completed_at - metadata - usage x-oaiMeta: name: The run step object beta: true example: "{\n \"id\": \"step_abc123\",\n \"object\": \"thread.run.step\",\n \"created_at\": 1699063291,\n \"run_id\": \"run_abc123\",\n \"assistant_id\": \"asst_abc123\",\n \"thread_id\": \"thread_abc123\",\n \"type\": \"message_creation\",\n \"status\": \"completed\",\n \"cancelled_at\": null,\n \"completed_at\": 1699063291,\n \"expired_at\": null,\n \"failed_at\": null,\n \"last_error\": null,\n \"step_details\": {\n \"type\": \"message_creation\",\n \"message_creation\": {\n \"message_id\": \"msg_abc123\"\n }\n },\n \"usage\": {\n \"prompt_tokens\": 123,\n \"completion_tokens\": 456,\n \"total_tokens\": 579\n }\n}\n" MessageContentImageUrlObject: title: Image URL type: object description: References an image URL in the content of a message. properties: type: type: string enum: - image_url description: The type of the content part. x-stainless-const: true image_url: type: object properties: url: type: string description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' format: uri detail: type: string description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` enum: - auto - low - high default: auto required: - url required: - type - image_url AssistantToolsFunction: type: object title: Function tool properties: type: type: string description: 'The type of tool being defined: `function`' enum: - function function: $ref: '#/components/schemas/FunctionObject' required: - type - function Metadata: anyOf: - type: object description: 'Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. ' additionalProperties: type: string x-oaiTypeLabel: map - type: 'null' ModifyRunRequest: type: object additionalProperties: false properties: metadata: $ref: '#/components/schemas/Metadata' ThreadObject: type: object title: Thread description: Represents a thread that contains [messages](/docs/api-reference/messages). properties: id: description: The identifier, which can be referenced in API endpoints. type: string object: description: The object type, which is always `thread`. type: string enum: - thread x-stainless-const: true created_at: description: The Unix timestamp (in seconds) for when the thread was created. type: integer format: unixtime tool_resources: anyOf: - type: object description: 'A set of resources that are made available to the assistant''s tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. ' properties: code_interpreter: type: object properties: file_ids: type: array description: 'A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. ' default: [] maxItems: 20 items: type: string file_search: type: object properties: vector_store_ids: type: array description: 'The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. ' maxItems: 1 items: type: string - type: 'null' metadata: $ref: '#/components/schemas/Metadata' required: - id - object - created_at - tool_resources - metadata x-oaiMeta: name: The thread object beta: true example: "{\n \"id\": \"thread_abc123\",\n \"object\": \"thread\",\n \"created_at\": 1698107661,\n \"metadata\": {}\n}\n" FileSearchRanker: type: string description: The ranker to use for the file search. If not specified will use the `auto` ranker. enum: - auto - default_2024_08_21 RunStepDetailsToolCallsFileSearchObject: title: File search tool call type: object properties: id: type: string description: The ID of the tool call object. type: type: string description: The type of tool call. This is always going to be `file_search` for this type of tool call. enum: - file_search x-stainless-const: true file_search: type: object description: For now, this is always going to be an empty object. x-oaiTypeLabel: map properties: ranking_options: $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchRankingOptionsObject' results: type: array description: The results of the file search. items: $ref: '#/components/schemas/RunStepDetailsToolCallsFileSearchResultObject' required: - id - type - file_search ResponseFormatJsonObject: type: object title: JSON object description: 'JSON object response format. An older method of generating JSON responses. Using `json_schema` is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so. ' properties: type: type: string description: The type of response format being defined. Always `json_object`. enum: - json_object x-stainless-const: true required: - type FunctionParameters: type: object description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. \n\nOmitting `parameters` defines a function with an empty parameter list." additionalProperties: true AssistantToolsCode_2: type: object title: Code interpreter tool properties: type: type: string description: 'The type of tool being defined: `code_interpreter`' enum: - code_interpreter x-stainless-const: true required: - type DeleteAssistantResponse: type: object properties: id: type: string deleted: type: boolean object: type: string enum: - assistant.deleted required: - id - object - deleted AssistantToolsFunction_2: type: object title: Function tool properties: type: type: string description: 'The type of tool being defined: `function`' enum: - function x-stainless-const: true function: $ref: '#/components/schemas/FunctionObject_2' required: - type - function ResponseFormatJsonSchemaSchema: type: object title: JSON schema description: 'The schema for the response format, described as a JSON Schema object. Learn how to build JSON schemas [here](https://json-schema.org/). ' additionalProperties: true AssistantSupportedModels: type: string enum: - gpt-5 - gpt-5-mini - gpt-5-nano - gpt-5-2025-08-07 - gpt-5-mini-2025-08-07 - gpt-5-nano-2025-08-07 - gpt-4.1 - gpt-4.1-mini - gpt-4.1-nano - gpt-4.1-2025-04-14 - gpt-4.1-mini-2025-04-14 - gpt-4.1-nano-2025-04-14 - o3-mini - o3-mini-2025-01-31 - o1 - o1-2024-12-17 - gpt-4o - gpt-4o-2024-11-20 - gpt-4o-2024-08-06 - gpt-4o-2024-05-13 - gpt-4o-mini - gpt-4o-mini-2024-07-18 - gpt-4.5-preview - gpt-4.5-preview-2025-02-27 - gpt-4-turbo - gpt-4-turbo-2024-04-09 - gpt-4-0125-preview - gpt-4-turbo-preview - gpt-4-1106-preview - gpt-4-vision-preview - gpt-4 - gpt-4-0314 - gpt-4-0613 - gpt-4-32k - gpt-4-32k-0314 - gpt-4-32k-0613 - gpt-3.5-turbo - gpt-3.5-turbo-16k - gpt-3.5-turbo-0613 - gpt-3.5-turbo-1106 - gpt-3.5-turbo-0125 - gpt-3.5-turbo-16k-0613 FunctionObject_2: type: object properties: description: type: string description: A description of what the function does, used by the model to choose when and how to call the function. name: type: string description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. parameters: $ref: '#/components/schemas/FunctionParameters_2' strict: anyOf: - type: boolean default: false description: Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](/docs/guides/function-calling). - type: 'null' required: - name FileSearchRankingOptions: title: File search tool call ranking options type: object description: 'The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. See the [file search tool documentation](/docs/assistants/tools/file-search#customizing-file-search-settings) for more information. ' properties: ranker: $ref: '#/components/schemas/FileSearchRanker' score_threshold: type: number description: The score threshold for the file search. All values must be a floating point number between 0 and 1. minimum: 0 maximum: 1 required: - score_threshold MessageRequestContentTextObject: title: Text type: object description: The text content that is part of a message. properties: type: description: Always `text`. type: string enum: - text x-stainless-const: true text: type: string description: Text content to be sent to the model required: - type - text FunctionObject: type: object properties: description: type: string description: A description of what the function does, used by the model to choose when and how to call the function. name: type: string description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. parameters: $ref: '#/components/schemas/FunctionParameters' required: - name RunCompletionUsage: anyOf: - type: object description: Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). properties: completion_tokens: type: integer description: Number of completion tokens used over the course of the run. prompt_tokens: type: integer description: Number of prompt tokens used over the course of the run. total_tokens: type: integer description: Total number of tokens used (prompt + completion). required: - prompt_tokens - completion_tokens - total_tokens - type: 'null' RunToolCallObject: type: object description: Tool call objects properties: id: type: string description: The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. type: type: string description: The type of tool call the output is required for. For now, this is always `function`. enum: - function x-stainless-const: true function: type: object description: The function definition. properties: name: type: string description: The name of the function. arguments: type: string description: The arguments that the model expects you to pass to the function. required: - name - arguments required: - id - type - function CreateAssistantRequest: type: object additionalProperties: false properties: model: description: model_description anyOf: - type: string name: description: assistant_name_param_description type: string nullable: true maxLength: 256 description: description: assistant_description_param_description type: string nullable: true maxLength: 512 instructions: description: assistant_instructions_param_description type: string nullable: true maxLength: 32768 tools: description: assistant_tools_param_description default: [] type: array maxItems: 128 items: oneOf: - $ref: '#/components/schemas/AssistantToolsCode' - $ref: '#/components/schemas/AssistantToolsRetrieval' - $ref: '#/components/schemas/AssistantToolsFunction' x-oaiExpandable: true file_ids: description: assistant_file_param_description default: [] maxItems: 20 type: array items: type: string metadata: description: metadata_description type: object x-oaiTypeLabel: map nullable: true required: - model TruncationObject: type: object title: Thread Truncation Controls description: Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run. properties: type: type: string description: The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. enum: - auto - last_messages last_messages: anyOf: - type: integer description: The number of most recent messages from the thread when constructing the context for the run. minimum: 1 - type: 'null' required: - type RunStepDetailsToolCallsCodeOutputImageObject: title: Code Interpreter image output type: object properties: type: description: Always `image`. type: string enum: - image x-stainless-const: true image: type: object properties: file_id: description: The [file](/docs/api-reference/files) ID of the image. type: string required: - file_id required: - type - image RunStepDetailsToolCallsFileSearchResultObject: title: File search tool call result type: object description: A result instance of the file search. x-oaiTypeLabel: map properties: file_id: type: string description: The ID of the file that result was found in. file_name: type: string description: The name of the file that result was found in. score: type: number description: The score of the result. All values must be a floating point number between 0 and 1. minimum: 0 maximum: 1 content: type: array description: The content of the result that was found. The content is only included if requested via the include query parameter. items: type: object properties: type: type: string description: The type of the content. enum: - text x-stainless-const: true text: type: string description: The text content of the file. required: - file_id - file_name - score ListAssistantsResponse: type: object properties: object: type: string example: list data: type: array items: $ref: '#/components/schemas/AssistantObject' first_id: type: string example: asst_abc123 last_id: type: string example: asst_abc456 has_more: type: boolean example: false required: - object - data - first_id - last_id - has_more x-oaiMeta: name: List assistants response object group: chat example: "{\n \"object\": \"list\",\n \"data\": [\n {\n \"id\": \"asst_abc123\",\n \"object\": \"assistant\",\n \"created_at\": 1698982736,\n \"name\": \"Coding Tutor\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc456\",\n \"object\": \"assistant\",\n \"created_at\": 1698982718,\n \"name\": \"My Assistant\",\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n },\n {\n \"id\": \"asst_abc789\",\n \"object\": \"assistant\",\n \"created_at\": 1698982643,\n \"name\": null,\n \"description\": null,\n \"model\": \"gpt-4\",\n \"instructions\": null,\n \"tools\": [],\n \"file_ids\": [],\n \"metadata\": {}\n }\n ],\n \"first_id\": \"asst_abc123\",\n \"last_id\": \"asst_abc789\",\n \"has_more\": false\n}\n" securitySchemes: ApiKeyAuth: type: http scheme: bearer x-oaiMeta: groups: - id: audio title: Audio description: 'Learn how to turn audio into text or text into audio. Related guide: [Speech to text](/docs/guides/speech-to-text) ' sections: - type: endpoint key: createSpeech path: createSpeech - type: endpoint key: createTranscription path: createTranscription - type: endpoint key: createTranslation path: createTranslation - id: chat title: Chat description: 'Given a list of messages comprising a conversation, the model will return a response. Related guide: [Chat Completions](/docs/guides/text-generation) ' sections: - type: endpoint key: createChatCompletion path: create - type: object key: CreateChatCompletionResponse path: object - type: object key: CreateChatCompletionStreamResponse path: streaming - id: embeddings title: Embeddings description: 'Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. Related guide: [Embeddings](/docs/guides/embeddings) ' sections: - type: endpoint key: createEmbedding path: create - type: object key: Embedding path: object - id: fine-tuning title: Fine-tuning description: 'Manage fine-tuning jobs to tailor a model to your specific training data. Related guide: [Fine-tune models](/docs/guides/fine-tuning) ' sections: - type: endpoint key: createFineTuningJob path: create - type: endpoint key: listPaginatedFineTuningJobs path: list - type: endpoint key: listFineTuningEvents path: list-events - type: endpoint key: retrieveFineTuningJob path: retrieve - type: endpoint key: cancelFineTuningJob path: cancel - type: object key: FineTuningJob path: object - type: object key: FineTuningJobEvent path: event-object - id: files title: Files description: 'Files are used to upload documents that can be used with features like [Assistants](/docs/api-reference/assistants) and [Fine-tuning](/docs/api-reference/fine-tuning). ' sections: - type: endpoint key: createFile path: create - type: endpoint key: listFiles path: list - type: endpoint key: retrieveFile path: retrieve - type: endpoint key: deleteFile path: delete - type: endpoint key: downloadFile path: retrieve-contents - type: object key: OpenAIFile path: object - id: images title: Images description: 'Given a prompt and/or an input image, the model will generate a new image. Related guide: [Image generation](/docs/guides/images) ' sections: - type: endpoint key: createImage path: create - type: endpoint key: createImageEdit path: createEdit - type: endpoint key: createImageVariation path: createVariation - type: object key: Image path: object - 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. ' sections: - type: endpoint key: listModels path: list - type: endpoint key: retrieveModel path: retrieve - type: endpoint key: deleteModel path: delete - type: object key: Model path: object - id: moderations title: Moderations description: 'Given a input text, outputs if the model classifies it as violating OpenAI''s content policy. Related guide: [Moderations](/docs/guides/moderation) ' sections: - type: endpoint key: createModeration path: create - type: object key: CreateModerationResponse path: object - id: assistants title: Assistants beta: true description: 'Build assistants that can call models and use tools to perform tasks. [Get started with the Assistants API](/docs/assistants) ' sections: - type: endpoint key: createAssistant path: createAssistant - type: endpoint key: createAssistantFile path: createAssistantFile - type: endpoint key: listAssistants path: listAssistants - type: endpoint key: listAssistantFiles path: listAssistantFiles - type: endpoint key: getAssistant path: getAssistant - type: endpoint key: getAssistantFile path: getAssistantFile - type: endpoint key: modifyAssistant path: modifyAssistant - type: endpoint key: deleteAssistant path: deleteAssistant - type: endpoint key: deleteAssistantFile path: deleteAssistantFile - type: object key: AssistantObject path: object - type: object key: AssistantFileObject path: file-object - id: threads title: Threads beta: true description: 'Create threads that assistants can interact with. Related guide: [Assistants](/docs/assistants/overview) ' sections: - type: endpoint key: createThread path: createThread - type: endpoint key: getThread path: getThread - type: endpoint key: modifyThread path: modifyThread - type: endpoint key: deleteThread path: deleteThread - type: object key: ThreadObject path: object - id: messages title: Messages beta: true description: 'Create messages within threads Related guide: [Assistants](/docs/assistants/overview) ' sections: - type: endpoint key: createMessage path: createMessage - type: endpoint key: listMessages path: listMessages - type: endpoint key: listMessageFiles path: listMessageFiles - type: endpoint key: getMessage path: getMessage - type: endpoint key: getMessageFile path: getMessageFile - type: endpoint key: modifyMessage path: modifyMessage - type: object key: MessageObject path: object - type: object key: MessageFileObject path: file-object - id: runs title: Runs beta: true description: 'Represents an execution run on a thread. Related guide: [Assistants](/docs/assistants/overview) ' sections: - type: endpoint key: createRun path: createRun - type: endpoint key: createThreadAndRun path: createThreadAndRun - type: endpoint key: listRuns path: listRuns - type: endpoint key: listRunSteps path: listRunSteps - type: endpoint key: getRun path: getRun - type: endpoint key: getRunStep path: getRunStep - type: endpoint key: modifyRun path: modifyRun - type: endpoint key: submitToolOuputsToRun path: submitToolOutputs - type: endpoint key: cancelRun path: cancelRun - type: object key: RunObject path: object - type: object key: RunStepObject path: step-object - id: completions title: Completions legacy: true description: 'Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our [Chat Completions API](/docs/guides/text-generation/text-generation-models) to leverage our best and newest models. Most models that support the legacy Completions endpoint [will be shut off on January 4th, 2024](/docs/deprecations/2023-07-06-gpt-and-embeddings). ' sections: - type: endpoint key: createCompletion path: create - type: object key: CreateCompletionResponse path: object