Authentication & API Keys
Authenticate the SDK with your platform API key or account credentials. Complete installation first.
Once installed, point the client at the trial host (https://api.trials.aip-v2.resarodev.ai) and authenticate. There are two kinds of credential:
- Account username + password — your login for the platform. The client exchanges them for a short-lived JWT on demand, so nothing needs to be provisioned ahead of time. Best for interactive scripts and notebooks.
- API key — a pre-issued, long-lived key (sent in your credentials email). Best for CI/CD and unattended jobs, where an interactive login isn't possible.
Either credential can be supplied two ways — directly to the SDK via aip.init(), or exported as environment variables (which the SDK reads) — described below.
SDK (Python)
Call aip.init() once at process start. It connects to the API and caches the configured client for every later call. Pass whichever credential you're using:
import aip_sdk as aip
# Account credentials — exchanged for a JWT automatically
aip.init("https://api.trials.aip-v2.resarodev.ai", username="<your-username>", password="<your-password>")
# ...or a pre-issued API key
aip.init("https://api.trials.aip-v2.resarodev.ai", api_key="<your-api-key>")
If you'd rather hold the token yourself — to cache it, inspect your identity, or reuse it across processes — call aip.auth.login() and pass the resulting token to aip.init():
import aip_sdk as aip
base_url = "https://api.trials.aip-v2.resarodev.ai"
result = aip.auth.login("<your-username>", "<your-password>", base_url=base_url)
aip.init(base_url, token=result.access_token)
Environment variables
Environment variables override the config file. Set the API host and workspace in the shell where you will run your Python script:
export AIP_API_URL="https://api.trials.aip-v2.resarodev.ai"
export AIP_WORKSPACE_ID="<your-workspace-id>"
The SDK reads AIP_WORKSPACE_ID automatically. If you only have a workspace name, resolve it with aip.Workspace.get_by_name("<your-workspace-name>") after authenticating and use the returned .id. AIP_WORKSPACE_NAME is a convention used by some example scripts; the SDK does not read it as configuration.
Then choose one credential method. Remove any previously exported credentials for the other methods before switching.
For a pre-issued API key:
export AIP_API_KEY="<your-api-key>"
For account credentials, which the SDK exchanges for a token (AIP_EMAIL is also accepted in place of AIP_USERNAME):
export AIP_USERNAME="<your-username>"
export AIP_PASSWORD="<your-password>"
For an existing bearer token:
export AIP_TOKEN="<your-bearer-token>"
Credential resolution precedence
Every setting resolves through the same four layers, each falling back independently:
explicit params > env vars > config file > defaults
The credential fields (token, username+password, api_key) follow one extra rule
on top of that: resolution stops as soon as one layer's values form a complete
credential, in this order --
token > username + password > api_key
-- so a stale credential in a lower layer (e.g. an expired token left in the config
file) can never outrank one already usable higher up. This is why passing username/
password (or an api_key) to aip.init() always wins over a leftover AIP_TOKEN in
your environment, and why login()'s base_url (above) needs to be explicit rather
than left to fall back on its own.
Verify your credentials work
Before running a full evaluation, confirm the SDK can reach the platform and authenticate. This catches authentication, URL, and workspace problems before starting a longer run.
Save the following as verify_auth.py. It uses AIP_API_URL and the credential method you exported above:
import os
import aip_sdk as aip
aip.init(os.environ["AIP_API_URL"])
workspace = aip.Workspace.get(os.environ["AIP_WORKSPACE_ID"])
print(f"✓ Connected — workspace {workspace.name} (id {workspace.id})")
Run it from the same shell:
python verify_auth.py
An AuthError means the credentials are missing, invalid, or expired. A NotFoundError means no accessible workspace matches AIP_WORKSPACE_ID. See Troubleshooting.