Automation library · Data collection

Track OpenAI Admin API usage and costs with Google Sheets

Started by a clock, and works across Google Sheets. 26 steps: large, and worth reading before you trust it with anything live.

Large

26 stepsLarge: read it before trusting it with anything live
0Branches: places the flow splits
0Loops or waits
1Service it connects to

The flow

Starts it 1Logic 19Service 6

The steps in the order they run, from what starts it.

  1. 1Schedule TriggerSchedule triggerStarts it
  2. 2OpenAI Admin - Get costHttp RequestService
  3. 3OpenAI Admin - get token usageHttp RequestService
  4. 4Merge token and usageMergeLogic
  5. 5Set api_key and project idsSetLogic
  6. 6Merge Usage dataMergeLogic
  7. 7Get project_idsCodeLogic
  8. 8Merge token, usage, projectsMergeLogic
  9. 9Split Out api_key and projectSplit OutLogic
  10. 10Add api_key name to token usageCodeLogic
  11. 11OpenAI Admin - Get Project detailsHttp RequestService
  12. 12Structure usage, cost, projectsSetLogic
  13. 13OpenAI Admin - Get API Key detailsHttp RequestService
  14. 14Add Project name in cost and usage objectsCodeLogic
  15. 15Set api_key id and nameSetLogic
  16. 16Split Out UsageSplit OutLogic
  17. 17Split Out CostSplit OutLogic
  18. 18Remove DuplicatesRemove DuplicatesLogic
  19. 19Structure Usage dataSetLogic
  20. 20Structure Cost dataSetLogic
  21. 21Split Out Usage ResultsSplit OutLogic
  22. 22Split Out Cost resultsSplit OutLogic
  23. 23Set Usage data for GsheetsSetLogic
  24. 24Set Cost data for GsheetsSetLogic
  25. 25Append Usage to GSheetsGoogle SheetsService
  26. 26Append Cost to GSheetsGoogle SheetsService

How it's built

Starts on
A clock
Steps
26
Size
Large: read it before trusting it with anything live
Connects to
Google Sheets
Model
None. This is plumbing, not judgement

Questions

What does it need to run?

An n8n account, plus your own Google Sheets account. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Take your time. At 26 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

Before you run it

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 26 steps before you point it at anything that matters.