跳转到内容

Workspace and usage

此内容尚不支持你的语言。

Your workspace (tenant) is the boundary every other resource lives in. myTenant and apiUsageSummary take a dashboard JWT and describe the whole workspace: its plan, its allowed models and the month’s model spend against the plan’s cap. customerUsageSummary takes an API key and rolls up the usage of the sessions you started for one end customer (the clientId you passed to sdkStart), so a server-side integration can report or bill usage per customer or per ticket.

Every operation is a POST of { "query", "variables" } to https://api.wetel.dev/graphql (sandbox) with the x-huat-platform: customer header and the credential shown. New here? Start with the Quickstart and the Authentication cheat sheet. Errors are listed in Errors; Postman and OpenAPI files are on Downloads.

OperationKindCredentialWhat it does
myTenantqueryDashboard JWTRead the workspace the signed-in user belongs to.
apiUsageSummaryqueryDashboard JWTModel spend for one calendar month, the plan’s monthly cap, and a breakdown by model and operation.
customerUsageSummaryqueryAPI keyTokens, estimated cost and session count across every session of one end customer.

Read the workspace the signed-in user belongs to.

  • Kind: query
  • Credential: Dashboard JWT: Authorization: Bearer <jwt>, from login (a person or a one-off script)
  • Available in: sandbox and production
  • Returns null for a user who is not assigned to a workspace yet.
  • allowedLlmModels is the workspace’s model allowlist: null means every model in the catalog, an empty list means none.

Request

query MyWorkspace {
myTenant {
id
name
plan
isSuspended
allowedLlmModels
createdAt
}
}
variables
{}

Allowed values

  • TenantPlanEnum: DEV, ENTERPRISE, PRO

Code samples

myTenant.sh
#!/usr/bin/env bash
# myTenant: Read the workspace the signed-in user belongs to.
# Credential: Dashboard JWT (WETEL_JWT).
API_URL="${WETEL_API_URL:-https://api.wetel.dev/graphql}"
curl -sS "$API_URL" \
-H "Content-Type: application/json" \
-H "x-huat-platform: customer" \
-H "Authorization: Bearer $WETEL_JWT" \
--data-binary @- <<'JSON'
{
"query": "query MyWorkspace{myTenant{id name plan isSuspended allowedLlmModels createdAt}}",
"variables": {}
}
JSON

Responses

Success (HTTP 200)

{
"data": {
"myTenant": {
"id": 3,
"name": "Example Support Team",
"plan": "PRO",
"isSuspended": false,
"allowedLlmModels": null,
"createdAt": "2026-08-04T02:10:00.000Z"
}
}
}
UNAUTHENTICATED: Called with an API key instead of a JWT (HTTP 200)
{
"errors": [
{
"message": "Unauthorized",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"myTenant"
],
"extensions": {
"code": "UNAUTHENTICATED",
"originalError": {
"message": "Unauthorized",
"statusCode": 401
}
}
}
],
"data": {
"myTenant": null
}
}

Model spend for one calendar month, the plan’s monthly cap, and a breakdown by model and operation.

  • Kind: query
  • Credential: Dashboard JWT: Authorization: Bearer <jwt>, from login (a person or a one-off script)
  • Available in: sandbox and production
  • Covers all model usage of the workspace (sessions, workflow runs, evaluation and the LLM API). It cannot be split by API key; use customerUsageSummary for one end customer.
  • yearMonth (YYYY-MM, UTC) reads a past month; omit it for the current month. Every figure covers that month, whatever the field name says.
  • usageByBucket always has the four rows AI_CREDITS, TTS, STT and AVATAR, even when a bucket is zero.

Request

query Usage($yearMonth: String) {
apiUsageSummary(yearMonth: $yearMonth) {
yearMonth
costThisMonthUsd
monthlySpendCapUsd
creditsUsedThisMonthApprox
usageByBucket {
bucket
callCount
costUsd
creditsUsed
}
breakdown {
model
operation
count
costUsd
creditsUsed
}
}
}
variables
{
"yearMonth": "2026-09"
}

Allowed values

  • UsageBucketEnum: AI_CREDITS, AVATAR, STT, TTS

Code samples

apiUsageSummary.sh
#!/usr/bin/env bash
# apiUsageSummary: Model spend for one calendar month, the plan's monthly cap, and a breakdown by model and operation.
# Credential: Dashboard JWT (WETEL_JWT).
API_URL="${WETEL_API_URL:-https://api.wetel.dev/graphql}"
curl -sS "$API_URL" \
-H "Content-Type: application/json" \
-H "x-huat-platform: customer" \
-H "Authorization: Bearer $WETEL_JWT" \
--data-binary @- <<'JSON'
{
"query": "query Usage($yearMonth:String){apiUsageSummary(yearMonth:$yearMonth){yearMonth costThisMonthUsd monthlySpendCapUsd creditsUsedThisMonthApprox usageByBucket{bucket callCount costUsd creditsUsed}breakdown{model operation count costUsd creditsUsed}}}",
"variables": {
"yearMonth": "2026-09"
}
}
JSON

