Skip to main content

Quick start

Validate one read-only request first, then test all eight endpoints and the actual business flow.

Validate one read-only request first, then test all eight endpoints and the actual business flow. Run the following commands from a terminal that can reach the enterprise service. They simulate QwenWork calls; they do not send requests to the QwenWork console.

1. Prepare connection details

InformationRequirement
Service URLFor example, https://spi.example.com/adapter; reachable from the QwenWork Biz service network
SPI tokenA dedicated Bearer token issued by the enterprise service, separate from model and Open Platform keys
Organization IDQwenWork organization UUID, bound to the correct ledger tenant in the enterprise service
Test userAn external user ID already bound in IAM and recognized by the enterprise system
Data and periodA complete readable statistics date, billing cycle and test quota
Configure the service URL prefix; QwenWork appends /spi/v1/.... With https://spi.example.com/adapter, Get latest statistics date calls https://spi.example.com/adapter/spi/v1/usage/meta. Do not append /spi/v1 yourself. HTTP/HTTPS, domain names, IPv4, bracketed IPv6, custom ports and path prefixes are supported. URLs must not contain credentials, query strings, fragments, whitespace or invalid ports. HTTP sends tokens in plaintext and is only for trusted private networks. HTTPS validates system-trusted certificates and the domain/IP; validation cannot be bypassed. The service must respond directly without redirects.

2. Implement common requests and responses

Request headers

HeaderRequiredReceiver behavior
Authorization: Bearer <SPI_TOKEN>YesValidate the credential and its authorization for the requested organization
X-QwenWork-Organization-IdYesQwenWork organization UUID; do not treat it directly as an enterprise ledger ID
X-QwenWork-Request-IdYesLog for diagnostics; not a user identity or idempotency key
Accept: application/jsonYesReturn JSON
Content-Type: application/jsonWith a JSON request bodyParse as UTF-8 JSON
Idempotency-KeyWhen setting a member limitCorrelates retries of the same write; see Quota writes
traceparentOptionalDistributed tracing
Do not trust the organization header alone. Validate the token's authorization for that organization. Member IDs are external identities; do not substitute a name, email address or internal UUID.

Response conventions

Success is always HTTP 200 with the specified JSON object, without an additional data wrapper. Do not return 204 or HTML. Empty collections are []; nullable unknown values are null, not fabricated zeros. Use a non-200 status for failure; see Error handling. Quota and usage SPI calls default to a 10-second timeout, a 1 MiB successful-response limit and a 32 KiB error-body limit. The SDK does not automatically retry GET requests; background tasks retain their own retry budgets. The manual connectivity check is a separate 5-second request.

3. Send the first read-only request

Inject the actual token securely into SPI_TOKEN for your terminal session. Do not write it into documentation or commit it to the repository. Set the other test parameters:
Call Get latest statistics date:
Expected HTTP 200:
This date indicates that all five periods, the organization overview and every member page are complete and readable. Return {"ds":null} if no complete data exists. The example date is illustrative; do not hardcode it in production.

4. Configure the console

  1. Sign in as an administrator with SPI management permission and open Open Platform → Extensions → BYOK limits and usage.
  2. Enter the service URL and token. A token is required when enabling the integration for the first time. Saved tokens are never displayed; leaving the field blank reuses the existing token, including after an address change.
  3. Click Test connectivity. The request comes from the Biz service and can run even when the extension is disabled or the draft is unsaved.
  4. Complete the integration tests below, then have the administrator save and enable the entire extension.
The check only verifies that Get latest statistics date returns HTTP 200. It does not validate the JSON or call the other seven endpoints. A successful check does not save configuration or start statistics synchronization; saving and enabling do not require a successful check.

5. Complete business integration tests in order

OrderActionAcceptance criteria
1Validate the organization, test user and credentialsReject invalid tokens and unauthorized organizations; user identity matches the IAM binding
2Query quota rules, current period and organization quotaValid period, matching organization, correct quota units and types
3Set a 500-credit member limit in the test organizationSet member limit receives "5000000"; the complete acknowledgement matches the request
4Generate test model consumptionMeter using the same external identity; changing the limit does not reset usage
5Complete a new statistics dateBefore publishing ds, all five periods of organization and member usage are complete and totals agree
6Complete QwenWork statistics refresh and query member daily trendsCorrect date on the page; consistent organization, member and daily-trend measurements
Disabling the extension pauses the associated quota dispatch. Existing background tasks synchronize automatically after it is enabled. Published statistics refresh by date; disabling or changing the URL does not overwrite snapshots for the same date. See Validation and troubleshooting for failure diagnosis.