Provider Pricing API

Hvoy 1.0/1.1 compatible pricing feed for NewAPI, Sub2API, and custom relay sites.

XTokenChecker first fetches the Hvoy-compatible pricing API submitted by the site owner. If the field is empty, we try /api/provider/pricing under the site domain, then fall back to price-page parsing.

Publishing this structured endpoint is strongly recommended. It is more stable than scraping an HTML pricing page and maps naturally to NewAPI / Sub2API model groups, channel groups, and final user-facing prices.

Endpoint

GET /api/provider/pricing
Content-Type: application/json; charset=utf-8

Return final CNY prices. XTokenChecker matches each channel by the stable compound key model_name + group_name.

Minimal Response

{
  "schema_version": "1.1",
  "success": true,
  "message": "",
  "data": {
    "currency": "CNY",
    "price_unit": "per_1m_tokens",
    "site_name": "example",
    "site_domain": "example.com",
    "updated_at": "2026-07-15T00:00:00Z",
    "models": [
      {
        "model_name": "claude-sonnet-4-6",
        "group_name": "cc",
        "input_price": 7.5,
        "output_price": 37.5,
        "cache_input_price": 0.75,
        "cache_create_price": 9.375,
        "cache_create_price_1h": 15,
        "enabled": true,
        "note": ""
      },
      {
        "model_name": "gpt-image-2",
        "group_name": "image",
        "price_unit": "per_call",
        "unit_price": 0.2,
        "enabled": true,
        "note": "per call"
      }
    ]
  }
}

Field Rules

FieldRule
schema_versionRequired. Use 1.1; 1.0 is still accepted.
successRequired. Whether the feed was generated successfully.
data.currencyRequired. Must be CNY.
data.price_unitRequired. Supports per_1m_tokens and per_call.
data.updated_atRequired. ISO 8601 datetime with timezone; UTC is recommended.
data.modelsRequired. One item per model and group combination.
model_nameRequired. Stable model ID, such as gpt-5.4 or claude-sonnet-4-6.
group_nameRequired. Stable channel or group ID, such as official, cc, or vip. Do not rename it frequently after publishing.
input_priceRequired for token pricing. CNY / 1M input tokens.
output_priceRecommended for token pricing. CNY / 1M output tokens. Use null if unknown.
cache_input_priceOptional cache-read price.
cache_create_priceOptional cache-write price; for Claude this usually maps to 5-minute cache writes.
cache_create_price_1hOptional Claude 1-hour cache-write price; usually null for other providers.
unit_priceRequired when price_unit is per_call. CNY / call.
enabledOptional, defaults to true. Return false for known temporarily unavailable combinations.
noteOptional display or debugging note; not used in calculations.

Prices must be JSON numbers, not numeric strings. Missing model_name + group_name combinations are treated as unmatched, not as explicitly disabled.

Optional Signature

If you do not want the pricing feed to be fully public, enable the Hvoy-compatible signature.

X-Hvoy-Ts: 1747886400
X-Hvoy-Sign: 9f0f4d7f6a5a648242cc0d2e4c2cfc0d4d79cf50615a5c1304f8cbea57c478c4

Signature formula:

sign = hex(HMAC-SHA256(auth_secret, X-Hvoy-Ts))

Accept timestamps within a 60-second window. The public tester uses this fixed test secret:

hvoy_provider_pricing_test_secret_v1_20260522

NewAPI Sites

Many relay sites are based on NewAPI or a fork. Add a read-only public endpoint in your own backend and convert internal pricing settings to the Provider Pricing API response.

Recommended sources:

  • Model availability: NewAPI model list, channel configuration, or public /v1/models.
  • Channel groups: channel group, model ratio group, user group price, or custom group mapped to stable group_name.
  • Token pricing: convert model ratio, completion ratio, and group ratio into final CNY / 1M token prices.
  • Image or per-call models: return price_unit: "per_call" and unit_price.

Avoid requiring the crawler to log into your admin dashboard. Admin tables and field names vary across forks; a JSON feed is much more reliable.

Sub2API Sites

Sub2API sites usually have model mappings, groups, and subscription or package multipliers. Export the final effective user price as Provider Pricing API.

Suggested flow:

  1. Load currently sellable models and groups.
  2. Normalize display names or aliases into stable model_name IDs.
  3. Convert package, model, and channel ratios into final CNY prices.
  4. Keep temporarily unavailable combinations in the feed with enabled: false.

If your site only has an HTML pricing page, XTokenChecker can try rule-based parsing, but structured JSON is the preferred path.

Self-Test

  1. Deploy GET /api/provider/pricing.
  2. Open the fetch tester.
  3. Enter a full HTTPS URL, for example https://example.com/api/provider/pricing.
  4. If signature validation is enabled, first test with the public test secret, then submit the production secret in the site-owner dashboard.
  5. The response should include at least one models[] entry that matches the models you submitted.

Common Mistakes

  • Returning numeric strings such as "7.5" instead of numbers.
  • Returning updated_at without timezone.
  • Using display names instead of stable model IDs.
  • Frequently renaming group_name, which breaks price history.
  • Mixing token pricing and per-call pricing without setting price_unit.
  • Returning official provider list prices instead of the final user-facing relay-site prices.