DINGJIAI
DINGJIAI
Quick start in 5 minutesWhat is DINGJIAI?

Online use

Online chatOpens in a new windowImage generationOpens in a new window

Popular Agents

Codex SetupClaude Code SetupOne-Click Setup

API Reference

API overview
ResponsesChat CompletionsAnthropic MessagesGemini API
Codex Search capabilityImages GenerationsImages EditsAnthropic Count Tokens
Error codes

Billing

Model pricingTroubleshooting calls
API families and API entriesAdditional entries and operations

Anthropic Count Tokens

The Count Tokens operation in the Anthropic Messages API.

The Count Tokens operation in the Anthropic Messages API

Count Tokens is a specific operation in the Anthropic Messages API. It uses the same API-family authentication and model-product selection. It does not create a model-call charge settlement, but it still checks the user key, balance, model, and upstream availability.

Paths

PurposeMethod and path
Count tokensPOST /v1/messages/count_tokens
Compatible pathPOST /anthropic/v1/messages/count_tokens

Request example

POST /v1/messages/count_tokens
curl https://dingjiai.com/v1/messages/count_tokens \
  -H "x-api-key: YOUR_USER_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Copy a model name from the Anthropic model list",
    "messages": [
      { "role": "user", "content": "Estimate the token count for this input" }
    ]
  }'

Actual boundaries

Prop

Type

Request-body handling

When forwarding Count Tokens, the gateway removes fields that are needed only for generation requests, such as stream, temperature, top_p, top_k, stop, and stop_sequences.

It cannot bypass balance checks

Count Tokens is not billed, but it is not fully anonymous or an offline calculation. The call still fails when the user key is invalid, the balance is insufficient, the model is not open for the entry, or no upstream is available.

Last updated on

Images EditsUsage and billing

On this page

PathsRequest exampleActual boundariesRequest-body handling