Class OpenAiResponsesProvider
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
This provider is designed for native agentic workflows, supporting built-in tools and stateful item-based history. It handles model discovery and API key management for the OpenAI platform.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final com.fasterxml.jackson.databind.ObjectMapperInternal Jackson mapper for OpenAI API JSON processing.private HttpClientThe HTTP client used for all communication with the OpenAI API.private booleanFlag indicating if the configured API key belongs to a verified OpenAI organization.Fields inherited from class AbstractAiProvider
MARKUP_TABLE_HEADERModifier and TypeFieldDescriptionstatic final StringMarkdown table header for provider listings.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupportModifier and TypeFieldDescriptionprotected PropertyChangeSupportSupport for firing property change events. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new OpenAiProvider with the 'OpenAI' UUID and standard tokenizer settings.Constructs a new OpenAiProvider with a custom UUID. -
Method Summary
Modifier and TypeMethodDescriptioncreateRequestBuilder(String endpoint) Creates an authorized HTTP Request Builder for the specified endpoint.Gets a template or hint string to display when the API keys file is empty.Lazy-initializes and returns the HTTP client for this provider.booleanisRetryable(int statusCode, String responseBody) Determines if an HTTP status code or response body indicates a transient failure that should trigger a retry or rotation.List<? extends AbstractModel> Fetches the list of all models available from the provider's remote API.Methods inherited from class AbstractAiProvider
addModel, addModels, ensureKeysFileExists, findModels, getAllDisplayModels, getAllSupportedActions, getCachedApiModel, getCurrentKey, getEnabledModels, getKeyPoolSize, getKeysAcquisitionUri, getKeysFilePath, getModel, getModels, getModelsDirectory, getProviderDirectory, getProviderId, getUnloadableModelsDirectory, hasKeys, hokusPocus, initialize, isBaseUrlConfigurable, isEffectivelyEnabled, loadModelsFromDisk, persist, refreshCachedApiModels, reloadKeyPool, reloadKeyPoolIfNeeded, remove, removeModel, setBaseUrl, testConnection, toMarkupRow, toMarkupRowModifier and TypeMethodDescriptionvoidaddModel(AbstractModel model) Adds a new model to this provider's local models list and persists it to disk.voidaddModels(List<AbstractModel> modelsToAdd) Adds multiple models to this provider's local models list, persists each to disk, and fires a single unified property change event for"models".voidEnsures that the API keys file exists on the host filesystem, creating * parent directories and the file if missing.findModels(String query, List<ResponseModality> modalities) Finds and filters models within this provider matching a regex/text query AND all requested response modalities.Gets the combined list of local persisted models and any newly discovered API models that are not yet persisted.Gets a set of all unique supported actions across all models offered by this provider, using the cached model list.getCachedApiModel(String modelId) Finds a cached API model by its unique ID.Returns the API key currently in use by this provider instance, reloading from disk if the file was modified externally.Gets the list of models that are currently enabled for this provider.intReturns the total number of configured API keys for this provider.Gets the URI where users can acquire API keys for this provider.Resolves the path to the API keys configuration file for this provider.Finds a single model by its unique ID within this provider.Gets the master list of model entities for this provider (loaded from disk .kryo files).Resolves the path to the models directory for this provider.Resolves the absolute path to the provider's storage directory in the active container.Compatibility alias forgetUuid()to maintain integration with existing IDE and UI components that expect a provider ID.Gets the directory where model entities that failed to load are quarantined.booleanhasKeys()Checks if there are any valid API keys configured for this provider.voidRotates the active key to the next available API key in the pool.voidInitializes this provider after instantiation and container binding.booleanIndicates whether this provider supports a user-configurable base URL in the UI.booleanChecks if this provider is effectively enabled and ready for active model requests.Loads all persisted models from this provider's models directory on disk into memory.voidpersist()Persists this AI provider entity directly to disk in the container's providers directory (~/.anahata/asi/<hostApp>/<version>/providers/<uuid>.kryo).Queries the provider's remote API to discover models and updatesAbstractAiProvider.cachedApiModels.voidReloads the API key pool from the provider's configuration file and triggers an initial key selection.voidChecks if the API keys configuration file on disk has been modified since it was last loaded.voidremove()Deletes the persisted .kryo file for this AI provider from disk and removes it from its parent container registry.voidremoveModel(AbstractModel model) Removes a model from this provider's in-memory list.voidsetBaseUrl(String baseUrl) Sets the base URL of the provider's API endpoint, normalizing blank strings to null.Tests connectivity to the provider's remote API endpoint and returns a human-readable status summary.Formats this provider as a Markdown table row, defaulting to showing the total count of models.toMarkupRow(boolean includeModelIds) Formats this provider as a Markdown table row for provider listing tools.Methods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerModifier and TypeMethodDescriptionvoidAdds a property change listener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a property change listener for a specific property.voidrebind()Re-initializes the transientPropertyChangeSupportafter deserialization.voidRemoves a property change listener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes a property change listener for a specific property.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupportModifier and TypeMethodDescriptionGets the PropertyChangeSupport instance for this object.
-
Field Details
-
API_MAPPER
private static final com.fasterxml.jackson.databind.ObjectMapper API_MAPPERInternal Jackson mapper for OpenAI API JSON processing. -
verifiedOrganization
private boolean verifiedOrganizationFlag indicating if the configured API key belongs to a verified OpenAI organization.Verified organizations are permitted to use
store: trueand receive plain-text reasoning summaries in their responses without throwing a 400 parameter error on subsequent turns. -
httpClient
The HTTP client used for all communication with the OpenAI API.Marked as transient to prevent serialization of the networking stack.
-
-
Constructor Details
-
OpenAiResponsesProvider
public OpenAiResponsesProvider()Constructs a new OpenAiProvider with the 'OpenAI' UUID and standard tokenizer settings. -
OpenAiResponsesProvider
Constructs a new OpenAiProvider with a custom UUID.- Parameters:
uuid- the unique provider identifier.
-
-
Method Details
-
getHttpClient
Lazy-initializes and returns the HTTP client for this provider.Ensures standard timeouts and redirect policies are applied.
- Returns:
- The active HTTP client.
-
createRequestBuilder
Creates an authorized HTTP Request Builder for the specified endpoint.- Parameters:
endpoint- the target sub-resource endpoint (e.g. "responses").- Returns:
- a pre-configured, authorized HttpRequest Builder.
-
listModels
Fetches the list of all models available from the provider's remote API.Implementation details: Executes a GET request to the
/modelsendpoint of the configuredgetBaseUrl(). Discovered models are filtered to include only those supported by the Responses API (gpt-4o and successor generations).- Specified by:
listModelsin classAbstractAiProvider- Returns:
- A list of provider-specific
AbstractModelobjects.
-
isRetryable
Determines if an HTTP status code or response body indicates a transient failure that should trigger a retry or rotation.- Parameters:
statusCode- The HTTP status code returned by the server.responseBody- The raw response body string.- Returns:
- true if the request can be retried, false otherwise.
-
getApiKeyHint
Gets a template or hint string to display when the API keys file is empty.Provides a template for the OpenAI
api_keys.txtfile.- Specified by:
getApiKeyHintin classAbstractAiProvider- Returns:
- The API key hint text.
-

