Skip to main content

Client Initialization

The MoorchehClient is the main entry point to the SDK.

Parameters

Optional[str]
required
Your API key. If None, reads from MOORCHEH_API_KEY environment variable.
Optional[str]
The API base URL. If None, reads from MOORCHEH_BASE_URL or uses the production default.
Optional[float]
default:"30.0"
Request timeout in seconds for all API calls. Defaults to 30.0.

Usage

The recommended way to use the client is with a context manager:
Basic Usage

Authentication Methods

Set Environment Variable
Use Environment Variable

Direct API Key

Direct API Key

Custom Configuration

Custom Configuration

Context Manager Benefits

Using the client as a context manager ensures:
  • Proper cleanup of network resources
  • Automatic connection pooling
  • Exception handling
  • Resource management
Always use the client as a context manager with the with statement to ensure proper resource cleanup.

Error Handling

The client will raise appropriate exceptions for various error conditions:
Error Handling