V1 API Common Conventions

Authentication, billing, shared objects, and error response formats for the V1 Open API

This document describes authentication, billing, shared objects, and error response formats for the V1 Open API (/v1/*).

Scope: Public /v1 Relay endpoints — 12 in total.


Common conventions

Base URL

https://www.guid.ai

Endpoints are mounted at the domain root, e.g. POST https://www.guid.ai/v1/chat/completions.

Authentication

All public /v1 endpoints use Bearer Token:

Authorization: Bearer sk-xxxxxxxxxxxxxxxx
RuleDescription
Token validationValidates API Key, user status, and balance/quota
IP allowlistIf the token has an IP allowlist, the request source is checked
Channel overrideAdmins may append -{channelId} after the Key (e.g. sk-xxx-6); regular users cannot
Auth failureReturns HTTP 401 / 403

Exception: GET /v1/videos/{task_id}/content supports both an admin console Session and a Bearer Token.

Content-Type

ScenarioContent-Type
JSON requestapplication/json
Image edit / video create with filesmultipart/form-data
TTS responseaudio/mpeg, audio/wav, etc. (depends on response_format)
Chat / Responses streamingtext/event-stream (SSE)

Billing

  • The gateway selects an upstream channel automatically based on model in the request body (or path parameter)
  • Supports token-based, per-request, per-second, and other billing strategies
  • Different API Keys may see different model lists

Shared response objects

usage (token billing)

Common in text endpoint responses (Chat / Completions / Responses):

FieldTypeDescription
prompt_tokensintegerInput token count (Completions / Chat)
completion_tokensintegerOutput token count (Completions / Chat)
total_tokensintegerTotal token count
input_tokensintegerInput token count (Responses)
output_tokensintegerOutput token count (Responses)
prompt_cache_hit_tokensintegerCached input tokens (some models)
prompt_tokens_detailsobjectInput token breakdown
prompt_tokens_details.cached_tokensintegerCached token count
prompt_tokens_details.text_tokensintegerText token count
prompt_tokens_details.audio_tokensintegerAudio token count
prompt_tokens_details.image_tokensintegerImage token count
completion_tokens_detailsobjectOutput token breakdown
completion_tokens_details.reasoning_tokensintegerReasoning token count
completion_tokens_details.text_tokensintegerText token count

usage (per-request billing, images)

FieldTypeDescription
quota_typeintegerBilling type identifier
quotaintegerQuota consumed by this request
request_countintegerRequest count, usually 1
prompt_tokensintegerInput tokens (usually 0 for image endpoints)
completion_tokensintegerOutput tokens (usually 0 for image endpoints)
total_tokensintegerTotal tokens (usually 0 for image endpoints)

Error responses

Standard errors (text / images / audio / video content)

HTTP status codes: 400, 401, 403, 404, 429, 500, etc.

{
  "error": {
    "message": "Invalid request",
    "type": "invalid_request_error",
    "code": "invalid_request",
    "param": "model"
  }
}
FieldTypeDescription
error.messagestringHuman-readable error description
error.typestringError type, e.g. invalid_request_error, insufficient_quota
error.codestringError code, e.g. invalid_request, model_not_found
error.paramstringRequest field that caused the error (if any)
error.metadataobjectExtended metadata (returned by some upstreams)

Task errors (video task create / query failure)

HTTP status codes: 400, 429, etc.

{
  "code": "invalid_request",
  "message": "model is required"
}
FieldTypeDescription
codestringError code; commonly invalid_request
messagestringError description

On HTTP 429, message is: 当前分组上游负载已饱和,请稍后再试 (upstream load for the current group is saturated; try again later).

Gateway extended errors (model list, voice list, etc.)

HTTP status codes: 200 (business failure) or 400.

{
  "success": false,
  "message": "get user group failed"
}
FieldTypeDescription
successbooleanWhether the call succeeded; false means failure
messagestringError description

Token balance & usage details

In addition to Relay endpoints, V1 provides two query endpoints. Authentication matches other /v1 APIs: Authorization: Bearer sk-xxxxxxxx. Each request can only query data for the current Bearer token.

MethodPathDescription
GET/v1/token/balanceQuery token balance (⚡)
GET/v1/token/consumeQuery current API Key consume records (paginated)

Authentication: Use Bearer Token. The token is resolved by the auth middleware — do not pass a key query parameter.


GET /v1/token/balance

Query the balance of the current Bearer token, returning the remaining and used quota in ⚡.

Auth: Authorization: Bearer sk-xxxxxxxx

Request parameters

No query parameters.

Request example (curl)

curl https://www.guid.ai/v1/token/balance \
  -H "Authorization: Bearer sk-xxxxx"

Response body

HTTP 200

{
  "success": true,
  "message": "",
  "data": {
    "id": 1,
    "name": "API Token",
    "remain_quota_usd": 0.2,
    "used_quota_usd": 0.1,
    "unlimited_quota": false
  }
}

Response fields

FieldTypeDescription
successbooleanWhether the call succeeded
messagestringStatus message
data.idintegerToken ID
data.namestringToken name
data.remain_quota_usdnumberRemaining quota (⚡). Always 0 for unlimited tokens
data.used_quota_usdnumberUsed quota (⚡)
data.unlimited_quotabooleanWhether the token has unlimited quota

GET /v1/token/consume

Paginated query of consume records for the current Bearer API Key (type = 2 only). Filtered by token_id — does not return the owning user's top-up/income wallet logs, and does not aggregate consume logs from the user's other keys.

Auth: Authorization: Bearer sk-xxxxxxxx

Request parameters

ParameterTypeRequiredDescription
pageintegerNoPage number, default 1
page_sizeintegerNoItems per page, default 10, max 100
time_rangestringNoQuick time-range filter; only all, today, yesterday, week, month allowed. Takes precedence over start_timestamp / end_timestamp
start_timestampintegerNoStart timestamp (used when time_range is empty)
end_timestampintegerNoEnd timestamp (used when time_range is empty)
model_namestringNoModel name filter
request_idstringNoRequest ID filter
upstream_request_idstringNoUpstream request ID filter

Request example (curl)

curl "https://www.guid.ai/v1/token/consume?page=1&page_size=10&time_range=today" \
  -H "Authorization: Bearer sk-xxxxx"

Response body

HTTP 200

{
  "success": true,
  "message": "",
  "code": 0,
  "data": {
    "page": 1,
    "page_size": 10,
    "total": 100,
    "items": [
      {
        "id": 1,
        "created_at": 1700000000,
        "type": 2,
        "type_name": "消费",
        "content": "模型推理",
        "token_name": "default",
        "model_name": "gpt-3.5-turbo",
        "app_name": "",
        "usage_name": "gpt-3.5-turbo",
        "quota_usd": 0.002,
        "quota_type": 2
      }
    ]
  }
}

Response fields

FieldTypeDescription
successbooleanWhether the call succeeded
messagestringStatus message
codeintegerStatus code; 0 success, -1 business failure
data.pageintegerCurrent page
data.page_sizeintegerPage size
data.totalintegerTotal records
data.itemsarrayConsume record list
data.items[].idintegerLog ID
data.items[].created_atintegerCreated-at timestamp
data.items[].typeintegerLog type; always 2 (consume)
data.items[].type_namestringLog type name; always consume
data.items[].contentstringLog content
data.items[].token_namestringToken name
data.items[].model_namestringModel name
data.items[].app_namestringApp name (if from Apps)
data.items[].usage_namestringModel name or Apps application name
data.items[].quota_usdnumberConsumed quota (⚡)
data.items[].quota_typeintegerQuota change type (0 none, 1 increase, 2 decrease)