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

# The grant to sign for grant mode

> Delegate address, chain limits, suggested caps, and the exact `createSession` call (arguments and SCALE call data) for the wallet to sign. With a key, for the key's wallet; without one, pass `address`. Read-only: nothing is reserved. The delegate shown is the one this wallet already granted, else the lowest router delegate with a free slot on chain; if two wallets grant its last slot at once, the chain refuses the second grant (`TooManySessions`) and asking again shows the next delegate. The router records a grant when `POST /v1/grants/sync` (or a chat request) finds it on chain. While a grant to the delegate is active the chain refuses a second one: then `renewal` is true and `call_data` is `utility.batchAll[revokeSession(delegate), createSession(...)]`, one signature that replaces the grant.



## OpenAPI

````yaml /openapi.json get /v1/grants/params
openapi: 3.1.0
info:
  title: floprouter API
  version: 1.0.0
  description: >-
    The floprouter API routes chat requests to FLOP Network miners and settles
    each one on chain. One request format covers every model: chat completions
    with `provider` preferences and a `models` fallback list, model objects, a
    generation lookup, one error format and one streaming format. FLOP's own
    concepts have their own routes: miners, sessions on payment channels,
    session-key grants, the prepaid FLOP balance, settlement and on-chain
    attribution. **Base paths**: `/api/v1/...` and `/v1/...` serve the same
    routes; this document lists them under `/v1`. **Payer modes** (per key,
    overridable per request with `flop.payer`):

    - `grant`: the caller's wallet is the on-chain payer (channel `agent`) of
    every session. The wallet signs one `flopSessionKeys.createSession` grant to
    the router's delegate (`GET /v1/grants/params` returns the exact call data);
    the router then opens channels within the grant's caps. The escrow is paid
    on chain from the wallet; only the router fee comes from the prepaid
    balance. - `credit`: the router's wallet pays the session on chain; escrow
    and router fee are taken from the prepaid balance. **Balance**: fund it with
    a plain FLOP transfer from your wallet to `deposit_address` (`GET
    /v1/balance`); it is credited once the block is finalized. Withdraw with
    `POST /v1/balance/withdraw` (to the owning wallet only). Every balance can
    be recomputed from finalized chain state: billed sessions carry an encrypted
    ledger tag on chain, and the service checks its ledger against the chain
    continuously. The router fee is `fee_percent` of the session's escrow,
    charged only when the channel settles paid. **One request shape for every
    model**: the router chooses the chat envelope, template version, token
    limits and parameter support per model from what the chain and the miner's
    signed info say. Parameters a model does not support (see its
    `supported_parameters`) are ignored and named in
    `X-Floprouter-Ignored-Parameters`; `provider.require_parameters` refuses
    them instead. **Cost** (`usage.cost`, in FLOP): the escrow (prompt plus
    `max_tokens` at the model's price, paid in full on a cooperative settle)
    plus the router fee. Final once the session settles; a refunded session
    costs 0. **Timing**: a proxy in front closes responses idle for 100 s.
    Non-streaming calls answer within about 85 s: with the verified reply, or
    with HTTP 202 and the generation id to poll (`GET /v1/generation?id=`).
    Streams send `: FLOPROUTER PROCESSING` comments at least every 15 s.
    **Streaming**: chat completion chunks ending in a usage chunk (one choice
    repeating `finish_reason`) and `data: [DONE]`. Text is forwarded as the
    miner streams it and is provisional until the turn's signed receipt is
    verified at the end of the turn. A mid-stream error is one chunk with a
    top-level `error` and `finish_reason: "error"`. **Errors**: `{"error":
    {"code": <HTTP status>, "message", "metadata": {"reason", ...}}}`; 429 and
    503 carry `Retry-After`. **Miner score**: computed by the router from
    on-chain facts only (settlement history, volume, stake, slashing record,
    calibration state). The raw facts are returned beside it. **Client
    libraries**: the chat endpoint uses the widely used chat completions request
    and response format, so any client library for that format works with
    `baseURL` set to `https://api.floprouter.com/api/v1` and a floprouter key.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.floprouter.com
    description: API used by this site
security: []
tags:
  - name: Inference
    description: Chat completions and sessions.
  - name: Models
    description: >-
      Models, with their prices, limits and supported parameters, and the miners
      serving each.
  - name: Auth
    description: Wallet-signed API keys.
  - name: Grants
    description: 'Grant payer mode: the wallet stays the on-chain payer.'
  - name: Balance
    description: Prepaid balance and ledger.
  - name: Directory
    description: No key needed.
  - name: Service
    description: Health and this document.
paths:
  /v1/grants/params:
    get:
      tags:
        - Grants
      summary: The grant to sign for grant mode
      description: >-
        Delegate address, chain limits, suggested caps, and the exact
        `createSession` call (arguments and SCALE call data) for the wallet to
        sign. With a key, for the key's wallet; without one, pass `address`.
        Read-only: nothing is reserved. The delegate shown is the one this
        wallet already granted, else the lowest router delegate with a free slot
        on chain; if two wallets grant its last slot at once, the chain refuses
        the second grant (`TooManySessions`) and asking again shows the next
        delegate. The router records a grant when `POST /v1/grants/sync` (or a
        chat request) finds it on chain. While a grant to the delegate is active
        the chain refuses a second one: then `renewal` is true and `call_data`
        is `utility.batchAll[revokeSession(delegate), createSession(...)]`, one
        signature that replaces the grant.
      operationId: getGrantParams
      parameters:
        - name: address
          in: query
          schema:
            type: string
          description: Wallet that will sign (when no key is sent).
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GrantParams'
              example:
                object: grant_params
                owner: 5F29vNoqgKpXxgUyz4DXifLnfAPQUQCq3ZQXGVjVbxp7sWBS
                delegate: 5EfBc9f69NuPUV9zue18zeURWriF64Q9d7MN7h626D3pm2r7
                network: devnet
                genesis_hash: >-
                  0x99c172c095340ace980631f9123544c6bebd4839f3437e463533422d8be2d631
                limits:
                  max_session_duration_blocks: 864000
                  max_sessions_per_delegate: 10
                  max_sessions_per_owner: 10
                  max_rotations_per_hour: 3
                  epoch_blocks: 86400
                  circuit_breaker:
                    period_blocks: 60
                    max_txs: 100
                    max_spend: '250'
                  block_time_ms: 1000
                  allowed_pallets:
                    - ComputeChannel
                amounts:
                  spending_cap: '5'
                  per_tx_limit: '0.5'
                  daily_cap: '2'
                  duration_blocks: 864000
                  duration_hours: 240
                  max_escrow_per_session: '0.5'
                call:
                  pallet: flopSessionKeys
                  method: createSession
                  args:
                    - 5EfBc9f69NuPUV9zue18zeURWriF64Q9d7MN7h626D3pm2r7
                    - '5000000000000000000'
                    - '500000000000000000'
                    - '2000000000000000000'
                    - 864000
                    - - ComputeChannel
                  args_names:
                    - delegate
                    - spending_cap
                    - per_tx_limit
                    - daily_cap
                    - duration_blocks
                    - allowed_pallets
                call_data: >-
                  0x5e0072c4397216285801092592606cb1e02ed8f54f45c7a3508e565e13ed6bdee57a0000f4448291634500000000000000000000b2d3595bf00600000000000000000000c84e676dc11b0000000000000000002f0d000438436f6d707574654368616e6e656c
                notes:
                  - >-
                    Sign and submit this one extrinsic with the wallet that
                    should pay for its sessions, then call POST /v1/grants/sync.
                  - >-
                    The grant lets the delegate open ComputeChannel channels for
                    you, within the caps. It cannot transfer funds. Revoke it at
                    any time with flopSessionKeys.revokeSession(delegate).
                  - >-
                    Every grant expires after at most 864000 blocks; sign a new
                    one before then (GET /v1/grants shows the expiry). Granting
                    the same delegate again replaces the old record.
                  - >-
                    Escrow is paid from your wallet on chain. The router fee is
                    taken from your prepaid balance (GET /v1/balance), and only
                    for sessions that settle paid. The delegate's transaction
                    fees are paid by the router.
        '400':
          $ref: '#/components/responses/E400'
        '401':
          $ref: '#/components/responses/E401'
        '429':
          $ref: '#/components/responses/E429'
      security:
        - bearer: []
        - {}
components:
  schemas:
    GrantParams:
      type: object
      properties:
        object:
          const: grant_params
        owner:
          type: string
        delegate:
          type: string
          description: Router delegate key to name in the grant. Kept per wallet.
        network:
          type: string
        genesis_hash:
          type: string
        limits:
          type: object
          description: Chain constants of the flopSessionKeys pallet.
          properties:
            max_session_duration_blocks:
              type: integer
            max_sessions_per_delegate:
              type: integer
            max_sessions_per_owner:
              type: integer
            max_rotations_per_hour:
              type: integer
            epoch_blocks:
              type: integer
            circuit_breaker:
              type: object
            block_time_ms:
              type: integer
            allowed_pallets:
              type: array
              items:
                type: string
        amounts:
          type: object
          description: Suggested caps (decimal FLOP) and duration.
        call:
          type: object
          properties:
            pallet:
              const: flopSessionKeys
            method:
              const: createSession
            args:
              type: array
              description: Raw units for amounts.
            args_names:
              type: array
              items:
                type: string
        call_data:
          type: string
          description: >-
            SCALE-encoded call (0x hex): sign and submit it as an extrinsic from
            the owner wallet.
        notes:
          type: array
          items:
            type: string
        renewal:
          type: boolean
          description: >-
            true when the wallet holds an active grant to this delegate:
            call_data then revokes and recreates it in one batchAll (described
            in renewal_call); call stays the createSession inside it.
        renewal_call:
          type:
            - object
            - 'null'
          description: >-
            When renewal is true: {pallet: utility, method: batchAll, calls:
            [revokeSession(delegate), createSession(...)]}. Otherwise null.
          properties:
            pallet:
              type: string
            method:
              type: string
            calls:
              type: array
              items:
                type: object
    Error:
      type: object
      description: >-
        `code` is the HTTP status; `metadata.reason` is floprouter's specific
        reason.
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: integer
              examples:
                - 400
                - 401
                - 402
                - 403
                - 404
                - 408
                - 409
                - 413
                - 429
                - 502
                - 503
            message:
              type: string
            metadata:
              type: object
              properties:
                reason:
                  type: string
                  examples:
                    - insufficient_balance
                    - grant_expired
                    - all_attempts_failed
                    - no_provider_supports_parameters
                    - tools_not_supported
                    - model_not_found
                    - rate_limited
                    - withdrawal_in_progress
                session_id:
                  type: string
              additionalProperties: true
  responses:
    E400:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 400
              message: >-
                each message needs a role of system, developer, user or
                assistant (tool messages are not supported)
              metadata:
                reason: invalid_message
    E401:
      description: Missing or invalid key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 401
              message: >-
                a wallet API key is required (Authorization: Bearer fr_...); see
                POST /v1/auth/challenge
              metadata:
                reason: unauthorized
    E429:
      description: Rate limit, concurrency cap, grant daily cap or demo budget
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: 429
              message: 'chat requests for this key: limit 20 per minute; retry in 41 s'
              metadata:
                reason: rate_limited
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds to wait.
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: Wallet API key `fr_...` from `POST /v1/auth/keys`.

````

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