> ## Documentation Index
> Fetch the complete documentation index at: https://algorand-54fd52b3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat completion

> OpenAI-style chat. Pricing uses the exact request body and output-token budget. The WIF amount is fixed by the x402 challenge; automatic WIF rebates and refunds are not enabled.



## OpenAPI

````yaml POST /v1/models/{model}/chat/completions
openapi: 3.1.0
info:
  title: Moltworld API
  version: 3.0.0
  description: >-
    Live Robinhood Chain deployment: chat requests are paid per call in WIF
    using x402 exact EVM/Permit2 on `eip155:4663`. Free model discovery and
    quotes are available. WIF is an 18-decimal ERC-20. Image, speech, video,
    marketplace listings and creator payouts, automatic WIF refunds/rebates, and
    autonomous agent mandates are not enabled. A paid chat request receives `402
    Payment Required` and must be retried with a valid EVM `Payment-Signature`;
    the signed challenge is authoritative for amount and recipient.
servers:
  - url: https://moltworldd.vercel.app
    description: Live WIF API
security: []
tags:
  - name: Models
    description: Chat is the only paid modality enabled on the Robinhood WIF deployment.
  - name: Pricing
  - name: Jobs and receipts
    description: >-
      Receipt lookup and signing keys are live. Video jobs are retained for
      legacy deployments only.
  - name: Mandates
    description: >-
      WIF GET lookup verifies a pinned owner-deployed contract. Setup, funding
      and revocation require the owner wallet; legacy Algorand POST routes
      remain unavailable on WIF.
  - name: Marketplace
    description: >-
      When ROBINHOOD_MARKETPLACE_ENABLED=true, approved real APIs support WIF
      checkout, exact creator credits and wallet-authorized verified payouts.
  - name: Service
paths:
  /v1/models/{model}/chat/completions:
    post:
      tags:
        - Models
      summary: Chat completion
      description: >-
        OpenAI-style chat. Pricing uses the exact request body and output-token
        budget. The WIF amount is fixed by the x402 challenge; automatic WIF
        rebates and refunds are not enabled.
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
          description: Model slug from `GET /v1/models`, for example `gpt-4o`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatResponse'
          headers:
            Moltworld-Receipt:
              description: Signed receipt, base64url-encoded JSON. See Receipts.
              schema:
                type: string
            Moltworld-Request-Id:
              description: Request id, used to look up the receipt.
              schema:
                type: string
            Payment-Response:
              description: x402 settlement result (base64 JSON with the transaction id).
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '503':
          $ref: '#/components/responses/Unavailable'
      security:
        - x402: []
        - {}
components:
  schemas:
    ChatRequest:
      type: object
      properties:
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          minItems: 1
          maxItems: 50
        max_tokens:
          type: integer
          minimum: 1
          description: >-
            Maximum output-token budget used to calculate the exact per-request
            quote.
        temperature:
          type: number
          minimum: 0
          maximum: 2
      required:
        - messages
    ChatResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          const: chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
              message:
                $ref: '#/components/schemas/ChatMessage'
              finish_reason:
                type: string
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
        moltworld:
          $ref: '#/components/schemas/Meta'
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
        content:
          type: string
      required:
        - role
        - content
    Meta:
      type: object
      properties:
        request_id:
          type: string
        price_usd_micro:
          type: integer
          description: USD quote in micro-dollars; this is not a WIF token amount.
        payment_asset:
          type: string
          description: Payment asset symbol, WIF on the Robinhood deployment.
        payment_amount_atomic:
          type: string
          pattern: ^[0-9]+$
          description: Exact ERC-20 base-unit amount paid.
        receipt_url:
          type: string
          format: uri
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: validation_error
            message:
              type: string
          required:
            - code
            - message
      required:
        - error
  responses:
    BadRequest:
      description: Invalid request body. Nothing was charged.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PaymentRequired:
      description: >-
        Payment required. The `Payment-Required` header holds the x402 terms for
        this exact request. If you sent a payment that was refused, the body
        explains why.
      headers:
        Payment-Required:
          description: >-
            Base64 JSON: `{ x402Version, accepts: [{ scheme, network, amount,
            asset, payTo, extra }] }`
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Unknown model, listing, job or receipt.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests from this IP. See `Retry-After`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UpstreamError:
      description: >-
        The model provider failed. Chat is not charged; image, voice and video
        are refunded on-chain.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: The model or payment verification is unavailable. Nothing was charged.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    x402:
      type: apiKey
      in: header
      name: Payment-Signature
      description: >-
        x402 v2 payment payload encoded for the `Payment-Signature` header. The
        buyer signs the exact Robinhood Chain WIF/Permit2 requirement with an
        EVM wallet or compatible x402 client; do not construct it by hand.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.