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

# Serverless Tokenize

> Tokenize text with the verified Tensormesh Serverless host.

Use this page when you want token ids for a specific serverless model.

* Auth: `Authorization: Bearer <API_KEY>`
* Host: `https://serverless.tensormesh.ai`
* Model: pass a serverless model name in the JSON request body


## OpenAPI

````yaml api-reference/serverless.openapi.yaml POST /tokenize
openapi: 3.1.0
info:
  title: Tensormesh Serverless Inference API
  version: 1.0.0
  description: |-
    OpenAI-compatible chat completions endpoint plus verified vLLM-compatible
    `/v1/models`, `/v1/completions`, `/v1/responses`, `/tokenize`,
    `/detokenize`, `/health`, and `/version` endpoints exposed through
    Tensormesh Serverless.

    Authentication: `Authorization: Bearer <API_KEY>` for `POST`
    inference requests. The public serverless host also serves
    `GET /v1/models`, `GET /health`, and `GET /version` without auth.

    If you have Control Plane access for the same Tensormesh environment,
    discover published serverless models with
    `tm billing pricing serverless list` and use the returned
    `pricing[].model` value in requests. If you are targeting a different
    serverless host override, or you only have inference credentials, get the
    model name from your Tensormesh environment before sending requests.
servers:
  - url: https://serverless.tensormesh.ai
    description: Tensormesh Serverless
security:
  - BearerAuth: []
tags:
  - name: inference.openapi_Inference
    x-displayName: Inference
paths:
  /tokenize:
    post:
      tags:
        - inference.openapi_Inference
      summary: Tokenize Text
      description: Tokenize text with the verified Serverless inference host.
      operationId: create_serverless_tokenize_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TokenizeRequest'
            example:
              model: openai/gpt-oss-20b
              prompt: Hello!
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizeResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    TokenizeRequest:
      type: object
      title: TokenizeRequest
      additionalProperties: true
      required:
        - model
      anyOf:
        - required:
            - prompt
        - required:
            - messages
      properties:
        model:
          type: string
          description: Serverless model name to use.
          example: openai/gpt-oss-20b
        prompt:
          type: string
          example: Hello!
        messages:
          type: array
          items:
            type: object
    TokenizeResponse:
      type: object
      title: TokenizeResponse
      additionalProperties: true
      properties:
        count:
          type: integer
        max_model_len:
          type: integer
        tokens:
          type: array
          items:
            type: integer
        token_strs:
          type: array
          items:
            type: string
    OpenAIErrorResponse:
      type: object
      title: OpenAIErrorResponse
      additionalProperties: true
      properties:
        error:
          anyOf:
            - $ref: '#/components/schemas/OpenAIError'
            - type: string
            - type: 'null'
          description: Error message (string) or structured error object.
    OpenAIError:
      type: object
      title: OpenAIError
      additionalProperties: true
      properties:
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
        code:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Code
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        Bearer authentication using your serverless API key. Format: Bearer
        <API_KEY>

````