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
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:
- Create an account for your end-user in Credits.
- Assign a plan to that account (e.g. monthly credits).
- Check balance before expensive operations.
- Reserve credits before an LLM call.
- Confirm or cancel the reservation based on actual usage.
- Grant or deduct credits for one-off adjustments.
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.