Skip to main content

qlam-core

Core Python SDK for QuEra Quantum Computing Services

qlam-core is a Python library for integrating QuEra quantum computing services into your applications. It handles authentication, configuration, and typed API clients for submitting tasks, managing compilations and definitions, retrieving results, and administering tenants, users, and groups.

Public qlam-core documentation is available at Third-Party SDKs (qlam-core).

Features

Feature Description
Multi-flow OAuth 2.0 Device code, PKCE, and client credentials
Multi-context config Multiple named contexts with easy switching
Type-safe API clients Pydantic models with full type hints
Tenant and user administration Manage tenants, audiences, users, and role assignments
Group management Manage groups and membership
Automatic token refresh Seamless credential management
Shared ~/.qsh state Reuses the standard config and credential storage layout

Installation

With pip:

pip install qlam-core

With uv:

# Install into the current environment
uv pip install qlam-core

# Or add it to a uv-managed project
uv add qlam-core

Requirements: Python 3.10+

Quick Start

First, ensure you have a configuration file at ~/.qsh/config.json. If you need a starting point, see Minimal Configuration below.

from qlam_core.common import AppContext
from qlam_core.plugins.tasks import TasksClient

# Create context (uses ~/.qsh/config.json)
ctx = AppContext()

# Use the Tasks API
with TasksClient(ctx) as client:
    tasks = client.list()
    print(f"Found {len(tasks)} tasks")

Core Concepts

AppContext

AppContext is the central object that manages configuration, authentication, and HTTP clients.

from qlam_core.common import AppContext

# Use default context from config
ctx = AppContext()

# Use a specific named context
ctx = AppContext(context_name="production")

print(ctx.config.api_base_url)
print(ctx.config.qpu)

API Clients

qlam-core includes typed clients for:

  • TasksClient
  • ResultsClient
  • CompilationsClient
  • DefinitionsClient
  • TenantsClient
  • UsersClient
  • GroupsClient

All clients follow the same pattern:

from qlam_core.plugins.tasks import TasksClient
from qlam_core.plugins.results import ResultsClient
from qlam_core.plugins.compilations import CompilationsClient
from qlam_core.plugins.definitions import DefinitionsClient

ctx = AppContext()

with TasksClient(ctx) as client:
    tasks = client.list()
    task = client.get(id="task-123")

Administrative clients follow the same pattern:

from qlam_core.plugins.tenants import TenantsClient
from qlam_core.plugins.users import UsersClient
from qlam_core.plugins.groups import GroupsClient

with TenantsClient(ctx) as client:
    tenant_page = client.list_page(size=10)

with UsersClient(ctx) as client:
    user_page = client.list_page(size=10)

with GroupsClient(ctx) as client:
    group_page = client.list_page(size=10)
    by_id = client.list_page(
        id=["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
        size=1,
    )

TenantsClient, UsersClient, and GroupsClient use non-QPU-scoped endpoints, so they do not accept qpu_mode. GroupsClient list helpers also accept optional name, is_shared, and repeatable id filters.

Configuration

Config File Location

By default, qlam-core reads configuration from ~/.qsh/config.json.

qlam-core uses the standard ~/.qsh config and credential layout directly. If you already use qsh, the same config directory and credential storage are reused automatically.

Minimal Configuration

{
  "current_context": "production",
  "contexts": [
    {
      "name": "production",
      "qpu": "your-qpu",
      "defaults": {
        "api_base_url": "https://api.example.com",
        "qpu_mode": "your-qpu-mode",
        "group": "00000000-0000-0000-0000-000000000001",
        "visibility": "public",
        "auth_provider": "oauth-device"
      },
      "auth_providers": [
        {
          "name": "oauth-device",
          "provider": "oauth",
          "auth_base_url": "https://auth.example.com",
          "client_id": "your-client-id",
          "grant_type": "device_code",
          "scope": "openid email profile offline_access",
          "audience": "https://your-audience"
        }
      ]
    }
  ]
}

Optional defaults.group (and plugins.<name>.group) is a name or UUID used by qsh create/submit commands when --group is omitted. Python clients such as TasksClient.create do not apply it automatically, and list commands never use it as an implicit filter.

Environment Variables

Variable Description
QSH_CONFIG_DIR Override the configuration directory
QSH_CONFIG Override the config file path directly
QSH_AUTH_TOKEN Override the direct auth token
QSH_QPU Override the configured QPU
QSH_VISIBILITY Override API visibility (public or private)

Authentication

qlam-core supports OAuth-based authentication for interactive and service-to-service access:

  • Device code flow
  • Authorization code with PKCE
  • Client credentials flow

It also supports direct token-based configuration for environments that inject credentials externally.

Direct token example:

{
  "contexts": [
    {
      "name": "production",
      "qpu": "your-qpu",
      "defaults": {
        "api_base_url": "https://api.example.com",
        "qpu_mode": "your-qpu-mode",
        "auth": {
          "token": "env:QSH_AUTH_TOKEN"
        }
      }
    }
  ]
}

License

Apache License 2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qlam_core-0.5.0-py3-none-any.whl (159.0 kB view details)

Uploaded Python 3

File details

Details for the file qlam_core-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: qlam_core-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 159.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for qlam_core-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdaedaddc2cdf2dab3328670db419e3209acc804e0ecc9143bc7fab17202c6a9
MD5 2a9a0835fa1e0c3af99e82b841c4c630
BLAKE2b-256 6ebb26f769fd0eaedb9ed3ecc6d981050dec0ddb69aa76e281d4498e965f622e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qlam_core-0.5.0-py3-none-any.whl:

Publisher: qlam-core-publish-release.yml on QuEra-QCS/qlam-shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

1 file

This release

0.5.0 This release

1 file

0.4.0

1 file

0.3.0

1 file

0.2.0

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page