# Payfer > Payfer adds usage-based billing to AI apps. Charge users for every AI request with micropayments, down to fractions of a cent. Set up in under a minute. Install it with `npm install payfer`. The browser client (`payfer`) asks a person to connect and approve a monthly allowance for your application; your server (`payfer/server`) verifies the connection once, then charges it with `charge()`, or with `meter()` when the price is only known after the work runs. Register an application in the [dashboard](https://payfer.me/dashboard) for test keys: they talk to test.payfer.me (Stripe test mode, Tempo testnet), and live keys to payfer.me. Every docs page below is also markdown at its own URL with `.md` added. ## Getting started - [Introduction](https://payfer.me/docs.md): Payfer lets you pay for apps by how much you use them, instead of by the month. - [Quickstart](https://payfer.me/docs/quickstart.md): This guide connects a user, verifies the connection on your server and makes a charge. - [Test and live mode](https://payfer.me/docs/test-and-live.md): Payfer runs two separate environments. ## Concepts - [Allowances](https://payfer.me/docs/allowances.md): An allowance is the most your application can charge one person in a month. - [Metering](https://payfer.me/docs/metering.md): Some work can only be priced after it runs: an AI reply priced by its tokens, or a video priced by its length. - [Idempotency](https://payfer.me/docs/idempotency.md): Every call that moves money takes an idempotencyKey. - [Payment identities](https://payfer.me/docs/identity.md): Your application never learns who someone is on Payfer. - [Pricing and fees](https://payfer.me/docs/pricing.md): Payfer’s fee comes out of the price you charge and is split out on-chain at settlement. ## Client SDK - [createClient()](https://payfer.me/docs/create-client.md): Create Payfer’s browser client with your publishable key: its options, their defaults and the client it returns. - [payfer.connect()](https://payfer.me/docs/connect.md): Asks someone to connect their Payfer account to your application. - [payfer.manage()](https://payfer.me/docs/manage.md): Opens Payfer’s page where the connected person can raise, lower or revoke the allowance they gave your application, and resolves with the allowance once they’re done. - [payfer.getAllowance()](https://payfer.me/docs/get-allowance.md): Reads the connected person’s allowance in the browser, for showing what’s left this month. ## Server SDK - [payfer.verifyConnection()](https://payfer.me/docs/verify-connection.md): Confirms on your server that a connection came from Payfer’s approval page for your application, and returns the ID to store. - [payfer.charge()](https://payfer.me/docs/charge.md): Charges a connected user from your server, within what’s left of their allowance this month. - [payfer.meter()](https://payfer.me/docs/meter.md): Charges for work you can only price after it runs. - [payfer.refund()](https://payfer.me/docs/refund.md): Refunds all or part of a payment. ## Examples - [Charge users for Claude API usage](https://payfer.me/docs/claude-api-billing.md): Bill your users for Claude API calls by the token or by the reply. TypeScript examples with the Anthropic SDK and Payfer’s meter() and charge(). - [Usage-based billing for OpenAI API apps](https://payfer.me/docs/openai-api-billing.md): Add usage-based billing to an OpenAI API app: charge users per token or per request. TypeScript examples with the OpenAI SDK and Payfer. - [Pay-per-image billing for fal.ai apps](https://payfer.me/docs/fal-ai-billing.md): Charge users for fal.ai image generation per megapixel or per image. TypeScript examples with the fal client and Payfer’s meter() and charge(). - [Charge users for Higgsfield AI images and video](https://payfer.me/docs/higgsfield-api-billing.md): Charge users for Higgsfield AI image and video generation: cost plus markup per image, or a price per second of video. TypeScript examples with Payfer. ## Reference - [Errors](https://payfer.me/docs/errors.md): Every failure is a PayferError with a stable code, a readable message and the HTTP status. - [Rate limits](https://payfer.me/docs/rate-limits.md): Payfer limits how fast some calls can be made, to keep sign-in codes from being abused and to protect people’s balances. ## Optional - [Every docs page in one file](https://payfer.me/llms-full.txt) - [Terms of Service](https://payfer.me/terms) - [Privacy Policy](https://payfer.me/privacy)