> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uncensoredgpt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Count message tokens

> Count the tokens of a request in the Anthropic Messages format, without generating a response.

Accepts the same body as `POST /v1/messages` and returns the input token count.



## OpenAPI

````yaml api-reference/openapi.json post /v1/messages/count_tokens
openapi: 3.1.0
info:
  title: UncensoredGPT API
  description: >-
    Every UncensoredGPT model through a single, OpenAI-compatible endpoint.
    Create an API key in the [UncensoredGPT
    Console](https://console.uncensoredgpt.ai), point your code at this base
    URL, and pay per token.
  version: 1.0.0
servers:
  - url: https://api.uncensoredgpt.ai
security: []
tags:
  - name: Chat
    description: >-
      Create a chat response for a list of messages. Supports streaming, tool
      calling, and vision models.
  - name: Completions
    description: Generate a text continuation for a prompt (legacy completions format).
  - name: Embeddings
    description: >-
      Turn text into a vector representation for search, retrieval, and
      clustering.
  - name: Responses
    description: >-
      The Responses API: stateful generations with tool use, plus retrieval and
      deletion of past responses.
  - name: Models
    description: List and inspect the models available to your API key.
  - name: Moderations
    description: Classify text against usage policies.
  - name: Batches
    description: >-
      Submit batches of requests for asynchronous processing within 24 hours, at
      lower cost.
  - name: Files
    description: Upload and manage files, for example Batch input files.
  - name: Images
    description: Generate or edit images from a text prompt.
  - name: Messages
    description: >-
      Call models using the Anthropic Messages format, for code that already
      targets the Anthropic API.
paths:
  /v1/messages/count_tokens:
    post:
      tags:
        - Messages
      summary: Count Tokens
      description: >-
        Count the tokens of a request in the Anthropic Messages format, without
        generating a response.


        Accepts the same body as `POST /v1/messages` and returns the input token
        count.
      operationId: count_tokens_v1_messages_count_tokens_post
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: Successful Response
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An UncensoredGPT API key created in the [UncensoredGPT
        Console](https://console.uncensoredgpt.ai).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.