Skip to content

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.

  • Python 3.10 or later
  • An hlix API key and workspace ID

Create a virtual environment, then install the SDK:

Terminal window
python -m venv .venv
source .venv/bin/activate
python -m pip install hlix-sdk

On Windows, activate it with .venv\Scripts\activate instead. Pin the package version in your application’s dependency file for reproducible builds.

Create list_projects.py:

import asyncio
import 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:

Terminal window
python list_projects.py

The script prints each project’s ID and name in the selected workspace. An empty workspace produces no lines.

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.

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.

  • ModuleNotFoundError: hlix — activate the environment where you installed hlix-sdk, or run python -m pip install hlix-sdk with 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.