Python SDK
Install the Python SDK, authenticate it, and list projects with the async client.
Use hlix-sdk to call the hlix API from Python. The package imports as hlix and provides async methods generated from the OpenAPI contract.
Prerequisites
Section titled “Prerequisites”- Python 3.10 or later
- An hlix API key and workspace ID
Install
Section titled “Install”Create a virtual environment, then install the SDK:
python -m venv .venvsource .venv/bin/activatepython -m pip install hlix-sdkOn Windows, activate it with .venv\Scripts\activate instead. Pin the package version in your application’s dependency file for reproducible builds.
List projects
Section titled “List projects”Create list_projects.py:
import asyncioimport os
import hlix
async def main() -> None: configuration = hlix.Configuration( host=os.environ.get("HLIX_BASE_URL", "https://server.hlix.ai") ) configuration.api_key["apiKey"] = os.environ["HLIX_API_KEY"]
async with hlix.ApiClient(configuration) as api_client: projects = await hlix.ProjectsApi(api_client).list_projects( x_organization_id=os.environ["HLIX_WORKSPACE_ID"] ) for project in projects: print(project.id, project.name)
asyncio.run(main())Set HLIX_API_KEY and HLIX_WORKSPACE_ID through your shell or secret manager, then run:
python list_projects.pyThe script prints each project’s ID and name in the selected workspace. An empty workspace produces no lines.
Authentication and workspace selection
Section titled “Authentication and workspace selection”Set configuration.api_key["apiKey"] to send the x-api-key header. Pass x_organization_id on workspace-scoped calls. An API key identifies a user; the workspace ID selects where the call acts.
Errors and streaming
Section titled “Errors and streaming”API failures raise hlix.rest.ApiException; inspect its status and body when handling an error. A 404 can mean a resource is absent or unavailable to the caller.
Handle streaming and retries in your application. If a write returns no response, inspect the resource before submitting it again.
Troubleshooting
Section titled “Troubleshooting”ModuleNotFoundError: hlix— activate the environment where you installedhlix-sdk, or runpython -m pip install hlix-sdkwith the interpreter used by your script.KeyError: HLIX_API_KEY— set the environment variable before starting the script.401— the API key is invalid or missing.403— the user cannot perform that action in the selected workspace.404— check the resource ID and workspace; the API does not reveal resources outside your access.