Documentation

Guides and complete API reference for credits.dev. Learn core concepts, integrate with your app, and explore every endpoint.

TypeScript / JavaScript SDK

Use the official @credits-dev/sdk for type-safe access to the API. All methods support both accountId and externalId where the API allows.

npm install @credits-dev/sdk

CreditsClient mirrors the REST API. For install, examples, and all methods see the SDK docs, or the API reference for REST endpoint details.

Authentication

All API requests require an API key passed in the X-API-Key header.

Your API key

Replace {{API_KEY}} in the examples below with your own API key.

Example request

curl -X GET "https://api.credits.dev/v1/accounts/balance?accountId=acc_123" \ -H "X-API-Key: {YOUR_API_KEY}"

Quickstart

A minimal example to call the Credits API and fetch an account balance using your selected API key.

Get account balance

Fetch current balance for an account using the Credits API.

curl -X GET "https://api.credits.dev/v1/accounts/balance?accountId=acc_123" \ -H "X-API-Key: {YOUR_API_KEY}"

Typical flow

A common integration pattern is:

  1. Create an account for your end-user in Credits.
  2. Assign a plan to that account (e.g. monthly credits).
  3. Check balance before expensive operations.
  4. Reserve credits before an LLM call.
  5. Confirm or cancel the reservation based on actual usage.
  6. Grant or deduct credits for one-off adjustments.

Need every endpoint?

Browse the full API reference with all request/response schemas and code examples.

Guides

Step-by-step guides with code examples. Start with Get Started, then dive into specific topics.

API Sections

All endpoints are account-scoped where relevant (e.g. /v1/accounts/balance?accountId=...). Use the full API reference for request/response schemas and examples.