Meta connections and spending protection — 2.8.2
ChatGPT and Meta subscription cards now share a Blade template: subscription tab, description, status, matching action buttons and next-step note. Meta connection details live under Advanced settings. Meta sign-in still requires administrator provisioning; Set up connection opens the official sign-in guide.
The Meta API tab accepts a tenant-owned key and monthly USD limit. Saving a key does not switch providers. Select Meta API (spending protected) in defaults to use it. A zero or missing saved limit blocks requests, including connection tests. Existing subscription adapters through Custom AI remain unchanged.
Enforcement
- Central MySQL ledger keyed by tenant and UTC calendar month; row locking makes admission atomic across workers. Usage survives cache clearing and restarts.
- Each outbound HTTP attempt reserves its worst-case cost before it is sent: the full 1,048,576-token input context plus a maximum 16,384 output tokens at Standard rates, rounded up to the next $0.10. That is $1.40 for Muse Spark 1.1–1.3 and $4.60 for Muse Wonder 1.0 (
MetaApiBudget::reservationFor). Concurrent requests and retries reserve separately. - Successful non-streaming responses release the unused reservation using reported input/output counts. Cached-input discounts are ignored, making accounting conservative. Streams, network failures, non-200 responses and invalid/missing usage retain the reservation. No automatic refunds for uncertain outcomes. The one certain outcome is Meta's own
401 authentication_error/invalid_api_keyenvelope (observed live 2026-10-21): nothing was processed, so that reservation is released (MetaApiBudget::release). Any other 401 keeps it. - Only Standard-mode text chat requests for models listed in
MetaApiBudget::PRICESare admitted: Muse Spark 1.1–1.3 and Muse Wonder 1.0 (added 2026-10-20). Unpriced models, paid server tools, media inputs, multiple completions and unbounded output fail before network access. Function calls are allowed; follow-up requests reserve again. - Both Prism (text, structured and streaming) and the direct connection-test path use the same HTTP middleware. Central requests without a tenant fail closed.
- The cap applies to this connector's admitted requests, not API-key use in other apps, Custom AI, other providers, previous usage, taxes or subscription billing. It is conservative admission accounting, not Meta invoice reconciliation.
- Prices verified on 19 and 20 October 2026 at https://dev.meta.ai/docs/pricing-rate-limits: Spark Standard $1.25 input and $4.25 output per million tokens; Wonder 1.0 Standard $4.00 input and $20.00 output. Muse Wonder Full is Muse Code-only and is not offered on the API route (model lists split in
MuseCodePlanConnection::MODELSvsMETERED_MODELS, 2026-10-20). An administrator must review pricing before 19 November 2026; requests stop after that cutoff until the code is reviewed.
Deployment and rollback
Local validation: 14 focused tests / 49 assertions passed. Real local MySQL concurrency check with six processes and a $2 limit admitted one $1.40 reservation, blocked five and reported zero errors. Disposable test rows were removed. PHP lint, Blade compilation and diff whitespace checks passed. Browser verification could not run because local browser access was disabled in Work settings.
Version stays 2.8.2 as requested. Deploy only the listed changed application files, Blade templates, this note and VERSION. Run only migration 2026_10_19_060000_create_meta_api_budgets_table.php, then compile views and gracefully restart queue workers. No credentials or provider defaults are changed by deploy.
Before deployment, archive every existing target file and record newly added paths. Rollback restores the archived files and removes only those newly added paths; retain the ledger table and migration record to preserve spending history. Compile views and restart workers after rollback. Rolling back the guard also removes its protection: keep metered Meta disabled if reverting to the previous implementation.
