yera.cli.setup_handlers.anthropic
Anthropic provider setup handler.
Symbols
AnthropicSetup
BaseProviderSetupHandler for configuring Anthropic provider connections.
This class implements the logic required to discover, prompt for, and validate the environment variables used to authenticate with Anthropic's API.
Methods
AnthropicSetup.detect_config
detect_config() → AnthropicConnection | NoneAttempts to automatically detect an Anthropic API key from the environment.
Checks for the presence of the default Anthropic environment variable. If found, it returns a connection configuration pointing to that variable.
Returns
An AnthropicConnection instance if the default environment variable is detected; otherwise, None.
AnthropicSetup.ask_for_config
ask_for_config() → AnthropicConnection | NoneInteractively prompts the user to configure an Anthropic connection.
First asks the user for confirmation to proceed, then prompts for the name of the environment variable that holds the API key.
Returns
An AnthropicConnection instance containing the user-specified environment variable name, or None if the user declines the setup.
AnthropicSetup.validate
validate(
config: AnthropicConnection,
) → NoneValidates the provided Anthropic connection configuration.
This method ensures that the specified environment variable is actually set and that its value matches the expected format of an Anthropic API key (starting with 'sk-ant-' and meeting minimum length requirements).
Parameters
The Anthropic connection configuration to validate.
Raises
If the environment variable is not set or if the API key format is invalid.