> ## 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 Text Completions

> Create text completions on the verified Tensormesh Serverless host.

Use this page when you want the serverless text-completions endpoint instead of chat completions.

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

If you need the OpenAI-style chat shape instead, use [Serverless Chat Completions](/api-reference/serverless).


## OpenAPI

````yaml api-reference/serverless.openapi.yaml POST /v1/completions
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:
  /v1/completions:
    post:
      tags:
        - inference.openapi_Inference
      summary: Create Completion
      description: >-
        Create a text completion through the verified Serverless inference
        surface.
      operationId: create_serverless_completion_v1_completions_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextCompletionRequest'
            example:
              model: openai/gpt-oss-20b
              prompt: Reply with ok.
              max_tokens: 12
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextCompletionResponse'
            text/event-stream:
              schema:
                type: string
              example: >-
                data:
                {"id":"cmpl_1","object":"text_completion","created":1,"model":"openai/gpt-oss-20b","choices":[{"index":0,"text":"ok","finish_reason":null}]}


                data: [DONE]
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '429':
          description: Rate Limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    TextCompletionRequest:
      type: object
      title: TextCompletionRequest
      additionalProperties: true
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: Serverless model name to use.
          example: openai/gpt-oss-20b
        prompt:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
          description: Prompt text to complete.
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
    TextCompletionResponse:
      type: object
      title: TextCompletionResponse
      additionalProperties: true
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
          example: cmpl_123
        object:
          type: string
          example: text_completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/TextCompletionChoice'
        usage:
          anyOf:
            - $ref: '#/components/schemas/UsageInfo'
            - type: 'null'
    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.
    TextCompletionChoice:
      type: object
      title: TextCompletionChoice
      additionalProperties: true
      required:
        - index
        - text
      properties:
        index:
          type: integer
        text:
          type: string
        finish_reason:
          anyOf:
            - type: string
            - type: 'null'
        logprobs:
          anyOf:
            - type: object
              additionalProperties: true
            - type: 'null'
        stop_reason:
          anyOf:
            - type: string
            - type: 'null'
    UsageInfo:
      type: object
      title: UsageInfo
      additionalProperties: true
      required:
        - prompt_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
        total_tokens:
          type: integer
          title: Total Tokens
        completion_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Completion Tokens
        prompt_tokens_details:
          anyOf:
            - type: object
              additionalProperties: true
            - type: 'null'
          default: null
          title: Prompt Tokens Details
    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>

````