CODE · 1.1 KB
tools/inspect-fal-account.mjs
Workspace snapshot · 09/04 14:52
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
const credentialReader = "C:\\service\\agent-venture-studio\\scripts\\read-avs-credential.ps1";
const credentialTarget = "AgentVentureStudio:Fal:AiVideoLab";
const { stdout } = await execFileAsync(
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", credentialReader, "-Target", credentialTarget],
{ timeout: 30000, maxBuffer: 4096, windowsHide: true, encoding: "utf8" },
);
const key = stdout.trim();
if (!key) throw new Error("Stored fal key unavailable");
const response = await fetch("https://api.fal.ai/v1/account/billing?expand=credits", {
headers: { Authorization: `Key ${key}` },
});
const body = await response.json().catch(() => ({}));
console.log(JSON.stringify(response.ok
? {
username: body.username,
balance: body.credits?.current_balance,
currency: body.credits?.currency,
}
: {
status: response.status,
error: body.detail || body.message || "request failed",
}));