Portkey Assistants API

Build Assistants that can call models and use tools.

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/portkey-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 email required.

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

OpenAPI Specification

portkey-assistants-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: Portkey Analytics > Graphs Assistants API
  description: The Portkey REST API. Please see https://portkey.ai/docs/api-reference for more details.
  version: 2.0.0
  termsOfService: https://portkey.ai/terms
  contact:
    name: Portkey Developer Forum
    url: https://portkey.wiki/community
  license:
    name: MIT
    url: https://github.com/Portkey-AI/portkey-openapi/blob/master/LICENSE
servers:
- url: https://api.portkey.ai/v1
  description: Portkey API Public Endpoint
security:
- Portkey-Key: []
tags:
- name: Assistants
  description: Build Assistants that can call models and use tools.
paths:
  /assistants:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    get:
      operationId: listAssistants
      tags:
      - Assistants
      summary: 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl \"https://api.portkey.ai/v1/assistants?order=desc&limit=20\" \\\n          -H \"Content-Type: application/json\" \\\n          -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n          -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n          -H \"OpenAI-Beta: assistants=v2\"\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nmy_assistants = client.beta.assistants.list(\n    order=\"desc\",\n    limit=\"20\",\n)\nprint(my_assistants.data)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const myAssistants = await client.beta.assistants.list({\n    order: \"desc\",\n    limit: \"20\",\n  });\n\n  console.log(myAssistants.data);\n}\n\nmain();\n"
        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-turbo\",\n      \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n      \"tools\": [],\n      \"tool_resources\": {},\n      \"metadata\": {},\n      \"top_p\": 1.0,\n      \"temperature\": 1.0,\n      \"response_format\": \"auto\"\n    },\n    {\n      \"id\": \"asst_abc456\",\n      \"object\": \"assistant\",\n      \"created_at\": 1698982718,\n      \"name\": \"My Assistant\",\n      \"description\": null,\n      \"model\": \"gpt-4-turbo\",\n      \"instructions\": \"You are a helpful assistant designed to make me better at coding!\",\n      \"tools\": [],\n      \"tool_resources\": {},\n      \"metadata\": {},\n      \"top_p\": 1.0,\n      \"temperature\": 1.0,\n      \"response_format\": \"auto\"\n    },\n    {\n      \"id\": \"asst_abc789\",\n      \"object\": \"assistant\",\n      \"created_at\": 1698982643,\n      \"name\": null,\n      \"description\": null,\n      \"model\": \"gpt-4-turbo\",\n      \"instructions\": null,\n      \"tools\": [],\n      \"tool_resources\": {},\n      \"metadata\": {},\n      \"top_p\": 1.0,\n      \"temperature\": 1.0,\n      \"response_format\": \"auto\"\n    }\n  ],\n  \"first_id\": \"asst_abc123\",\n  \"last_id\": \"asst_abc789\",\n  \"has_more\": false\n}\n"
    post:
      operationId: createAssistant
      tags:
      - Assistants
      summary: 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl \"https://api.portkey.ai/v1/assistants\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\" \\\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-turbo\"\n  }'\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\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-turbo\",\n)\nprint(my_assistant)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const myAssistant = await client.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-turbo\",\n  });\n\n  console.log(myAssistant);\n}\n\nmain();\n"
        response: "{\n  \"id\": \"asst_abc123\",\n  \"object\": \"assistant\",\n  \"created_at\": 1698984975,\n  \"name\": \"Math Tutor\",\n  \"description\": null,\n  \"model\": \"gpt-4-turbo\",\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  \"metadata\": {},\n  \"top_p\": 1.0,\n  \"temperature\": 1.0,\n  \"response_format\": \"auto\"\n}\n"
  /assistants/{assistant_id}:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    get:
      operationId: getAssistant
      tags:
      - Assistants
      summary: 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/assistants/asst_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\"\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nmy_assistant = client.beta.assistants.retrieve(\"asst_abc123\")\nprint(my_assistant)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const myAssistant = await client.beta.assistants.retrieve(\n    \"asst_abc123\"\n  );\n\n  console.log(myAssistant);\n}\n\nmain();\n"
        response: "{\n  \"id\": \"asst_abc123\",\n  \"object\": \"assistant\",\n  \"created_at\": 1699009709,\n  \"name\": \"HR Helper\",\n  \"description\": null,\n  \"model\": \"gpt-4-turbo\",\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\": \"file_search\"\n    }\n  ],\n  \"metadata\": {},\n  \"top_p\": 1.0,\n  \"temperature\": 1.0,\n  \"response_format\": \"auto\"\n}\n"
    post:
      operationId: modifyAssistant
      tags:
      - Assistants
      summary: 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/assistants/asst_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\" \\\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\": \"file_search\"}],\n      \"model\": \"gpt-4-turbo\"\n    }'\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\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\": \"file_search\"}],\n  model=\"gpt-4-turbo\"\n)\n\nprint(my_updated_assistant)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const myUpdatedAssistant = await client.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: \"file_search\" }],\n      model: \"gpt-4-turbo\"\n    }\n  );\n\n  console.log(myUpdatedAssistant);\n}\n\nmain();\n"
        response: "{\n  \"id\": \"asst_123\",\n  \"object\": \"assistant\",\n  \"created_at\": 1699009709,\n  \"name\": \"HR Helper\",\n  \"description\": null,\n  \"model\": \"gpt-4-turbo\",\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\": \"file_search\"\n    }\n  ],\n  \"tool_resources\": {\n    \"file_search\": {\n      \"vector_store_ids\": []\n    }\n  },\n  \"metadata\": {},\n  \"top_p\": 1.0,\n  \"temperature\": 1.0,\n  \"response_format\": \"auto\"\n}\n"
    delete:
      operationId: deleteAssistant
      tags:
      - Assistants
      summary: 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/assistants/asst_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\" \\\n  -X DELETE\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nresponse = client.beta.assistants.delete(\"asst_abc123\")\nprint(response)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const response = await client.beta.assistants.del(\"asst_abc123\");\n\n  console.log(response);\n}\nmain();\n"
        response: "{\n  \"id\": \"asst_abc123\",\n  \"object\": \"assistant.deleted\",\n  \"deleted\": true\n}\n"
  /threads:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nmessage_thread = client.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\nprint(message_thread)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const messageThread = await client.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();\n"
        response: "{\n  \"id\": \"thread_abc123\",\n  \"object\": \"thread\",\n  \"created_at\": 1699014083,\n  \"metadata\": {},\n  \"tool_resources\": {}\n}\n"
  /threads/{thread_id}:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads/thread_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\"\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nmy_thread = client.beta.threads.retrieve(\"thread_abc123\")\nprint(my_thread)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const myThread = await client.beta.threads.retrieve(\n    \"thread_abc123\"\n  );\n\n  console.log(myThread);\n}\n\nmain();\n"
        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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads/thread_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\" \\\n  -d '{\n      \"metadata\": {\n        \"modified\": \"true\",\n        \"user\": \"abc123\"\n      }\n    }'\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nmy_updated_thread = client.beta.threads.update(\n  \"thread_abc123\",\n  metadata={\n    \"modified\": \"true\",\n    \"user\": \"abc123\"\n  }\n)\nprint(my_updated_thread)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const updatedThread = await client.beta.threads.update(\n    \"thread_abc123\",\n    {\n      metadata: { modified: \"true\", user: \"abc123\" },\n    }\n  );\n\n  console.log(updatedThread);\n}\n\nmain();\n"
        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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads/thread_abc123 \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\" \\\n  -X DELETE\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nresponse = client.beta.threads.delete(\"thread_abc123\")\nprint(response)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const response = await client.beta.threads.del(\"thread_abc123\");\n\n  console.log(response);\n}\nmain();\n"
        response: "{\n  \"id\": \"thread_abc123\",\n  \"object\": \"thread.deleted\",\n  \"deleted\": true\n}\n"
  /threads/{thread_id}/messages:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    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](https://platform.openai.com/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, 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
      - 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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads/thread_abc123/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY\" \\\n  -H \"OpenAI-Beta: assistants=v2\"\n"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nthread_messages = client.beta.threads.messages.list(\"thread_abc123\")\nprint(thread_messages.data)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const threadMessages = await client.beta.threads.messages.list(\n    \"thread_abc123\"\n  );\n\n  console.log(threadMessages.data);\n}\n\nmain();\n"
        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](https://platform.openai.com/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'
      security:
      - Portkey-Key: []
        Virtual-Key: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
      - Portkey-Key: []
        Config: []
      - Portkey-Key: []
        Provider-Auth: []
        Provider-Name: []
        Custom-Host: []
      x-code-samples:
      - lang: curl
        source: "curl https://api.portkey.ai/v1/threads/thread_abc123/messages \\\n  -H \"Content-Type: application/json\" \\\n  -H \"x-portkey-api-key: $PORTKEY_API_KEY\" \\\n  -H \"x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_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"
      - lang: python
        source: "from portkey_ai import Portkey\n\nclient = Portkey(\n  api_key = \"PORTKEY_API_KEY\",\n  virtual_key = \"PROVIDER_VIRTUAL_KEY\"\n)\n\nthread_message = client.beta.threads.messages.create(\n  \"thread_abc123\",\n  role=\"user\",\n  content=\"How does AI work? Explain it in simple terms.\",\n)\nprint(thread_message)\n"
      - lang: javascript
        source: "import Portkey from 'portkey-ai';\n\nconst client = new Portkey({\n  apiKey: 'PORTKEY_API_KEY',\n  virtualKey: 'PROVIDER_VIRTUAL_KEY'\n});\n\nasync function main() {\n  const threadMessages = await client.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();\n"
        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}:
    servers:
    - url: https://api.portkey.ai/v1
      description: Portkey API Public Endpoint
    - url: SELF_HOSTED_GATEWAY_URL
      description: Self-Hosted Gateway URL
    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](https://platform.openai.com/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 re

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