> ## 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 batch to sign for grant mode

> The one batch a wallet signs to use the router without a deposit: a compute grant (the router opens ComputeChannel sessions from your wallet within the caps) and a fee grant (the router collects its fee, 5% of the escrow with a minimum of `min_router_fee`, from your wallet to `fee_address`, within the fee caps). `call_data` is the SCALE-encoded `utility.batchAll` over `calls`; sign and submit it, then call `POST /v1/grants/sync`. Either grant can be revoked at any time. With a key, for the key's wallet; without one, pass `address`. Read-only: nothing is reserved. The delegates shown are the ones this wallet already granted, else the lowest router delegates with a free slot on chain; if two wallets grant a last slot at once, the chain refuses the second grant (`TooManySessions`) and asking again shows the next delegate. A wallet with an active compute grant and no fee grant gets a batch with only the fee call, and keeps its compute grant. A wallet replacing grants gets `revokeSession` calls first (`renewal` is true). A wallet may create 3 grants per hour (`limits.max_rotations_per_hour`); a batch that would exceed it fails on chain with `flopSessionKeys.SessionRotationLimited`. A router without fee collection answers the older compute-only shape (no `fee_delegate`, `fee_address`, `fee_call` or `calls`; `call_data` is one `createSession` or a revoke-and-create `batchAll`) and takes its fee from the prepaid balance.



## OpenAPI

