PermuteDocs
Go to Permute

AI credits · aiCreditsGet

Get a resource's AI credits

Returns this UTC month's AI credits used by a Business Action's or operation's llm() calls, and its monthly limit. Pass a Business Action (actn_) or operation (oper_) ID. Operation test runs count only toward the organization. Without a custom limit, the default of 2,000 credits applies. The limit applies on every plan, including plans with unlimited AI credits, and the calls also count toward the organization's plan limit. Requires view access to the resource.

GET/v1/ai-credits/{resourceId}
betaauthenticatedworkspace

When to use

Check how many AI credits a Business Action's or operation's llm() calls used this month, and its limit.

For agents

Pass a Business Action (actn_) or operation (oper_) ID; requires view access to the resource. At the limit, llm() calls fail with "This Business Action reached its monthly limit of N AI credits." or "This operation reached its monthly limit of N AI credits.", where N is the current limit, and an operation run fails. The limit applies even on plans with unlimited AI credits. The calls also count toward the organization's plan limit, which this endpoint does not show. aiCallsEnabled is false when the published action lacks llm: true, or when neither the operation's published nor its latest saved code allows AI calls (a changed Allow AI calls setting applies once the code is saved). Operation test runs count only toward the organization. canEditLimit says whether the caller may change the limit; maxSettableLimit is the highest value it may set (0 without the permission). Organization admins see every resource in the web app under organization settings, AI credits.

Example

typescript
import { PermuteClient } from '@permute/sdk';

const orgClient = new PermuteClient({
  apiKey: process.env.PERMUTE_API_KEY!,
});

const client = orgClient.withWorkspace(process.env.PERMUTE_WORKSPACE_ID!);

const result = await client.aiCredits.get('oper_abcdefghijklmnopqrstuvwx');

Response

json
{
  "data": {
    "resourceId": "oper_abcdefghijklmnopqrstuvwx",
    "period": "2026-11",
    "usedCredits": 120,
    "monthlyLimit": 2000,
    "isDefaultLimit": true,
    "aiCallsEnabled": true,
    "canEditLimit": true,
    "maxSettableLimit": 5000
  }
}