yera.cli.model_discovery.openai
OpenAI provider setup handler.
Symbols
OpenAIModelDiscovery
BaseModelDiscoveryHandler for discovering models from OpenAI.
This class connects to the OpenAI API using a provided API key to retrieve all available models and categorises them into LLM, Embeddings, TTS, or STT configurations based on their model IDs.
Methods
OpenAIModelDiscovery.discover
discover() → DiscoveredModelsFetches and classifies all available models from the OpenAI API.
The discovery process follows these steps:
1. Validates that the connection is an OpenAIConnection.
2. Retrieves the API key from the environment variable specified in the connection.
3. Initialises the OpenAI client and fetches the full list of models.
4. Uses classify_openai_model to determine the model type.
5. Maps each valid model to its corresponding Yera configuration object.
Returns
A DiscoveredModels object containing lists of discovered LLMs, embeddings, TTS, and STT configurations.
Raises
If the provided connection object is not an OpenAIConnection.
If the required API key environment variable is not set.