> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowra.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage and credits

> Track Flowra credit usage via the SDK — balance, ledger, chat SSE usage events, and workflow execution usage.

Flowra bills in **credits**. Approximate platform economics:

* `10_000 credits ≈ $1` of vendor cost (before plan markup on AI)
* AI usage applies a small markup on top of upstream model cost

Product UI: [Account and pricing](/product/account-and-pricing). The `usage` namespace is on both SDKs.

## Balance and ledger

<CodeGroup>
  ```ts theme={null}
  import { Flowra } from '@flowra/sdk';

  const flowra = new Flowra({ apiKey: process.env.FLOWRA_API_KEY! });

  const balance = await flowra.usage.balance();
  console.log(balance);

  const ledger = await flowra.usage.list({
    threadId,
    from: '2026-08-01T00:00:00.000Z',
  });

  const run = await flowra.usage.forExecution(executionId);
  ```

  ```python theme={null}
  from flowra import Flowra

  flowra = Flowra(api_key="YOUR_API_KEY")

  balance = flowra.usage.balance()
  print(balance)

  ledger = flowra.usage.list(
      threadId=thread_id,
      **{"from": "2026-08-01T00:00:00.000Z"},
  )

  run = flowra.usage.for_execution(execution_id)
  ```
</CodeGroup>

Attribution fields on ledger rows can include `workflowId`, `executionId`, `eUID`, and related execution log ids.

## After each chat turn (SSE)

`POST /api/v1/graphify/threads/{thread_id}/runs/stream` emits a final SSE event:

```
event: usage
data: {
  "runCredits": 142,
  "threadCreditsTotal": 890,
  "balanceRemaining": 48200,
  "executionId": "...",
  "breakdown": { "ai_model": 120, "tool": 22, ... }
}
```

Parse it with the SDK helpers — full walkthrough: [Chat streaming](/guides/sdk-chat-streaming).

```python theme={null}
for event in flowra.chat.stream(thread_id, body, as_events=True):
    if event["event"] == "usage":
        print(event["data"]["runCredits"])
```

## After each workflow run

Execute returns `executionId` and `usage` (null while running). Poll status or fetch execution detail:

<CodeGroup>
  ```ts theme={null}
  const run = await flowra.workflows.run(workflowId, {
    input: { message: 'hi' },
  });
  const status = await flowra.workflows.status(run.threadId);
  // status.usage when completed
  const detail = await flowra.workflows.execution(run.executionId);
  const billed = await flowra.usage.forExecution(run.executionId);
  ```

  ```python theme={null}
  run = flowra.workflows.run(workflow_id, {"input": {"message": "hi"}})
  status = flowra.workflows.status(run["threadId"])
  detail = flowra.workflows.execution(run["executionId"])
  billed = flowra.usage.for_execution(run["executionId"])
  ```
</CodeGroup>

## Related

* [Chat streaming](/guides/sdk-chat-streaming)
* [Threads](/guides/threads)
* [Workflows](/guides/workflows)
* [TypeScript SDK](/guides/sdk-typescript)
* [Python SDK](/guides/sdk-python)
* [SDKs](/guides/sdk)
