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

# Completion

> Retrieve an LLM completion or queue a completion for later retrieval.



## OpenAPI

````yaml get /ai
openapi: 3.1.0
info:
  title: Massive
  description: The missing services for agent-first development.
  version: 1.0.0
servers:
  - url: https://render.joinmassive.com
security:
  - bearerAuth: []
paths:
  /ai:
    get:
      summary: Completion
      description: Retrieve an LLM completion or queue a completion for later retrieval.
      parameters:
        - name: prompt
          description: >-
            The question or instruction of up to 2,047 characters to use as a
            chat prompt; the prompt requires [form or URL
            encoding](https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding)
            (with any space character being replaced by a `+` character or `%20`
            sequence).
          schema:
            type: string
            example: best basketball shoes for 2026
          in: query
          required: true
        - name: model
          description: The AI model to chat with.
          schema:
            type: string
            enum:
              - chatgpt
              - gemini
              - perplexity
              - copilot
            default: chatgpt
            example: gemini
          in: query
        - name: device
          description: >-
            The name as returned by the [devices resource](ai/devices) of the
            device to emulate chatting on (these names are case insensitive but
            must include form- or URL-encoded spaces and punctuation marks);
            device emulation is unused by default.
          schema:
            type: string
            example: null
          in: query
        - name: country
          description: >-
            The [two-letter ISO code](https://www.iso.org/obp/ui/#search/code)
            of the country to chat from (these codes are case insensitive); a
            random country is used by default.
          schema:
            type: string
            example: null
          in: query
        - name: subdivision
          description: >-
            The alphanumeric second part (proceeding the separator) of a
            [first-level subdivision
            code](https://www.iso.org/obp/ui/#search/code) in the (prerequisite)
            country to chat from (these codes are case insensitive); a random
            subdivision is used by default.
          schema:
            type: string
            example: null
          in: query
        - name: city
          description: >-
            The [commonly spelled name](https://www.geonames.org/) of the city
            in the (prerequisite) country to chat from (these names are
            temporarily case sensitive and required to include form- or
            URL-encoded spaces and punctuation marks); a random city is used by
            default.
          schema:
            type: string
            example: null
          in: query
        - name: language (planned)
          description: >-
            The commonly spelled name or [two-letter ISO
            code](https://www.loc.gov/standards/iso639-2/php/code_list.php) of
            the language to chat in (these names and codes are case insensitive
            but required to include form- or URL-encoded spaces and punctuation
            marks); the language is unset by default.
          schema:
            type: string
            example: null
          in: query
        - name: display (planned)
          description: >-
            The commonly spelled name or [two-letter ISO
            code](https://www.loc.gov/standards/iso639-2/php/code_list.php) of
            the chat interface’s display language (these names and codes are
            case insensitive but required to include form- or URL-encoded spaces
            and punctuation marks); the display language is unset by default or
            set to the language if given.
          schema:
            type: string
            example: null
          in: query
        - name: format
          description: The format to output to.
          schema:
            type: string
            enum:
              - json
              - rendered
              - raw
            default: json
            example: rendered
          in: query
        - name: expiration
          description: >-
            The age in days of when to consider a cached completion expired,
            where `0` disables caching.
          schema:
            type: integer
            minimum: 0
            maximum: 1
            default: 1
            example: 0
          in: query
        - name: mode
          description: >-
            The synchronous or asynchronous mode of completion retrieval (see
            the [async resource](ai/completions)).
          schema:
            $ref: '#/components/schemas/Mode'
          in: query
      responses:
        '200':
          description: The AI completion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Completion'
            text/html:
              schema:
                type: string
        '202':
          description: A job identifier.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The identifier to retrieve the queued conversation with.
                    type: string
                    format: uuid
                    example: 1851dab8-4619-409f-893f-47dd3a180bc3
                required:
                  - id
        '401':
          $ref: '#/components/responses/authenticationError'
        '402':
          $ref: '#/components/responses/creditsError'
        '403':
          $ref: '#/components/responses/captchaError'
        '422':
          $ref: '#/components/responses/paramsError'
        '500':
          $ref: '#/components/responses/unknownError'
        '503':
          $ref: '#/components/responses/unavailableError'
        '504':
          $ref: '#/components/responses/timeoutError'
components:
  schemas:
    Mode:
      summary: Retrieval mode
      type: string
      enum:
        - sync
        - async
      default: sync
      example: sync
    Completion:
      summary: AI completion
      type: object
      properties:
        model:
          description: The AI model that generated the completion.
          type: string
          enum:
            - chatgpt
            - gemini
            - perplexity
            - copilot
          example: chatgpt
        query:
          description: The user prompt that the completion was generated for.
          type: string
          example: best basketball shoes for 2026
        html:
          description: The rendered HTML of the entire conversation.
          type: string
          example: <!DOCTYPE html><html lang="en-US" ...
        prompt:
          description: The rendered HTML of just the prompt portion of the conversation.
          type: string
          example: '<h4 class="sr-only select-none">You said: ...'
        completion:
          description: >-
            The rendered HTML of just the completion portion of the
            conversation.
          type: string
          example: '<h4 class="sr-only select-none">ChatGPT said: ...'
        sources:
          description: The rendered HTML of just the sources portion of the conversation.
          type: string
          example: <section aria-label="Sources" ...
        ads:
          description: The rendered HTML of just the ads portion of the conversation.
          type: string
          example: >-
            <div class="border-token-border-default mt-2 border-t py-4 text-sm"
            ...
        fanouts:
          description: >-
            The fanout queries that the model searched to generate the
            completion; only some models expose these queries.
          type: array
          items:
            type: string
          example:
            - best basketball shoes 2026
            - top rated basketball shoes 2026 reviews
            - best performance basketball shoes 2026
            - best basketball shoes for guards 2026
            - best basketball shoes for wide feet 2026
            - best outdoor basketball shoes 2026
            - most popular basketball shoes 2026
        device:
          description: The name of the targeted emulated device.
          type: string
          example: null
        country:
          description: The ISO code of the targeted country.
          type: string
          example: null
        subdivision:
          description: The partial ISO code of the targeted subdivision in the country.
          type: string
          example: null
        city:
          description: The common name of the targeted city in the country.
          type: string
          example: null
        language (planned):
          description: The common name or ISO code of the targeted language.
          type: string
          example: null
        display (planned):
          description: The common name or ISO code of the targeted display language.
          type: string
          example: null
      required:
        - model
        - query
        - html
        - prompt
        - completion
        - sources
        - ads
        - fanouts
  responses:
    authenticationError:
      description: The authorization header was missing.
      content:
        text/plain:
          schema:
            type: string
            example: Authorization header must be provided
    creditsError:
      description: No more credits are available.
      content:
        text/plain:
          schema:
            type: string
            example: >-
              Credit balance is 0; top up at
              https://dashboard.joinmassive.com/plans
    captchaError:
      description: The content was captcha’d.
      content:
        text/plain:
          schema:
            type: string
            example: Captcha was detected
    paramsError:
      description: One or more parameters were invalid.
      content:
        text/plain:
          schema:
            type: string
            example: Character counts must be no more than 255
    unknownError:
      description: An unknown error occurred.
      content:
        text/plain:
          schema:
            type: string
            example: Unknown error occurred
    unavailableError:
      description: The service is unavailable.
      content:
        text/plain:
          schema:
            type: string
            example: Service is autoscaling; please retry in 180 seconds
    timeoutError:
      description: The operation timed out.
      content:
        text/plain:
          schema:
            type: string
            example: Request(s) timed out
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````