@quantum-hub/qhub-service
v1.7.0
Published
SDK to interact with managed services on the Kipu Quantum Hub.
Readme
Kipu Quantum Hub Service SDK
Installation
The package can be installed using npm:
npm install @quantum-hub/qhub-serviceUsage
const serviceEndpoint = "..."
const accessKeyId = "..."
const secretAccessKey = "..."
// Create a new client instance
const client = new HubServiceClient(serviceEndpoint, accessKeyId, secretAccessKey)
// List all service executions
const serviceExecutions = await client.api().getServiceExecutions()
// Start a new service execution
let serviceExecution = await client.api().startExecution({n_coin_tosses: 2, shots: 100}, {timeoutInSeconds: 60})
// Check the status of the service execution
serviceExecution = await client.api().getStatus({id: serviceExecution.id!})
// Wait for the service execution to finish
const finalStates = ["SUCCEEDED", "CANCELLED", "FAILED"]
while (!finalStates.includes(serviceExecution.status!)) {
serviceExecution = await client.api().getStatus({id: serviceExecution.id!})
}
// Get the result of the service execution
const result = await client.api().getResult({id: serviceExecution.id!})
// Get the logs of the service execution
const logs = await client.api().getLogs({id: serviceExecution.id!})
// Cancel the service execution if it is still pending or running
await client.api().cancelExecution({id: serviceExecution.id!})Data Pool Access Grants
Service executions that read from or write to data pools require a short-lived JWT grant. The client can acquire these grants automatically by calling the Hub Platform API on your behalf.
Pass a HubPlatformClient (constructed with a personal access token as the apiKey parameter) to the HubServiceClient, then supply one or more DataPoolGrant entries via the run() options:
import {HubServiceClient, HubPlatformClient} from '@quantum-hub/qhub-service'
import {DataPoolPermission, type DataPoolGrant} from '@quantum-hub/qhub-service/datapool'
const platformClient = new HubPlatformClient({
apiKey: '...',
organizationId: '...',
})
const client = new HubServiceClient(serviceEndpoint, accessKeyId, secretAccessKey, undefined, platformClient)
const grants: DataPoolGrant[] = [
{
name: 'input_data',
datapoolId: 'dp-abc123',
applicationId: 'app-xyz789',
permission: DataPoolPermission.VIEW,
},
{
name: 'output_data',
datapoolId: 'dp-def456',
applicationId: 'app-xyz789',
permission: DataPoolPermission.MODIFY,
},
]
const serviceExecution = await client.run({shots: 100}, undefined, undefined, {grants})For each grant, the client injects a DataPoolReference (with the issued JWT) into the request under the supplied name.
Grants are cached per (datapoolId, applicationId, permission) until shortly before the JWT expires.
License
Apache-2.0 | Copyright 2026-now Kipu Quantum GmbH
