@inductiv/node-red-openai-api
Version:
Enhance your Node-RED projects with advanced AI capabilities.
662 lines (661 loc) • 18.2 kB
JSON
[
{
"id": "6a49c6dfe3a24511",
"type": "tab",
"label": "Admin Example",
"disabled": false,
"info": "Admin example.\n\nThis flow shows representative Admin surfaces for organization and project controls in the same direct Node-RED style as the rest of the project:\n- list organization projects\n- inspect recent organization audit logs\n- inspect project rate limits and update a rate limit by id\n- inspect organization usage for web search calls\n- update organization data retention controls\n- create, list, and update project spend alerts\n- update project model and hosted tool permissions\n- update a project service account\n\nBefore running:\n- import the flow, then configure each red-marked `OpenAI API` node with your own `Service Host`\n- the selected `Service Host` must include an `Admin API Key`\n- replace `proj_replace_me`, `rlimit_replace_me`, `alert_replace_me`, and `svc_replace_me` with real ids returned by your organization or project lookups\n\nThis flow keeps all request data under `msg.payload`, which matches the default `OpenAI API` node property.",
"env": []
},
{
"id": "eb58f2dd2c6a4d73",
"type": "comment",
"z": "6a49c6dfe3a24511",
"name": "Use a Service Host with an Admin API Key, then replace the placeholder admin ids.",
"info": "What this flow covers:\n- organization project listing through `listOrganizationProjects`\n- organization audit-log retrieval through `listOrganizationAuditLogs`\n- project rate-limit inspection and updates through `listProjectRateLimits` and `modifyProjectRateLimit`\n- usage reporting through `getOrganizationUsageWebSearchCalls`\n- organization data retention through `modifyOrganizationDataRetention`\n- project spend alert create/list/update through `createProjectSpendAlert`, `listProjectSpendAlerts`, and `modifyProjectSpendAlert`\n- project permission updates through `modifyProjectModelPermissions` and `modifyProjectHostedToolPermissions`\n- existing-family project service account updates through `modifyProjectServiceAccount`\n\nExpected setup:\n- your `Service Host` must include a working `Admin API Key`\n- `proj_replace_me` should be replaced with a real `project_id`\n- `rlimit_replace_me` should be replaced with a real `rate_limit_id` from the list-rate-limits response\n- `alert_replace_me` should be replaced with a real project spend alert id after creating or listing alerts\n- `svc_replace_me` should be replaced with a real project service account id",
"x": 520,
"y": 100,
"wires": []
},
{
"id": "4f4c2c4d3f9f4f6d",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "List Organization Projects",
"props": [
{
"p": "payload.limit",
"v": "10",
"vt": "num"
},
{
"p": "payload.include_archived",
"v": "false",
"vt": "bool"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 210,
"y": 220,
"wires": [
[
"4b8d06bd3d5f45ba"
]
]
},
{
"id": "4b8d06bd3d5f45ba",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "List Organization Projects",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "listOrganizationProjects",
"x": 500,
"y": 220,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "be0f4ef4055d4e62",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "List Organization Audit Logs",
"props": [
{
"p": "payload.limit",
"v": "20",
"vt": "num"
},
{
"p": "payload.effective_at",
"v": "{\"gt\":1710000000}",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 220,
"y": 300,
"wires": [
[
"f836a42338444d8f"
]
]
},
{
"id": "f836a42338444d8f",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "List Organization Audit Logs",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "listOrganizationAuditLogs",
"x": 510,
"y": 300,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "d98e27b4821647ea",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "List Project Rate Limits",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 210,
"y": 380,
"wires": [
[
"9f910f112c93456f"
]
]
},
{
"id": "9f910f112c93456f",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "List Project Rate Limits",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "listProjectRateLimits",
"x": 500,
"y": 380,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "307a2c5d1fb541b2",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Rate Limit",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.rate_limit_id",
"v": "rlimit_replace_me",
"vt": "str"
},
{
"p": "payload.max_requests_per_1_minute",
"v": "500",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 210,
"y": 460,
"wires": [
[
"72d3f27538464b90"
]
]
},
{
"id": "72d3f27538464b90",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Rate Limit",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyProjectRateLimit",
"x": 500,
"y": 460,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "d191c5f11a3b4f00",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Usage Web Search Calls",
"props": [
{
"p": "payload.start_time",
"v": "1710000000",
"vt": "num"
},
{
"p": "payload.end_time",
"v": "1710086400",
"vt": "num"
},
{
"p": "payload.bucket_width",
"v": "1d",
"vt": "str"
},
{
"p": "payload.group_by",
"v": "[\"project_id\"]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 210,
"y": 540,
"wires": [
[
"6b53782f5fd14a41"
]
]
},
{
"id": "6b53782f5fd14a41",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Usage Web Search Calls",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "getOrganizationUsageWebSearchCalls",
"x": 500,
"y": 540,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "a18f5a69960f43ca",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Organization Data Retention",
"props": [
{
"p": "payload.retention_type",
"v": "modified_abuse_monitoring",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 620,
"wires": [
[
"96b2da4c2b1c48f6"
]
]
},
{
"id": "96b2da4c2b1c48f6",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Organization Data Retention",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyOrganizationDataRetention",
"x": 550,
"y": 620,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "fe4a7b2f5a93434b",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Create Project Spend Alert",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.currency",
"v": "USD",
"vt": "str"
},
{
"p": "payload.interval",
"v": "month",
"vt": "str"
},
{
"p": "payload.threshold_amount",
"v": "100000",
"vt": "num"
},
{
"p": "payload.notification_channel",
"v": "{\"type\":\"email\",\"recipients\":[\"admin@example.com\"],\"subject_prefix\":\"OpenAI spend\"}",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 230,
"y": 700,
"wires": [
[
"1e760a2d29b64eb1"
]
]
},
{
"id": "1e760a2d29b64eb1",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Create Project Spend Alert",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "createProjectSpendAlert",
"x": 520,
"y": 700,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "e380c459e96c4c05",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "List Project Spend Alerts",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.limit",
"v": "10",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 220,
"y": 780,
"wires": [
[
"6d52e0e042d34d02"
]
]
},
{
"id": "6d52e0e042d34d02",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "List Project Spend Alerts",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "listProjectSpendAlerts",
"x": 520,
"y": 780,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "2c853ef3ee854efb",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Spend Alert",
"props": [
{
"p": "payload.alert_id",
"v": "alert_replace_me",
"vt": "str"
},
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.currency",
"v": "USD",
"vt": "str"
},
{
"p": "payload.interval",
"v": "month",
"vt": "str"
},
{
"p": "payload.threshold_amount",
"v": "125000",
"vt": "num"
},
{
"p": "payload.notification_channel",
"v": "{\"type\":\"email\",\"recipients\":[\"admin@example.com\"]}",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 230,
"y": 860,
"wires": [
[
"92cb048b6d784f3a"
]
]
},
{
"id": "92cb048b6d784f3a",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Spend Alert",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyProjectSpendAlert",
"x": 520,
"y": 860,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "a3959caf05274dcb",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Model Permissions",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.mode",
"v": "allow_list",
"vt": "str"
},
{
"p": "payload.model_ids",
"v": "[\"gpt-4.1-mini\"]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 940,
"wires": [
[
"c0e99e62df864c73"
]
]
},
{
"id": "c0e99e62df864c73",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Model Permissions",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyProjectModelPermissions",
"x": 550,
"y": 940,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "2d3832d907ea4c75",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Hosted Tool Permissions",
"props": [
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.web_search",
"v": "{\"enabled\":true}",
"vt": "json"
},
{
"p": "payload.file_search",
"v": "{\"enabled\":true}",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 1020,
"wires": [
[
"a57d97a0d4934d6b"
]
]
},
{
"id": "a57d97a0d4934d6b",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Hosted Tool Permissions",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyProjectHostedToolPermissions",
"x": 550,
"y": 1020,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "2978c8590a244a53",
"type": "inject",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Service Account",
"props": [
{
"p": "payload.service_account_id",
"v": "svc_replace_me",
"vt": "str"
},
{
"p": "payload.project_id",
"v": "proj_replace_me",
"vt": "str"
},
{
"p": "payload.name",
"v": "automation-service",
"vt": "str"
},
{
"p": "payload.role",
"v": "member",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 250,
"y": 1100,
"wires": [
[
"8eadb71d955448a6"
]
]
},
{
"id": "8eadb71d955448a6",
"type": "OpenAI API",
"z": "6a49c6dfe3a24511",
"name": "Modify Project Service Account",
"property": "payload",
"propertyType": "msg",
"service": "",
"method": "modifyProjectServiceAccount",
"x": 550,
"y": 1100,
"wires": [
[
"08cc06e7f92249ca"
]
]
},
{
"id": "08cc06e7f92249ca",
"type": "debug",
"z": "6a49c6dfe3a24511",
"name": "Admin Output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 810,
"y": 660,
"wires": []
}
]