OpenAI Assistants API

Build Assistants that can call models and use tools.

Operations 27

GET /assistants OpenAI Returns a list of assistants. #
POST /assistants OpenAI Create an assistant with a model and instructions. #
GET /assistants/{assistant_id} OpenAI Retrieves an assistant. #
POST /assistants/{assistant_id} OpenAI Modifies an assistant. #
DELETE /assistants/{assistant_id} OpenAI Delete an assistant. #
GET /assistants/{assistant_id}/files OpenAI Returns a list of assistant files. #
POST /assistants/{assistant_id}/files OpenAI Create an assistant file by attaching a [File](/docs/api-reference/files) to an [assistant](/docs/api-reference/assistants). #
GET /assistants/{assistant_id}/files/{file_id} OpenAI Retrieves an AssistantFile. #
DELETE /assistants/{assistant_id}/files/{file_id} OpenAI Delete an assistant file. #
POST /threads Create a thread. #
POST /threads/runs Create a thread and run it in one request. #
GET /threads/{thread_id} Retrieves a thread. #
POST /threads/{thread_id} Modifies a thread. #
DELETE /threads/{thread_id} Delete a thread. #
GET /threads/{thread_id}/messages Returns a list of messages for a given thread. #
POST /threads/{thread_id}/messages Create a message. #
GET /threads/{thread_id}/messages/{message_id} Retrieve a message. #
POST /threads/{thread_id}/messages/{message_id} Modifies a message. #
DELETE /threads/{thread_id}/messages/{message_id} Deletes a message. #
GET /threads/{thread_id}/runs Returns a list of runs belonging to a thread. #
POST /threads/{thread_id}/runs Create a run. #
GET /threads/{thread_id}/runs/{run_id} Retrieves a run. #
POST /threads/{thread_id}/runs/{run_id} Modifies a run. #
POST /threads/{thread_id}/runs/{run_id}/cancel Cancels a run that is `in_progress`. #
GET /threads/{thread_id}/runs/{run_id}/steps Returns a list of run steps belonging to a run. #
GET /threads/{thread_id}/runs/{run_id}/steps/{step_id} Retrieves a run step. #
POST /threads/{thread_id}/runs/{run_id}/submit_tool_outputs 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 #

Documentation

📖
Documentation
https://platform.openai.com/docs/assistants/overview
📖
Documentation
https://platform.openai.com/docs/api-reference/assistants
📖
Documentation
https://platform.openai.com/docs/guides/text-to-speech
📖
Documentation
https://platform.openai.com/docs/api-reference/audio
📖
Documentation
https://platform.openai.com/docs/guides/speech-to-text
📖
Documentation
https://developers.openai.com/api/docs/guides/audio/
📖
Documentation
https://developers.openai.com/api/docs/guides/voice-agents/
📖
Documentation
https://platform.openai.com/docs/api-reference/chat
📖
Documentation
https://platform.openai.com/docs/guides/embeddings
📖
Documentation
https://platform.openai.com/docs/api-reference/embeddings
📖
Documentation
https://platform.openai.com/docs/api-reference/files
📖
Documentation
https://platform.openai.com/docs/guides/fine-tuning
📖
Documentation
https://platform.openai.com/docs/api-reference/fine-tuning
📖
Documentation
https://platform.openai.com/docs/guides/images
📖
Documentation
https://platform.openai.com/docs/api-reference/images
📖
Documentation
https://platform.openai.com/docs/guides/image-generation
📖
Documentation
https://platform.openai.com/docs/guides/images-vision
📖
Documentation
https://platform.openai.com/docs/models
📖
Documentation
https://platform.openai.com/docs/api-reference/models
📖
Documentation
https://platform.openai.com/docs/assistants/how-it-works/managing-threads-and-messages
📖
Documentation
https://platform.openai.com/docs/api-reference/threads
📖
Documentation
https://platform.openai.com/docs/api-reference/completions

Specifications

Schemas & Data

Other Resources

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/openai-assistants-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

openai-assistants-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Openai Assistants API
  contact:
    name: OpenAI Support
    url: https://help.openai.com/
  license:
    name: MIT
    url: https://github.com/openai/openai-openapi/blob/master/LICENSE
  termsOfService: https://openai.com/policies/terms-of-use
  version: '1.0'
  description: 'Operations tagged Assistants across 3 of this provider''s published API definitions: assistants-openapi-original.yml, files-openapi-original.yml, openai-openapi-master.yml. Each path carries the servers of the definition it was published in.'
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"
    servers:
    - url: https://api.openai.com/v1
  /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"
    servers:
    - url: https://api.openai.com/v1
  /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"
    servers:
    - url: https://api.openai.com/v1
  /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"
    servers:
    - url: https://api.openai.com/v1
  /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"
    servers:
    - url: https://api.openai.com/v1
  /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           

# --- truncated at 32 KB (265 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/openai/refs/heads/main/openapi/openai-assistants-api-openapi.yml