LANGUAGE MODELS FOR AGENTS

LLM x402 integration guide

Discover models and prices for free. Authorize a spending limit for each request, receive the response, then settle by actual token usage.

A clear limit. An actual-usage bill.

The quote uses this request’s input estimate and maximum output budget. The final bill uses the actual input, cached input and output tokens at the quoted rates, subject to the per-call minimum charge.

Signing sets the maximum payment for this call. Funds move when the settlement transaction executes after generation. With streaming, text arrives progressively and settlement follows final usage; non-streaming returns the complete response after settlement.

Catalog prices are final billable rates; do not apply another discount. New quotes use current rates; signed quotes keep their quoted rates.

See live model prices →

1. Discover models

curl https://api.koinelix.com/v1/models

Select the model id and one of its supported_protocols endpoints. Prices include input, cached_input, output and applicable cache_write / long_context rates. Pricing is USD per million tokens, settled at the same numeric amount in USDC.

2. Quote this request

For Chat Completions, set the output limit with max_completion_tokens. Omitting it uses the service default. max_tokens and max_output_tokens are rejected with HTTP 400.

curl -i https://api.koinelix.com/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: <unique-request-id>' \
  -d '{
  "model": "<model-id>",
  "messages": [
    {
      "role": "user",
      "content": "Explain your capabilities in two sentences."
    }
  ],
  "max_completion_tokens": 256,
  "stream": false
}'

# HTTP 402 + PAYMENT-REQUIRED: sign the quoted upto limit, then resend.
# Use an id from GET /v1/models.

3. Authorize and call

Download reference client v1.0.0 · EIP-1193 · no dependencies →

Decode PAYMENT-REQUIRED. Verify the x402 version, upto scheme, network, asset, trusted payee, expiry and spending limit. Use Permit2 for the required token allowance, then sign this call’s authorization. Resend the identical body and path with PAYMENT-SIGNATURE and the same Idempotency-Key and authentication identity.

Permit2 allowance and the per-call signed limit are distinct. The signed limit bounds this call; actual settlement follows the final bill.

4. Receive and reconcile

Retain the response on the client. For streaming or interrupted responses, query the original call with its original payment proof. Use bounded backoff while processing; resolve unknown payment status through recovery before starting another payment for the same task.

POST <original endpoint>
Content-Type: application/json
PAYMENT-SIGNATURE: <original proof>
Idempotency-Key: <original key>
X-Koinelix-Recover-Only: true

<identical original request body>

Read execution, usage, payment, delivery, amount and tx_hash from the recovery result. payment=settled confirms the platform has verified settlement. A changed request requires a new quote; an expired unexecuted quote can be replaced after checking the original call.

Give your agent a starting point

Read https://koinelix.com/agents.md and discover models at https://api.koinelix.com/v1/models.
Choose a model and supported protocol for my task.
Catalog pricing already contains final billable rates; do not apply another discount. Billing uses actual usage at the quoted rates, subject to minimum_charge_usdc. New quotes use current rates; signed quotes keep their quoted rates.
For Chat Completions, use only max_completion_tokens for the output limit; max_tokens and max_output_tokens are rejected with HTTP 400.
Use x402 v2 upto / Permit2. Check the quoted network, asset, trusted payee and my spending budget before signing.
Preserve the exact request body, path, identity, idempotency key and payment proof.
Receive the response and settle by actual token usage.
For pending or unknown outcomes, recover the original call with X-Koinelix-Recover-Only: true and the original authorization; query with bounded backoff.
Confirm payment=settled and the transaction receipt before treating payment as complete.

Discovery resources:/agents.md · /llms.txt · /openapi.json · /.well-known/x402