````yaml /openapi.json get /v1/grants/params
openapi: 3.1.0
info:
  title: floprouter Unified API
  version: 1.0.0
  description: >-
    The floprouter Unified 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 batch (`GET /v1/grants/params` returns
    the exact call data): a `flopSessionKeys.createSession` grant to the
    router's compute delegate (ComputeChannel only) and one to a fee delegate
    (Balances only, used for the router's own fee). The router then opens
    channels within the caps and collects its fee from the wallet to the
    router's fee address. No deposit is needed. The escrow is paid on chain from
    the wallet. A wallet that prefers to prepay can deposit instead; the fee
    then 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**: optional in grant mode, required in credit mode. 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 the larger of `fee_percent` of the session's
    escrow or `min_router_fee` (0.012 FLOP on testnet; it pays the chain fee of
    opening the channel), charged only when the channel settles paid (in grant
    mode it accrues, then is collected from the wallet through the fee grant;
    the `fees` object on GET /v1/balance and GET /v1/grants shows accrued,
    collected and owed). Both are in GET /v1/models, GET /v1/balance and
    /health. **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: Router fees, 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 batch to sign for grant mode
      description: >-
        The one batch a wallet signs to use the router without a deposit: a
        compute grant (the router opens ComputeChannel sessions from your wallet
        within the caps) and a fee grant (the router collects its fee, 5% of the
        escrow with a minimum of `min_router_fee`, from your wallet to
        `fee_address`, within the fee caps). `call_data` is the SCALE-encoded
        `utility.batchAll` over `calls`; sign and submit it, then call `POST
        /v1/grants/sync`. Either grant can be revoked at any time. With a key,
        for the key's wallet; without one, pass `address`. Read-only: nothing is
        reserved. The delegates shown are the ones this wallet already granted,
        else the lowest router delegates with a free slot on chain; if two
        wallets grant a last slot at once, the chain refuses the second grant
        (`TooManySessions`) and asking again shows the next delegate. A wallet
        with an active compute grant and no fee grant gets a batch with only the
        fee call, and keeps its compute grant. A wallet replacing grants gets
        `revokeSession` calls first (`renewal` is true). A wallet may create 3
        grants per hour (`limits.max_rotations_per_hour`); a batch that would
        exceed it fails on chain with `flopSessionKeys.SessionRotationLimited`.
        A router without fee collection answers the older compute-only shape (no
        `fee_delegate`, `fee_address`, `fee_call` or `calls`; `call_data` is one
        `createSession` or a revoke-and-create `batchAll`) and takes its fee
        from the prepaid balance.
      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: 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty
                delegate: 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw
                fee_delegate: 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y
                fee_address: 5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy
                network: testnet
                genesis_hash: >-
                  0x918abd58fb16306b30ef3886514cfaebffecb4de43e82b6f8ec4795c43cfd800
                rpc: wss://testnet.flop.network/
                rpc_urls:
                  - wss://testnet.flop.network/
                explorer_url: https://testnet.flopscan.io
                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:
                    - 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw
                    - '5000000000000000000'
                    - '500000000000000000'
                    - '2000000000000000000'
                    - 864000
                    - - ComputeChannel
                  args_names:
                    - delegate
                    - spending_cap
                    - per_tx_limit
                    - daily_cap
                    - duration_blocks
                    - allowed_pallets
                fee_call:
                  pallet: flopSessionKeys
                  method: createSession
                  args:
                    - 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y
                    - '700000000000000000000'
                    - '73000000000000000'
                    - '280000000000000000000'
                    - 864000
                    - - Balances
                  args_names:
                    - delegate
                    - spending_cap
                    - per_tx_limit
                    - daily_cap
                    - duration_blocks
                    - allowed_pallets
                calls:
                  - pallet: flopSessionKeys
                    method: createSession
                    args:
                      - 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw
                      - '5000000000000000000'
                      - '500000000000000000'
                      - '2000000000000000000'
                      - 864000
                      - - ComputeChannel
                    args_names:
                      - delegate
                      - spending_cap
                      - per_tx_limit
                      - daily_cap
                      - duration_blocks
                      - allowed_pallets
                  - pallet: flopSessionKeys
                    method: createSession
                    args:
                      - 5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y
                      - '700000000000000000000'
                      - '73000000000000000'
                      - '280000000000000000000'
                      - 864000
                      - - Balances
                    args_names:
                      - delegate
                      - spending_cap
                      - per_tx_limit
                      - daily_cap
                      - duration_blocks
                      - allowed_pallets
                renewal: false
                renewal_call: null
                call_data: 0x<scale-encoded-utility-batch-all-call>
                notes:
                  - >-
                    Sign this one batch with your wallet and call POST
                    /v1/grants/sync.
                  - >-
                    The compute grant lets the router open and fund
                    ComputeChannel sessions from your wallet.
                  - >-
                    The router uses the fee grant only to pay its own fees to
                    the fee address, up to the fee cap. You can revoke it at any
                    time or deposit instead.
                  - >-
                    When adding a fee grant to an existing compute grant, the
                    batch keeps the compute grant. For renewal, the batch
                    revokes the grants being replaced.
        '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 compute delegate to name in the compute grant. Kept per
            wallet.
        network:
          type: string
        genesis_hash:
          type: string
        rpc:
          type: string
          description: >-
            Public RPC address to connect to when signing this call (the first
            of rpc_urls).
        rpc_urls:
          type: array
          items:
            type: string
          description: Every public RPC address of the chain.
        explorer_url:
          type: string
          description: Base URL of the chain explorer.
        limits:
          type: object
          description: >-
            Chain constants of the flopSessionKeys pallet.
            `max_rotations_per_hour`: grants a wallet may create per hour (3);
            more fails with `flopSessionKeys.SessionRotationLimited`.
            `block_time_ms`: milliseconds per block.
          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 compute caps (decimal FLOP) and duration. The fee grant's
            caps are in `fee_call.args`.
        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
          description: >-
            The compute `createSession` call (kept for clients that build it
            themselves; sign `call_data` instead).
        call_data:
          type: string
          description: >-
            SCALE-encoded call (0x hex): sign and submit it as an extrinsic from
            the owner wallet. In grant fee-collection mode it is always
            `utility.batchAll` over `calls`, even for one call.
        notes:
          type: array
          items:
            type: string
        renewal:
          type: boolean
          description: >-
            true when the batch replaces existing grants (it starts with
            `revokeSession` calls, because the chain refuses a second grant to a
            delegate while one is active).
        renewal_call:
          type:
            - object
            - 'null'
          description: >-
            When renewal is true: {pallet: utility, method: batchAll, calls}
            (the same `calls`). Otherwise null.
          properties:
            pallet:
              type: string
            method:
              type: string
            calls:
              type: array
              items:
                type: object
        fee_delegate:
          type: string
          description: >-
            Router fee delegate to name in the fee grant (only in grant
            fee-collection mode). Kept per wallet.
        fee_address:
          type: string
          description: >-
            Where the router's fee is paid to: the fee grant lets the router
            transfer its fee from your wallet to this address and nowhere else.
        fee_call:
          type: object
          description: >-
            The fee `createSession` call: allowed_pallets is ["Balances"]; the
            caps are raw units sized for the router's fee (5% of the escrow, at
            least `min_router_fee`) over the grant's life. Present in grant
            fee-collection mode.
          properties:
            pallet:
              const: flopSessionKeys
            method:
              const: createSession
            args:
              type: array
              description: Raw units for amounts.
            args_names:
              type: array
              items:
                type: string
        calls:
          type: array
          items:
            $ref: '#/components/schemas/GrantCall'
          description: >-
            The batch body in order: `revokeSession` for each grant being
            replaced, then the compute `createSession` (omitted when the wallet
            keeps its current compute grant, so a wallet with a compute-only
            grant gets just the fee call), then the fee `createSession`. Present
            in grant fee-collection mode.
    GrantCall:
      type: object
      description: >-
        One call of the grant batch. Amounts in `args` are raw units (18
        decimals).
      properties:
        pallet:
          type: string
          examples:
            - flopSessionKeys
        method:
          enum:
            - createSession
            - revokeSession
        args:
          type: array
          description: >-
            createSession: delegate, spending_cap, per_tx_limit, daily_cap,
            duration_blocks, allowed_pallets. revokeSession: delegate.
        args_names:
          type: array
          items:
            type: string
          description: Names of args (createSession only).
    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
                    - fees_owed
                    - grant_expired
                    - all_attempts_failed
                    - no_provider_supports_parameters
                    - model_not_found
                    - rate_limited
                    - withdrawal_in_progress
                    - invalid_tools
                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.