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

# Count Response Input Tokens

> Input-token count for a Responses request, without running inference.

Bills nothing and writes no usage row. The body is OpenAI's
``{"object": "response.input_tokens", "input_tokens": N}``;
``X-Mesh-Token-Count-Source`` says whether the provider counted it (``exact``)
or the gateway estimated it (``estimate``).



## OpenAPI

````yaml /api/openapi.json post /v1/responses/input_tokens
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/responses/input_tokens:
    post:
      tags:
        - Responses
      summary: Count Response Input Tokens
      description: >-
        Input-token count for a Responses request, without running inference.


        Bills nothing and writes no usage row. The body is OpenAI's

        ``{"object": "response.input_tokens", "input_tokens": N}``;

        ``X-Mesh-Token-Count-Source`` says whether the provider counted it
        (``exact``)

        or the gateway estimated it (``estimate``).
      operationId: count_response_input_tokens
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
              - 2026-09
              - 2026-11
            default: 2026-08
          example: 2026-11
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    ResponsesRequest:
      properties:
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        input:
          anyOf:
            - type: string
            - items: {}
              type: array
          title: Input
        service_tier:
          anyOf:
            - type: string
              enum:
                - auto
                - default
                - flex
            - type: 'null'
          title: Service Tier
        template:
          anyOf:
            - type: string
            - type: 'null'
          title: Template
        template_version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Template Version
        variables:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Variables
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
        router_version:
          anyOf:
            - type: string
            - type: 'null'
          title: Router Version
        provider:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider
          description: >-
            Pin this request to one upstream provider, e.g. `bedrock`. The
            request is served by that provider or refused — never routed
            elsewhere. See `GET /v1/providers/pinnable` for the slugs this
            deployment accepts.
        stream:
          type: boolean
          title: Stream
          default: false
        max_output_tokens:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Output Tokens
        temperature:
          anyOf:
            - type: number
              maximum: 2
              minimum: 0
            - type: 'null'
          title: Temperature
        top_p:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Top P
        seed:
          anyOf:
            - type: integer
            - type: 'null'
          title: Seed
        reasoning:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Reasoning
        tools:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ResponsesFunctionTool'
                  - $ref: '#/components/schemas/BuiltinTool'
              type: array
            - type: 'null'
          title: Tools
        tool_choice:
          anyOf:
            - type: string
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Tool Choice
        response_format:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Response Format
        plugins:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Plugins
        safety_identifier:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Safety Identifier
          description: >-
            A stable, anonymised identifier for the end user making this
            request, recorded on the usage row and available as a filter and a
            group-by dimension in the usage API. Supersedes the deprecated
            `user` field. Use an opaque id, not an email address or a name.
        user:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: User
          deprecated: true
        previous_response_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Response Id
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
        thinking:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Thinking
        caching:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Caching
        store:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Store
        background:
          type: boolean
          title: Background
          default: false
        include:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Include
        expire_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expire At
        max_tool_calls:
          anyOf:
            - type: integer
              maximum: 10
              minimum: 1
            - type: 'null'
          title: Max Tool Calls
        context_management:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Context Management
        text:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Text
        timeout:
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: 'null'
          title: Timeout
        tags:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Tags
          description: >-
            Your own labels for this request, echoed back on the usage row and
            available as a filter and a group-by dimension in the usage API.
            String keys to string values. Never put personal or sensitive data
            here — tags are stored with the usage record and are not redacted.
          examples:
            - env: prod
              feature: summariser
      type: object
      required:
        - input
      title: ResponsesRequest
      example:
        input: Explain quantum computing in one sentence.
        model: openai/gpt-5-pro
        stream: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ResponsesFunctionTool:
      properties:
        type:
          type: string
          const: function
          title: Type
          default: function
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        parameters:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Parameters
        strict:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Strict
      type: object
      required:
        - name
      title: ResponsesFunctionTool
      description: >-
        Custom function tool in the Responses API flat format.


        The Responses API uses a flat structure (name/description/parameters at
        top

        level) unlike Chat Completions which nests them under a "function" key:

          Responses API:   {"type": "function", "name": "add", "parameters": {...}}
          Chat Completions: {"type": "function", "function": {"name": "add", ...}}
    BuiltinTool:
      properties:
        type:
          type: string
          enum:
            - image_generation
            - web_search_preview
            - web_search_preview_2025_03_11
            - file_search
            - computer_use_preview
            - code_interpreter
          title: Type
      additionalProperties: true
      type: object
      required:
        - type
      title: BuiltinTool
      description: >-
        Represents an OpenAI built-in tool (non-function), e.g. {"type":
        "image_generation"}.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) or, for the admin-keys endpoints, a
        dashboard session token — sent as `Authorization: Bearer <token>`.

````

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