Responses

Success (HTTP 200)

{
"data": {
"apiUsageSummary": {
"yearMonth": "2026-09",
"costThisMonthUsd": 3.4182,
"monthlySpendCapUsd": 200,
"creditsUsedThisMonthApprox": 97419,
"usageByBucket": [
{
"bucket": "AI_CREDITS",
"callCount": 1840,
"costUsd": 3.2011,
"creditsUsed": 91231
},
{
"bucket": "TTS",
"callCount": 52,
"costUsd": 0.2171,
"creditsUsed": 6188
},
{
"bucket": "STT",
"callCount": 0,
"costUsd": 0,
"creditsUsed": 0
},
{
"bucket": "AVATAR",
"callCount": 0,
"costUsd": 0,
"creditsUsed": 0
}
],
"breakdown": [
{
"model": "gemini-2.5-flash",
"operation": "generate",
"count": 1712,
"costUsd": 3.1904,
"creditsUsed": 90926
},
{
"model": "gemini-embedding-001",
"operation": "embed",
"count": 128,
"costUsd": 0.0107,
"creditsUsed": 305
}
]
}
}
}
BAD_REQUEST: Month in the future or badly formatted (HTTP 200)
{
"errors": [
{
"message": "yearMonth must be a past or current month formatted 'YYYY-MM'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"apiUsageSummary"
],
"extensions": {
"code": "BAD_REQUEST",
"originalError": {
"message": "yearMonth must be a past or current month formatted 'YYYY-MM'",
"error": "Bad Request",
"statusCode": 400
}
}
}
],
"data": null
}
UNAUTHENTICATED: Called with an API key instead of a JWT (HTTP 200)
{
"errors": [
{
"message": "Unauthorized",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"apiUsageSummary"
],
"extensions": {
"code": "UNAUTHENTICATED",
"originalError": {
"message": "Unauthorized",
"statusCode": 401
}
}
}
],
"data": null
}

Tokens, estimated cost and session count across every session of one end customer.

  • Kind: query
  • Credential: API key: X-Api-Key: sk_..., kept on your server only
  • Available in: sandbox and production
  • externalCustomerId is the clientId you passed to sdkStart. Give each ticket its own clientId to read usage per ticket.
  • costUsd is an estimate (about 4 characters per token), not a billing figure; the workspace’s billed spend is in apiUsageSummary.
  • An identifier with no sessions returns zeros, not an error.

Request

query CustomerUsage($externalCustomerId: String!) {
customerUsageSummary(externalCustomerId: $externalCustomerId) {
externalCustomerId
sessionCount
tokensIn
tokensOut
costUsd
creditsUsedApprox
}
}
variables
{
"externalCustomerId": "ticket-1001"
}

Code samples

customerUsageSummary.sh
#!/usr/bin/env bash
# customerUsageSummary: Tokens, estimated cost and session count across every session of one end customer.
# Credential: API key (WETEL_API_KEY).
API_URL="${WETEL_API_URL:-https://api.wetel.dev/graphql}"
curl -sS "$API_URL" \
-H "Content-Type: application/json" \
-H "x-huat-platform: customer" \
-H "X-Api-Key: $WETEL_API_KEY" \
--data-binary @- <<'JSON'
{
"query": "query CustomerUsage($externalCustomerId:String!){customerUsageSummary(externalCustomerId:$externalCustomerId){externalCustomerId sessionCount tokensIn tokensOut costUsd creditsUsedApprox}}",
"variables": {
"externalCustomerId": "ticket-1001"
}
}
JSON

Responses

Success (HTTP 200)

{
"data": {
"customerUsageSummary": {
"externalCustomerId": "ticket-1001",
"sessionCount": 2,
"tokensIn": 1840,
"tokensOut": 612,
"costUsd": 0.0021,
"creditsUsedApprox": 60
}
}
}
UNAUTHENTICATED: Missing API key (HTTP 200)
{
"errors": [
{
"message": "Missing X-Api-Key header",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"customerUsageSummary"
],
"extensions": {
"code": "UNAUTHENTICATED",
"originalError": {
"message": "Missing X-Api-Key header",
"error": "Unauthorized",
"statusCode": 401
}
}
}
],
"data": null
}
BAD_USER_INPUT: Identifier sent as a number (HTTP 400)

Sent with variables:

{
"externalCustomerId": 1001
}
{
"errors": [
{
"message": "Variable \"$externalCustomerId\" got invalid value 1001; String cannot represent a non string value: 1001",
"locations": [
{
"line": 1,
"column": 21
}
],
"extensions": {
"code": "BAD_USER_INPUT"
}
}
]
}