Query usage analytics
package main
import ( "fmt" "net/http" "io")
func main() {
url := "https://api.ai.wpengine.com/v1/analytics?project_id=example&start_time=1&bucket_width=10m&auth_method=browser_session&actor_type=anonymous&application=wpe-ai-chatbot"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.ai.wpengine.com/v1/analytics?project_id=example&start_time=1&bucket_width=10m&auth_method=browser_session&actor_type=anonymous&application=wpe-ai-chatbot';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.ai.wpengine.com/v1/analytics?project_id=example&start_time=1&bucket_width=10m&auth_method=browser_session&actor_type=anonymous&application=wpe-ai-chatbot', [ 'headers' => [ 'Authorization' => 'Bearer <token>', ],]);
echo $response->getBody();curl --request GET \ --url 'https://api.ai.wpengine.com/v1/analytics?project_id=example&start_time=1&bucket_width=10m&auth_method=browser_session&actor_type=anonymous&application=wpe-ai-chatbot' \ --header 'Authorization: Bearer <token>'Returns credit consumption and request counts aggregated into time-bucketed slots for a given project and time range. Requires account-level Okta authentication.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”The project to query analytics for.
Start of the query window as a Unix timestamp in seconds (inclusive).
End of the query window as a Unix timestamp in seconds (exclusive). Defaults to the current time.
Width of each time bucket in the response. Defaults to 1d. Maximum query windows per bucket_width: 10m → 24 hours, 1h → 7 days, 1d → 30 days.
Filter results to a single registered site, identified by the client_id returned by the sites API. When omitted, all sites are included. Usage with no registered site (console, playground and direct API-key traffic) is reported with an empty client_id and cannot be selected by this filter.
Filter results by authentication method. When omitted, all auth methods are included. browser_session: browser-session traffic. api_key: API key traffic. service_token: service-token callers. okta: Okta-authenticated callers. internal_service: internal service-to-service calls. unknown: unclassified auth.
Filter results by actor type. When omitted, all actor types are included. anonymous: unauthenticated end users. authenticated: logged-in end users. service: service accounts. unknown: actor type not yet determined.
Filter results by calling application. When omitted, all applications are included. wpe-ai-chatbot: WP Engine AI Chatbot. wpe-ai-playground: WP Engine AI Playground. power-coworker: Power Coworker. power-connector: Power Connector. wpe-agents: WP Engine Agents. wpe-kb-sync: WP Engine knowledge-base sync. third_party: any other identified caller. unknown: no caller user-agent present.
Comma-separated list of dimension columns to group results by. When omitted, results are grouped by model and operation (preserving the default behaviour). Valid values: model, operation, client_id, auth_method, actor_type, application. Example: group_by=client_id,application.
Responses
Section titled “Responses”Analytics data for the requested time range
object
The bucket width used for the response, echoing the request parameter.
Inclusive start of the response window (UTC).
Exclusive end of the response window (UTC).
object
Total credits consumed, in exact integer nanocredits (1 credit = 1,000,000,000 nanocredits). Divide by 1,000,000,000 to get credits.
Total number of requests.
Per-model, per-operation breakdown sorted by credits descending. Entries with equal credits are ordered by model, operation, client_id, auth_method, actor_type then application (all ascending), so the order is stable across identical requests.
object
Model identifier (e.g. “google/gemini-3.5-flash”).
Operation type (e.g. “chat”, “image”).
The registered site this row is attributed to. Only present when client_id is included in the group_by parameter, and empty within such a response for usage that has no registered site (console, playground and direct API-key traffic).
Authentication method for this row. Only present when auth_method is included in the group_by parameter.
Actor type for this row. Only present when actor_type is included in the group_by parameter.
Calling application for this row. Only present when application is included in the group_by parameter.
Credits consumed, in exact integer nanocredits (1 credit = 1,000,000,000 nanocredits). Divide by 1,000,000,000 to get credits.
Number of requests for this model and operation.
object
Start of this bucket (UTC).
Credits consumed in this bucket, in exact integer nanocredits (1 credit = 1,000,000,000 nanocredits). Divide by 1,000,000,000 to get credits.
Number of requests in this bucket.
object
Model identifier (e.g. “google/gemini-3.5-flash”).
Operation type (e.g. “chat”, “image”).
The registered site this row is attributed to. Only present when client_id is included in the group_by parameter, and empty within such a response for usage that has no registered site (console, playground and direct API-key traffic).
Authentication method for this row. Only present when auth_method is included in the group_by parameter.
Actor type for this row. Only present when actor_type is included in the group_by parameter.
Calling application for this row. Only present when application is included in the group_by parameter.
Credits consumed, in exact integer nanocredits (1 credit = 1,000,000,000 nanocredits). Divide by 1,000,000,000 to get credits.
Number of requests for this model and operation.
Example
{ "bucket_width": "10m", "totals": { "credits_nano": 12000000000, "models": [ { "model": "google/gemini-3.5-flash", "operation": "chat", "client_id": "wpe_site_9f2c41", "auth_method": "browser_session", "actor_type": "anonymous", "application": "wpe-ai-chatbot", "credits_nano": 4230000000 } ] }, "buckets": [ { "credits_nano": 1500000000, "models": [ { "model": "google/gemini-3.5-flash", "operation": "chat", "client_id": "wpe_site_9f2c41", "auth_method": "browser_session", "actor_type": "anonymous", "application": "wpe-ai-chatbot", "credits_nano": 4230000000 } ] } ]}Invalid request body or parameters
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Missing or invalid bearer token
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}Headers
Section titled “Headers”Example
Bearer realm="ai-services"The token is valid, but the caller is not permitted to perform this action — either its scope/permission is insufficient or the authenticated user is not authorized for the target account (error type “permission_error”). On /v1/chat/completions specifically, a 403 with error type “content_policy_violation” instead means the request content was blocked by content moderation policy; that response never identifies which filter or category matched.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}A required dependency is temporarily unavailable. Retry after a short delay with exponential back-off.
object
object
Correlation ID for this request, matching the X-Request-ID response header — a 32-character trace ID behind the load balancer, otherwise a UUID. Quote it in support reports.
Example
{ "error": { "type": "invalid_request_error", "request_id": "80f1e2c3a4b5c6d7e8f9a0b1c2d3e4f5" }}