# Decentramind for agents

OpenAI-compatible API over OpenRouter and Chutes (Bittensor subnet 64), paid from a balance a Solana wallet activates on-chain.

- Base URL: https://decentramind.app/api/v1
- Auth: `Authorization: Bearer sk-dm-<epoch>-<key>`
- Catalog: GET https://decentramind.app/api/v1/models (no key). OpenRouter ids as-is; Bittensor subnet 64 models as `chutes/<id>`.

## Get a key

Sign this exact message with the wallet (Ed25519, UTF-8 bytes):

    Decentramind API key · decentramind.app · solana:mainnet · program <program> · epoch 0

The message names this site, network and program; a signature of any other message is not a key here. The key is `sk-dm-0-` followed by base64url (no padding) of the 32-byte public key and then the 64-byte signature. Signing a higher epoch rotates the key once it is used.

## Fund the balance on Solana mainnet

Program (not deployed yet), order book (not deployed yet), credit mint (Token-2022) (not deployed yet), USDC (not deployed yet). Amounts have 6 decimals; one credit pays for one dollar of usage.

1. Read the book account and walk its asks cheapest first, FIFO within a price: each fill costs ceil(credits × price / 10000) USDC atoms; their sum is `payment_in`.
2. Send `buy_and_activate(payment_in, min_credit_out, beneficiary, max_fills)`. It fills from the cheapest asks and burns the credits into `beneficiary`'s API balance in one transaction, or fails without moving anything.
3. `POST https://decentramind.app/api/v1/activations` with `{"signature":"…"}` credits it at once.

A wallet that already holds credits can send `activate(amount)` instead, then step 3.

## Call models

    curl https://decentramind.app/api/v1/chat/completions \
      -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
      -d '{"model":"anthropic/claude-sonnet-5","messages":[{"role":"user","content":"Hello"}]}'

- Without max_tokens, output is capped at what the balance can pay for; max_tokens and max_completion_tokens are both sent as the cap.
- Only standard chat fields are forwarded (models, route, plugins, prediction, web_search_options, user and the like are dropped). n must be 1, tools must be functions, content parts must be text or image_url.
- Up to 60 requests a minute per wallet (429 rate_limit).
- Every response has X-Decentramind-Balance (USD) and X-Decentramind-Request-Id.
- Balance: GET https://decentramind.app/api/v1/key, or GET https://decentramind.app/api/v1/auth/key in OpenRouter's shape.
- 402 insufficient_balance: lower max_tokens or activate more.

## MCP

Streamable HTTP at https://decentramind.app/api/mcp with the same key. Tools: models, ask, balance.

    claude mcp add --transport http decentramind https://decentramind.app/api/mcp --header "Authorization: Bearer $KEY"
