Sohay → Diagnostics is the first place to look when the chat misbehaves, and the place to check occasionally when it does not.
What it shows
Today’s token usage, live. Two numbers matter: what you have spent, and how close that is to the daily cap you set. A cap that is about to be reached is worth knowing before it starts turning real visitors away — from the visitor’s side, a limit that fires is indistinguishable from an outage.
The last 100 log entries, with timestamps and context. Provider errors land here: rejected keys, exhausted quotas, refused requests, failing syncs, streaming failures.
Reading usage
A usage number that climbs in step with your conversation count is just your site working.
A number that jumps without a matching jump in conversations is the signal to investigate. That shape usually means one of:
- A loop — something re-sending the same request.
- An abusive client hammering the endpoint.
- A model change you made and forgot; a flagship tier costs a large multiple of a mini one for identical work.
Catching it here is much cheaper than catching it on the invoice.
Reading the log
The most common entries and what they mean:
| What you see | Usually means |
|---|---|
| Authentication or invalid-key errors | The key is wrong, revoked, or has whitespace around it |
| Quota or billing errors | The provider account has no balance or has hit its own limit |
| Rate-limit errors from the provider | You are sending faster than your provider tier allows |
| Sync failures | See When a Knowledge Base sync fails |
| Stream or connection errors | See Answers cut off behind a CDN or proxy |
The buffer holds the most recent 100 entries. A problem from last week will have rolled off — reproduce it, then look.
Sending errors somewhere permanent
Every log entry also fires an action, so errors can go to whatever you already use:
add_action( 'sohaychat_log_error', function ( $message, $context ) {
// Forward to Sentry, Stackdriver, Query Monitor, your own logger.
}, 10, 2 );
Worth wiring up on a production site. A 100-entry buffer is fine for answering “what just happened?” and no use at all for “what happened at 3am on Tuesday?”.
Who can see it
Diagnostics is read-only and gated on the sohaychat_view_logs capability,
which administrators hold automatically. It is a reasonable capability to
delegate to whoever keeps the site running without also handing them AI
Settings and your API keys.
Clearing the log buffer requires the higher sohaychat_manage capability, so
somebody with read access cannot erase the evidence.
Where to go next
Daily token caps and rate limits for the ceilings the usage readout is measured against.