---
agentTools:
  projectIndex: https://memgpt.readme.io/llms.txt
---

# Create Run

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAI Assistants API",
    "version": "0.1.0"
  },
  "paths": {
    "/openai/v1/threads/{thread_id}/runs": {
      "post": {
        "tags": [
          "threads",
          "runs"
        ],
        "summary": "Create Run",
        "operationId": "create_run_openai_v1_threads__thread_id__runs_post",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "The unique identifier of the thread.",
              "title": "Thread Id"
            },
            "description": "The unique identifier of the thread."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRunRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIRun"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateRunRequest": {
        "properties": {
          "assistant_id": {
            "type": "string",
            "title": "Assistant Id",
            "description": "The unique identifier of the assistant."
          },
          "model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Model",
            "description": "The model used by the run."
          },
          "instructions": {
            "type": "string",
            "title": "Instructions",
            "description": "The instructions for the run."
          },
          "additional_instructions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Additional Instructions",
            "description": "Additional instructions for the run."
          },
          "tools": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/memgpt__schemas__openai__openai__ToolCall"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools",
            "description": "The tools used by the run (overrides assistant)."
          },
          "metadata": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata",
            "description": "Metadata associated with the run."
          }
        },
        "type": "object",
        "required": [
          "assistant_id",
          "instructions"
        ],
        "title": "CreateRunRequest"
      },
      "Function": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name",
            "description": "The name of the function."
          },
          "arguments": {
            "type": "string",
            "title": "Arguments",
            "description": "The arguments of the function."
          }
        },
        "type": "object",
        "required": [
          "name",
          "arguments"
        ],
        "title": "Function"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "OpenAIError": {
        "properties": {
          "code": {
            "type": "string",
            "title": "Code",
            "description": "The error code."
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "The error message."
          }
        },
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "title": "OpenAIError"
      },
      "OpenAIRun": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "The unique identifier of the run."
          },
          "object": {
            "type": "string",
            "title": "Object",
            "default": "thread.run"
          },
          "created_at": {
            "type": "integer",
            "title": "Created At",
            "description": "The unix timestamp of when the run was created."
          },
          "thread_id": {
            "type": "string",
            "title": "Thread Id",
            "description": "The unique identifier of the thread."
          },
          "assistant_id": {
            "type": "string",
            "title": "Assistant Id",
            "description": "The unique identifier of the assistant."
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "The status of the run."
          },
          "required_action": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/RequiredAction"
              },
              {
                "type": "null"
              }
            ],
            "description": "The required action of the run."
          },
          "last_error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OpenAIError"
              },
              {
                "type": "null"
              }
            ],
            "description": "The last error of the run."
          },
          "expires_at": {
            "type": "integer",
            "title": "Expires At",
            "description": "The unix timestamp of when the run expires."
          },
          "started_at": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At",
            "description": "The unix timestamp of when the run started."
          },
          "cancelled_at": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cancelled At",
            "description": "The unix timestamp of when the run was cancelled."
          },
          "failed_at": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Failed At",
            "description": "The unix timestamp of when the run failed."
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At",
            "description": "The unix timestamp of when the run completed."
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "The model used by the run."
          },
          "instructions": {
            "type": "string",
            "title": "Instructions",
            "description": "The instructions for the run."
          },
          "tools": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/memgpt__schemas__openai__openai__ToolCall"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tools",
            "description": "The tools used by the run."
          },
          "file_ids": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "File Ids",
            "description": "List of file IDs associated with the run."
          },
          "metadata": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Metadata",
            "description": "Metadata associated with the run."
          },
          "usage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OpenAIUsage"
              },
              {
                "type": "null"
              }
            ],
            "description": "The usage of the run."
          }
        },
        "type": "object",
        "required": [
          "id",
          "created_at",
          "thread_id",
          "assistant_id",
          "status",
          "expires_at",
          "model",
          "instructions"
        ],
        "title": "OpenAIRun"
      },
      "OpenAIUsage": {
        "properties": {
          "completion_tokens": {
            "type": "integer",
            "title": "Completion Tokens",
            "description": "The number of tokens used for the run."
          },
          "prompt_tokens": {
            "type": "integer",
            "title": "Prompt Tokens",
            "description": "The number of tokens used for the prompt."
          },
          "total_tokens": {
            "type": "integer",
            "title": "Total Tokens",
            "description": "The total number of tokens used for the run."
          }
        },
        "type": "object",
        "required": [
          "completion_tokens",
          "prompt_tokens",
          "total_tokens"
        ],
        "title": "OpenAIUsage"
      },
      "RequiredAction": {
        "properties": {
          "type": {
            "type": "string",
            "title": "Type",
            "default": "submit_tool_outputs"
          },
          "submit_tool_outputs": {
            "items": {
              "$ref": "#/components/schemas/memgpt__schemas__openai__openai__ToolCall"
            },
            "type": "array",
            "title": "Submit Tool Outputs"
          }
        },
        "type": "object",
        "required": [
          "submit_tool_outputs"
        ],
        "title": "RequiredAction"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "memgpt__schemas__openai__openai__ToolCall": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "The unique identifier of the tool call."
          },
          "type": {
            "type": "string",
            "title": "Type",
            "default": "function"
          },
          "function": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Function"
              }
            ],
            "description": "The function call."
          }
        },
        "type": "object",
        "required": [
          "id",
          "function"
        ],
        "title": "ToolCall"
      }
    }
  },
  "servers": [
    {
      "url": "http://memgpt.localhost"
    },
    {
      "url": "http://localhost:8283"
    },
    {
      "url": "http://localhost:8083"
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 205,
      "2": 22,
      "3": 232,
      "4": 121,
      "5": 139,
      "6": 199,
      "7": 0,
      "8": 15,
      "9": 218,
      "10": 177,
      "11": 203
    }
  }
}
```