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

# Send a message and start a generation

> Starts an async generation job.

<Note>
  This returns immediately with `status: "generating"` — it does not return the finished video. Poll `GET /fragments/{fragmentId}` until `animationUrl` is non-null.
</Note>


## OpenAPI

````yaml /openapi.json post /projects/{projectId}/messages
openapi: 3.1.0
info:
  title: Mathify API
  version: 1.0.0
  description: >-
    Public REST API for generating and retrieving Mathify math animations. See
    app/api/v1/README.md in the source repo for the underlying implementation.
servers:
  - url: https://mathify.dev/api/v1
security: []
tags:
  - name: Projects
  - name: Messages
  - name: Fragments
  - name: Music
  - name: Evals
paths:
  /projects/{projectId}/messages:
    post:
      tags:
        - Projects
        - Messages
      summary: Send a message and start a generation
      description: Starts an async generation job.
      operationId: createMessage
      parameters:
        - in: path
          name: projectId
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageBody'
      responses:
        '202':
          description: Generation started
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateMessageResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: >-
            A valid API key is required, or the account has no credits balance
            (see https://mathify.dev/pricing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Generation is in maintenance mode
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - apiKeyHeader: []
        - bearerAuth: []
components:
  schemas:
    CreateMessageBody:
      type: object
      properties:
        content:
          example: Animate the Pythagorean theorem
          type: string
          minLength: 1
          maxLength: 100000
        model:
          $ref: '#/components/schemas/Model'
          description: >-
            Optional preference for the model or provider family used by the
            main generation agent — the one doing the primary reasoning and code
            generation. Other steps in the pipeline (e.g. scene planning, visual
            validation) may already use a different model regardless of this
            setting. Even for the main agent, it's a preference rather than a
            guarantee: depending on the difficulty or type of your prompt,
            Mathify may route generation to a different model or provider family
            if we judge it a better fit for that specific task. Omit this field
            to let Mathify choose automatically.
        forceWatermark:
          description: >-
            Opt into a watermarked render even if the caller's account has the
            no-watermark benefit.
          type: boolean
      required:
        - content
    CreateMessageResponse:
      type: object
      properties:
        messageId:
          type: string
        fragmentId:
          type: string
        status:
          type: string
          const: generating
        totalSteps:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
      required:
        - messageId
        - fragmentId
        - status
        - totalSteps
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          example: Project not found
          type: string
      required:
        - error
      additionalProperties: false
    Model:
      example: anthropic
      type: string
      enum:
        - openai
        - anthropic
        - qwen
        - gemini
        - grok
        - gptoss
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Mathify API key (`mk_live_<64 hex chars>`), generated at
        /settings/api-keys.
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Same token as apiKeyHeader, passed as `Authorization: Bearer <token>`.'

````