π Authentication
To ensure secure and authorized communication with WyseOS, all interactions via the Python SDK require an API key.
This guide will walk you through the process of obtaining your API key and securely configuring it.
π‘οΈ 1. Obtaining Your WyseOS API Key
Follow these simple steps to acquire your unique API key from the WyseOS dashboard:
- Sign up or Log in: Visit mate.wyseos.com and either create a new account or log in to your existing one.
- Access Dashboard: Navigate to your personal dashboard.
- Generate API Key: Locate the API key management section and create a new key. Immediately save this key in a secure location, as it will not be displayed again. This key is your credential for all interactions.
βοΈ 2. Configuring Your API Key
Securely configuring your API key is crucial for the integrity of your application. The Python SDK offers several flexible methods:
π Preferred Method: Using a mate.yaml file
Using a mate.yaml file is the recommended and most secure way to manage your API key, keeping sensitive information separate from your application's source code. Create this file in the root directory of your project:
api_key: "your-api-key-here"
base_url: "https://api.wyseos.com"
timeout: 30Configuration Fields Explained:
| Field | Type | Description | Default Value |
|---|---|---|---|
api_key | string | Your unique API key obtained from the WyseOS dashboard. Required. | (None) |
base_url | string | The base URL for the WyseOS API. | https://api.wyseos.com |
timeout | integer | The maximum duration (in seconds) for API requests to respond. | 30 |
Loading the mate.yaml Configuration:
Integrate the configuration into your Python application using load_config():
from wyseos.mate import Client
from wyseos.mate.config import load_config
# Attempt to load configuration from the default mate.yaml location
config = load_config()
if config:
client = Client(config)
print("Client initialized successfully from mate.yaml.")
else:
print("Warning: mate.yaml not found. Falling back to in-code configuration. "
"Consider using mate.yaml for better security in production.")
# Fallback for demonstration/development (replace 'YOUR_API_KEY' with your actual key)
from wyseos.mate import ClientOptions
client = Client(ClientOptions(api_key="YOUR_API_KEY"))π» 3. Alternative Method: In-Code Configuration
For quick testing or scenarios where a configuration file is not feasible, you can pass your API key directly during Client initialization. This method is generally not recommended for production environments due to the risk of exposing credentials in source code.
from wyseos.mate import Client, ClientOptions
client = Client(ClientOptions(
api_key="YOUR_API_KEY", # Replace with your actual API key
base_url="https://api.wyseos.com",
timeout=30
))