Skip to content

openai_utils

Shared utilities for interacting with the OpenAI API.

Classes:

Name Description
AIModels

Functions:

Name Description
get_usable_models_async

Asynchronously get the usable models, fetching them if not already cached.

get_usable_models_sync

Synchronously get the usable models using asyncio.run().

Attributes:

Name Type Description
client
tts_voices list[str]

client module-attribute

client = AsyncOpenAI()

tts_voices module-attribute

tts_voices: list[str] = extract_literal_values_from_member(
    SpeechCreateParams, "voice"
)

AIModels dataclass

AIModels(
    image_models: list[str],
    speech_models: list[str],
    text_models: list[str],
    other_models: list[str] | None,
)

Attributes:

Name Type Description
image_models list[str]
other_models list[str] | None
speech_models list[str]
text_models list[str]

image_models instance-attribute

image_models: list[str]

other_models instance-attribute

other_models: list[str] | None

speech_models instance-attribute

speech_models: list[str]

text_models instance-attribute

text_models: list[str]

get_usable_models_async async

get_usable_models_async() -> AIModels

Asynchronously get the usable models, fetching them if not already cached.

get_usable_models_sync

get_usable_models_sync() -> AIModels

Synchronously get the usable models using asyncio.run().