Skip to content

Add context length attribute to the model objects returned on the list and retrieve models endpoint. #587

Description

@microsoftbuild

Describe the feature or improvement you're requesting

Description:

At present, the openai.Model.list() function provides a list of model objects, each characterized by four attributes, as exemplified below:

{
  "id": "davinci",
  "object": "model",
  "created": 1686935002,
  "owned_by": "openai"
}

I would like to propose an augmentation to this functionality by introducing an additional attribute that conveys crucial information—the maximum context length or limit of each model.

Request:

I kindly request the incorporation of a new attribute to the model object that signifies the respective model's maximum context length. This enhancement would yield several benefits:

  1. Simplified Code Implementation: By exposing the maximum context length directly through the model object, users can seamlessly adapt their code to automatically respect the context limit. This feature would empower users to fine-tune their applications to the specific capabilities of each model effortlessly, without having to manually store context limits individually for every model.

  2. Enhanced Adaptability: The suggested attribute would enable OpenAI to dynamically adjust a model's context length, if needed, without disrupting users' code. This adaptability reflects a proactive approach towards model improvements while safeguarding the stability of user implementations.

Proposed Attribute:

I propose the inclusion of the following attribute in the model object:

{
  "context_limit": {
    "type": "integer",
    "description": "The maximum context length that the model can effectively handle."
  },
}

The "context_limit" attribute, when integrated into the model object, would be of type "integer." It will succinctly convey the maximum number of tokens can be processed by the model. This clear and concise addition would provide developers with essential information upfront, contributing to an improved development experience.

Additional context

There's been demand for this attribute on the OpenAI dev community as well. Here are the links for your reference:

Activity

  1. added a commit that references this issue on Oct 17, 2023
  2. rattrayalex commented on Nov 10, 2023

    @rattrayalex
    Contributor

    Thanks for the feature request! I've bumped it with the team.

    The dev community is the best place for these; this repo is just for the Python library.

  3. caishuo-C commented on Apr 5, 2024

    @caishuo-C

    After the version update, openai.Model.list() is invalid, now how do I see which models the API can call?

  4. microsoftbuild commented on Apr 5, 2024

    @microsoftbuild
    Author

    Here's API reference showing you how to do that @caishuo-C
    https://platform.openai.com/docs/api-reference/models/list

  5. added a commit that references this issue on Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions