yera.cli.model_discovery.openai

OpenAI provider setup handler.

Symbols

class OpenAIModelDiscovery — Handler for discovering models from OpenAI.

OpenAIModelDiscovery

Handler 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

discover — Fetches and classifies all available models from the OpenAI API.

OpenAIModelDiscovery.discover

discover() → DiscoveredModels

Fetches 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

type: DiscoveredModels

A DiscoveredModels object containing lists of discovered LLMs, embeddings, TTS, and STT configurations.

Raises

TypeError

If the provided connection object is not an OpenAIConnection.

ValueError

If the required API key environment variable is not set.