Cohere Detokenize API

The Cohere Detokenize API converts a sequence of token IDs back into their corresponding text string using the tokenizer for a specified model. It is the inverse operation of the Tokenize API and is useful for inspecting model outputs at the token level, debugging tokenization behavior, and reconstructing text from token representations.

Operations 1

POST /v1/detokenize Detokenize #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/cohere:detokenize-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

cohere-detokenize-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Cohere Detokenize API
  version: 1.0.0
servers:
- url: https://api.cohere.com
  description: production
tags:
- name: Detokenize
paths:
  /v1/detokenize:
    post:
      operationId: detokenize
      summary: Detokenize
      description: This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page.
      parameters:
      - name: X-Client-Name
        in: header
        description: 'The name of the project that is making the request.

          '
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/detokenize_Response_200'
        '400':
          description: "This error is returned when the request is not well formed. This could be because:\n  - JSON is invalid\n  - The request is missing required fields\n  - The request contains an invalid combination of fields\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestBadRequestError'
        '401':
          description: "This error indicates that the operation attempted to be performed is not allowed. This could be because:\n  - The api token is invalid\n  - The user does not have the necessary permissions\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestUnauthorizedError'
        '403':
          description: "This error indicates that the operation attempted to be performed is not allowed. This could be because:\n  - The api token is invalid\n  - The user does not have the necessary permissions\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestForbiddenError'
        '404':
          description: "This error is returned when a resource is not found. This could be because:\n  - The endpoint does not exist\n  - The resource does not exist eg model id, dataset id\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestNotFoundError'
        '422':
          description: "This error is returned when the request is not well formed. This could be because:\n  - JSON is invalid\n  - The request is missing required fields\n  - The request contains an invalid combination of fields\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestUnprocessableEntityError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestTooManyRequestsError'
        '498':
          description: 'This error is returned when a request or response contains a deny-listed token.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestInvalidTokenError'
        '499':
          description: 'This error is returned when a request is cancelled by the user.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestClientClosedRequestError'
        '500':
          description: 'This error is returned when an uncategorised internal server error occurs.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestInternalServerError'
        '501':
          description: 'This error is returned when the requested feature is not implemented.

            '
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestNotImplementedError'
        '503':
          description: "This error is returned when the service is unavailable. This could be due to:\n  - Too many users trying to access the service at the same time\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestServiceUnavailableError'
        '504':
          description: "This error is returned when a request to the server times out. This could be due to:\n  - An internal services taking too long to respond\n"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetokenizeRequestGatewayTimeoutError'
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              type: object
              properties:
                tokens:
                  type: array
                  items:
                    type: integer
                  description: The list of tokens to be detokenized.
                model:
                  type: string
                  description: An optional parameter to provide the model name. This will ensure that the detokenization is done by the tokenizer used by that model.
              required:
              - tokens
              - model
      security:
      - bearerAuth: []
      tags:
      - Detokenize
components:
  schemas:
    DetokenizeRequestServiceUnavailableError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestServiceUnavailableError
    DetokenizeRequestUnprocessableEntityError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestUnprocessableEntityError
    DetokenizeRequestForbiddenError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestForbiddenError
    detokenize_Response_200:
      type: object
      properties:
        text:
          type: string
          description: A string representing the list of tokens.
        meta:
          $ref: '#/components/schemas/ApiMeta'
      required:
      - text
      title: detokenize_Response_200
    DetokenizeRequestUnauthorizedError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestUnauthorizedError
    DetokenizeRequestNotFoundError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestNotFoundError
    DetokenizeRequestTooManyRequestsError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestTooManyRequestsError
    DetokenizeRequestNotImplementedError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestNotImplementedError
    DetokenizeRequestClientClosedRequestError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestClientClosedRequestError
    ApiMetaTokens:
      type: object
      properties:
        input_tokens:
          type: number
          format: double
          description: 'The number of tokens used as input to the model.

            '
        output_tokens:
          type: number
          format: double
          description: 'The number of tokens produced by the model.

            '
      title: ApiMetaTokens
    DetokenizeRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestBadRequestError
    ApiMetaBilledUnits:
      type: object
      properties:
        images:
          type: number
          format: double
          description: 'The number of billed images.

            '
        input_tokens:
          type: number
          format: double
          description: 'The number of billed input tokens.

            '
        image_tokens:
          type: number
          format: double
          description: 'The number of billed image tokens.

            '
        output_tokens:
          type: number
          format: double
          description: 'The number of billed output tokens.

            '
        search_units:
          type: number
          format: double
          description: 'The number of billed search units.

            '
        classifications:
          type: number
          format: double
          description: 'The number of billed classifications units.

            '
        pages:
          type: number
          format: double
          description: 'The number of billed pages parsed.

            '
      title: ApiMetaBilledUnits
    ApiMeta:
      type: object
      properties:
        api_version:
          $ref: '#/components/schemas/ApiMetaApiVersion'
        billed_units:
          $ref: '#/components/schemas/ApiMetaBilledUnits'
        tokens:
          $ref: '#/components/schemas/ApiMetaTokens'
        cached_tokens:
          type: number
          format: double
          description: 'The number of prompt tokens that hit the inference cache.

            '
        warnings:
          type: array
          items:
            type: string
      title: ApiMeta
    DetokenizeRequestGatewayTimeoutError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestGatewayTimeoutError
    ApiMetaApiVersion:
      type: object
      properties:
        version:
          type: string
        is_deprecated:
          type: boolean
        is_experimental:
          type: boolean
      required:
      - version
      title: ApiMetaApiVersion
    DetokenizeRequestInternalServerError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestInternalServerError
    DetokenizeRequestInvalidTokenError:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
      title: DetokenizeRequestInvalidTokenError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer