Skip to content

config

Configuration module for Focoos AI SDK.

This module defines the configuration settings for the Focoos AI SDK, including API credentials, logging levels, default endpoints, and runtime preferences. It provides a centralized way to manage SDK behavior through environment variables.

Classes:

Name Description
FocoosConfig

Pydantic settings class for Focoos SDK configuration.

Constants

LogLevel: Type definition for supported logging levels. FOCOOS_CONFIG: Global configuration instance used throughout the SDK.

FocoosConfig #

Bases: BaseSettings

Configuration settings for the Focoos AI SDK.

This class uses pydantic_settings to manage configuration values, supporting environment variable overrides and validation. All attributes can be configured via environment variables with the same name.

Attributes:

Name Type Description
focoos_api_key Optional[str]

API key for authenticating with Focoos services. Required for accessing protected API endpoints. Defaults to None.

focoos_log_level LogLevel

Logging level for the SDK to control verbosity. Defaults to "DEBUG".

default_host_url str

Default API endpoint URL for all service requests. Defaults to the production API URL.

runtime_type RuntimeTypes

Default runtime type for model inference engines. Defaults to TORCHSCRIPT_32 for optimal performance.

warmup_iter int

Number of warmup iterations for model initialization to stabilize performance metrics. Defaults to 2.

Example

Setting configuration via environment variables in bash:

1
2
3
4
5
6
7
8
9
# Set API key and change log level
export FOCOOS_API_KEY="your-api-key-here"
export FOCOOS_LOG_LEVEL="INFO"
export DEFAULT_HOST_URL="https://custom-api-endpoint.com"
export RUNTIME_TYPE="ONNX_CUDA32"
export WARMUP_ITER="3"

# Then run your Python application
python your_app.py

Source code in focoos/config.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class FocoosConfig(BaseSettings):
    """
    Configuration settings for the Focoos AI SDK.

    This class uses pydantic_settings to manage configuration values,
    supporting environment variable overrides and validation. All attributes
    can be configured via environment variables with the same name.

    Attributes:
        focoos_api_key (Optional[str]): API key for authenticating with Focoos services.
            Required for accessing protected API endpoints. Defaults to None.
        focoos_log_level (LogLevel): Logging level for the SDK to control verbosity.
            Defaults to "DEBUG".
        default_host_url (str): Default API endpoint URL for all service requests.
            Defaults to the production API URL.
        runtime_type (RuntimeTypes): Default runtime type for model inference engines.
            Defaults to TORCHSCRIPT_32 for optimal performance.
        warmup_iter (int): Number of warmup iterations for model initialization to
            stabilize performance metrics. Defaults to 2.

    Example:
        Setting configuration via environment variables in bash:
        ```bash
        # Set API key and change log level
        export FOCOOS_API_KEY="your-api-key-here"
        export FOCOOS_LOG_LEVEL="INFO"
        export DEFAULT_HOST_URL="https://custom-api-endpoint.com"
        export RUNTIME_TYPE="ONNX_CUDA32"
        export WARMUP_ITER="3"

        # Then run your Python application
        python your_app.py
        ```
    """

    focoos_api_key: Optional[str] = None
    focoos_log_level: LogLevel = "DEBUG"
    default_host_url: str = PROD_API_URL
    runtime_type: RuntimeType = RuntimeType.TORCHSCRIPT_32
    warmup_iter: int = 2