Unified API: Full Test Example
Comprehensive Python Example
Below is a Python script that demonstrates how to call each major endpoint. You can copy/paste and adjust the variables.
PYTHONimport requests import json BASE_URL = "https://api.levangie-laboratories.com" AUTH_TOKEN = "YOUR_USER_ID:TIMESTAMP:RANDOM" API_KEY = "YOUR_API_KEY" AGENT_ID = "YOUR_AGENT_ID" # 1. Check your credits via /info info_payload = { "auth_token": AUTH_TOKEN, "action": "get_credits" } res = requests.post(f"{BASE_URL}/info", json=info_payload) print("[INFO] Credits:", res.json()) # 2. Create an API Key via /createapikey (optional if you want a new one) create_key_payload = { "auth_token": AUTH_TOKEN, "key_name": "MyTestKey" } res = requests.post(f"{BASE_URL}/createapikey", json=create_key_payload) print("[CREATE KEY] Response:", res.json()) # 3. Perform an operation (/operation) operation_payload = { "operation": "message", "params": {"text": "Hello from test script"}, "api_key": API_KEY, "agent_id": AGENT_ID } res = requests.post(f"{BASE_URL}/operation", json=operation_payload) print("[OPERATION] Response:", res.json()) # 4. Upload a file (/upload_file) file_path = "agent_data/test.txt" with open("./local_test_file.txt", "rb") as f: files = { "file": f } data = { "api_key": API_KEY, "agent_id": AGENT_ID, "file_path": file_path } res = requests.post(f"{BASE_URL}/upload_file", data=data, files=files) print("[UPLOAD FILE] Response:", res.json())
Logging & Debugging
We recommend adding debug prints or using a logging library for more visibility. If you encounter issues, check your agent’s logs in the Agents Page or contact support.