Base API Processor Class
Base API Processor Class
Details
Abstract base class for API processors that provides common functionality including unified logging, error handling, input processing, and response validation. This eliminates code duplication across all provider-specific processors.
Public fields
provider_nameName of the API provider
loggerUnified logger instance
base_urlCustom base URL for API endpoints
Methods
Method new()
Initialize the base API processor
Usage
BaseAPIProcessor$new(provider_name, base_url = NULL)Method process_request()
Main entry point for processing API requests
Arguments
promptPrompt text to send
modelModel identifier
api_keyProvider API key
normalizeLogical. If
TRUE(default), the response is normalized into non-empty trimmed lines. IfFALSE, the raw response string is returned instead. Set toFALSEwhen the caller needs the original text (e.g., JSON parsing in reasoning mode).
Method get_default_api_url()
Abstract method to be implemented by subclasses for getting default API URL
Method make_api_call()
Abstract method to be implemented by subclasses for making the actual API call
Method extract_response_content()
Abstract method to be implemented by subclasses for extracting content from response