Skip to content

Add ImageDetail as a named public type alias (like ReasoningEffort) #2889

@dawid-dol

Description

@dawid-dol

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

The SDK exposes ReasoningEffort as a named TypeAlias in openai.types, making it easy to reference in user code:

from openai.types import ReasoningEffort

cast(ReasoningEffort, reasoning_effort.value if reasoning_effort else 'minimal')`

There's no equivalent for the image detail level. The detail field on image input types uses an inline literal across several generated files:

types/responses/response_input_image_content.py — detail: Optional[Literal["low", "high", "auto"]]
types/responses/response_input_image_content_param.py — detail: Optional[Literal["low", "high", "auto"]]
types/chat/chat_completion_content_part_image.py — detail: Optional[Literal["auto", "low", "high"]]

Users who need to type or cast this value are forced to repeat the inline literal or define their own alias:

cast(Literal["low", "high", "auto"], image_quality.value if image_quality else 'high')

Proposed change

Add ImageDetail as a named type alias following the same pattern as ReasoningEffort:

# openai/types/shared/image_detail.py
from typing import Optional
from typing_extensions import Literal, TypeAlias

__all__ = ["ImageDetail"]

ImageDetail: TypeAlias = Optional[Literal["low", "high", "auto"]]

Export it from openai.types so users can import it directly:

from openai.types import ImageDetail

Before:

cast(Literal["low", "high", "auto"], image_quality.value if image_quality else 'high')

After:

cast(ImageDetail, image_quality.value if image_quality else 'high')

And use it as the field type across the relevant generated models instead of the inline literal.

Why this matters?

It would add consistency with the existing ReasoningEffort pattern and cleaner user code when casting or annotating image detail values.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions