openai-and-claude-usage-report-generator 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +16 -6
  2. package/package.json +8 -2
package/README.md CHANGED
@@ -16,8 +16,12 @@ Can be used as:
16
16
  ## Prerequisites
17
17
 
18
18
  - Node.js 18+ and Yarn (`.nvmrc` specifies 22)
19
- - **OpenAI**: API admin key, Organization ID, and Project ID
20
- - **Claude**: Anthropic **Admin API key** (`sk-ant-admin...`). Standard API keys do not work; create one in [Console Settings Admin keys](https://console.anthropic.com/settings/admin-keys).
19
+ - **OpenAI**: **Admin API key** (not a standard API key), Organization ID, and Project ID
20
+ - ⚠️ **Important**: Standard API keys do not work. You need an admin key with organization access.
21
+ - Create one in [OpenAI Platform → Settings → Organization → API keys](https://platform.openai.com/api-keys)
22
+ - **Claude**: Anthropic **Admin API key** (`sk-ant-admin...`)
23
+ - ⚠️ **Important**: Standard API keys do not work. You need an admin key.
24
+ - Create one in [Console → Settings → Admin keys](https://console.anthropic.com/settings/admin-keys)
21
25
 
22
26
  ## Installation
23
27
 
@@ -41,10 +45,12 @@ npm install openai-and-claude-usage-report-generator
41
45
 
42
46
  Create a `.env` file in the root directory (see `.env.example` for a template).
43
47
 
48
+ ⚠️ **Important**: Both platforms require **admin/administrative API keys**. Standard API keys will not work.
49
+
44
50
  **OpenAI** (default):
45
51
 
46
52
  ```env
47
- OPENAI_ADMIN_KEY=sk-...
53
+ OPENAI_ADMIN_KEY=sk-... # Must be an admin key, not a standard API key
48
54
  OPENAI_ORG_ID=org-...
49
55
  OPENAI_PROJECT_ID=proj_...
50
56
  ```
@@ -52,7 +58,7 @@ OPENAI_PROJECT_ID=proj_...
52
58
  **Claude**:
53
59
 
54
60
  ```env
55
- ANTHROPIC_ADMIN_API_KEY=sk-ant-admin-...
61
+ ANTHROPIC_ADMIN_API_KEY=sk-ant-admin-... # Must be an admin key (starts with sk-ant-admin), not a standard API key
56
62
  ```
57
63
 
58
64
  ## Usage
@@ -86,12 +92,13 @@ import {
86
92
  import type { OpenAIReportConfig, ClaudeReportConfig } from 'openai-and-claude-usage-report-generator';
87
93
 
88
94
  // Example: Fetch and process OpenAI costs
95
+ // Note: OPENAI_ADMIN_KEY must be an admin key, not a standard API key
89
96
  async function generateOpenAIReport() {
90
97
  const config: OpenAIReportConfig = {
91
98
  provider: 'openai',
92
99
  startDate: '2024-01-01',
93
100
  endDate: '2024-01-31',
94
- apiKey: process.env.OPENAI_ADMIN_KEY!,
101
+ apiKey: process.env.OPENAI_ADMIN_KEY!, // Must be an admin key
95
102
  orgId: process.env.OPENAI_ORG_ID!,
96
103
  projectId: process.env.OPENAI_PROJECT_ID!,
97
104
  };
@@ -118,12 +125,13 @@ async function generateOpenAIReport() {
118
125
  }
119
126
 
120
127
  // Example: Fetch and process Claude costs
128
+ // Note: ANTHROPIC_ADMIN_API_KEY must be an admin key (sk-ant-admin...), not a standard API key
121
129
  async function generateClaudeReport() {
122
130
  const config: ClaudeReportConfig = {
123
131
  provider: 'claude',
124
132
  startDate: '2024-01-01',
125
133
  endDate: '2024-01-31',
126
- apiKey: process.env.ANTHROPIC_ADMIN_API_KEY!,
134
+ apiKey: process.env.ANTHROPIC_ADMIN_API_KEY!, // Must be an admin key (starts with sk-ant-admin)
127
135
  };
128
136
 
129
137
  const buckets = await fetchClaudeCosts(config);
@@ -136,6 +144,8 @@ async function generateClaudeReport() {
136
144
 
137
145
  **Note**: When using as a library, you need to handle environment variables yourself. The `loadConfig` function is available but requires environment variables to be set, or you can construct the config objects directly as shown above.
138
146
 
147
+ ⚠️ **Important Reminder**: Both platforms require **admin/administrative API keys**. Standard API keys will not work for accessing cost/usage data.
148
+
139
149
  ## Output
140
150
 
141
151
  - **OpenAI**: `reports/openai/`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openai-and-claude-usage-report-generator",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "OpenAI and Claude API Usage Report Generator - CLI tool and library for generating billing reports",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,7 +30,13 @@
30
30
  "test:run": "vitest run",
31
31
  "build": "tsc",
32
32
  "postbuild": "node --input-type=module -e \"import fs from 'fs';const f='dist/cli.js';const c=fs.readFileSync(f,'utf8');fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c.replace(/^#!.*\\n/,''))\"",
33
- "prepublishOnly": "yarn test:run && yarn build"
33
+ "prepublishOnly": "yarn test:run && yarn build",
34
+ "version:patch": "npm version patch && git push --follow-tags",
35
+ "version:minor": "npm version minor && git push --follow-tags",
36
+ "version:major": "npm version major && git push --follow-tags",
37
+ "release:patch": "npm run version:patch && npm publish",
38
+ "release:minor": "npm run version:minor && npm publish",
39
+ "release:major": "npm run version:major && npm publish"
34
40
  },
35
41
  "keywords": [
36
42
  "openai",