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.
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.
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.
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.
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:
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.
1. Prepare connection details
| Information | Requirement |
|---|---|
| Service URL | For example, https://spi.example.com/adapter; reachable from the QwenWork Biz service network |
| SPI token | A dedicated Bearer token issued by the enterprise service, separate from model and Open Platform keys |
| Organization ID | QwenWork organization UUID, bound to the correct ledger tenant in the enterprise service |
| Test user | An external user ID already bound in IAM and recognized by the enterprise system |
| Data and period | A complete readable statistics date, billing cycle and test quota |
2. Implement common requests and responses
Request headers
| Header | Required | Receiver behavior |
|---|---|---|
| Authorization: Bearer <SPI_TOKEN> | Yes | Validate the credential and its authorization for the requested organization |
| X-QwenWork-Organization-Id | Yes | QwenWork organization UUID; do not treat it directly as an enterprise ledger ID |
| X-QwenWork-Request-Id | Yes | Log for diagnostics; not a user identity or idempotency key |
| Accept: application/json | Yes | Return JSON |
| Content-Type: application/json | With a JSON request body | Parse as UTF-8 JSON |
| Idempotency-Key | When setting a member limit | Correlates retries of the same write; see Quota writes |
| traceparent | Optional | Distributed tracing |
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
- Sign in as an administrator with SPI management permission and open Open Platform → Extensions → BYOK limits and usage.
- 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.
- Click Test connectivity. The request comes from the Biz service and can run even when the extension is disabled or the draft is unsaved.
- Complete the integration tests below, then have the administrator save and enable the entire extension.
5. Complete business integration tests in order
| Order | Action | Acceptance criteria |
|---|---|---|
| 1 | Validate the organization, test user and credentials | Reject invalid tokens and unauthorized organizations; user identity matches the IAM binding |
| 2 | Query quota rules, current period and organization quota | Valid period, matching organization, correct quota units and types |
| 3 | Set a 500-credit member limit in the test organization | Set member limit receives "5000000"; the complete acknowledgement matches the request |
| 4 | Generate test model consumption | Meter using the same external identity; changing the limit does not reset usage |
| 5 | Complete a new statistics date | Before publishing ds, all five periods of organization and member usage are complete and totals agree |
| 6 | Complete QwenWork statistics refresh and query member daily trends | Correct date on the page; consistent organization, member and daily-trend measurements |