Create Thread and Run

Go to Product

Create a thread and run it in one request.

Options

OpenAI Beta
Calls to the Assistants API require that you pass a beta HTTP header.
Body

Request body which must comply to the following JSON Schema:

{
  "required" : [ "assistant_id", "thread_id" ],
  "type" : "object",
  "properties" : {
    "assistant_id" : {
      "type" : "string",
      "description" : "The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run."
    },
    "thread" : {
      "type" : "object",
      "properties" : {
        "messages" : {
          "type" : "array",
          "description" : "A list of [messages](/docs/api-reference/messages) to start the thread with.",
          "items" : {
            "required" : [ "content", "role" ],
            "type" : "object",
            "properties" : {
              "role" : {
                "type" : "string",
                "description" : "The role of the entity that is creating the message. Currently only `user` is supported.",
                "enum" : [ "user" ]
              },
              "content" : {
                "maxLength" : 32768,
                "minLength" : 1,
                "type" : "string",
                "description" : "The content of the message."
              },
              "file_ids" : {
                "maxItems" : 10,
                "minItems" : 1,
                "type" : "array",
                "description" : "A list of [File](/docs/api-reference/files) IDs that the message should use. There can be a maximum of 10 files attached to a message. Useful for tools like `retrieval` and `code_interpreter` that can access and use files.",
                "items" : {
                  "type" : "string"
                },
                "default" : [ ]
              },
              "metadata" : {
                "type" : "object",
                "description" : "metadata_description",
                "nullable" : true,
                "x-oaiTypeLabel" : "map"
              }
            },
            "additionalProperties" : false
          }
        },
        "metadata" : {
          "type" : "object",
          "description" : "metadata_description",
          "nullable" : true,
          "x-oaiTypeLabel" : "map"
        }
      },
      "additionalProperties" : false
    },
    "model" : {
      "type" : "string",
      "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.",
      "nullable" : true
    },
    "instructions" : {
      "type" : "string",
      "description" : "Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.",
      "nullable" : true
    },
    "tools" : {
      "maxItems" : 20,
      "type" : "array",
      "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,
      "items" : {
        "oneOf" : [ {
          "title" : "Code interpreter tool",
          "required" : [ "type" ],
          "type" : "object",
          "properties" : {
            "type" : {
              "type" : "string",
              "description" : "The type of tool being defined: `code_interpreter`",
              "enum" : [ "code_interpreter" ]
            }
          }
        }, {
          "title" : "Retrieval tool",
          "required" : [ "type" ],
          "type" : "object",
          "properties" : {
            "type" : {
              "type" : "string",
              "description" : "The type of tool being defined: `retrieval`",
              "enum" : [ "retrieval" ]
            }
          }
        }, {
          "title" : "Function tool",
          "required" : [ "function", "type" ],
          "type" : "object",
          "properties" : {
            "type" : {
              "type" : "string",
              "description" : "The type of tool being defined: `function`",
              "enum" : [ "function" ]
            },
            "function" : {
              "required" : [ "name" ],
              "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" : {
                  "type" : "object",
                  "additionalProperties" : true,
                  "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."
                }
              }
            }
          }
        } ]
      }
    },
    "metadata" : {
      "type" : "object",
      "description" : "metadata_description",
      "nullable" : true,
      "x-oaiTypeLabel" : "map"
    }
  },
  "additionalProperties" : false
}
Result Format

Specify how the response should be mapped to the table output. The following formats are available:

Raw Response: Returns the raw response in a single row with the following columns:

  • body: Response body
  • status: HTTP status code

Input Ports

Icon
Configuration data.

Output Ports

Icon
Result of the request depending on the selected Result Format.
Icon
Configuration data (this is the same as the input port; it is provided as passthrough for sequentially chaining nodes to declutter your workflow connections).

Popular Predecessors

  • No recommendations found

Popular Successors

  • No recommendations found

Views

This node has no views

Workflows

  • No workflows found

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.