Skip to main content

Documentation Index

Fetch the complete documentation index at: https://doc.hitopen.com/llms.txt

Use this file to discover all available pages before exploring further.

Newapi records a log entry for every request processed, capturing the model used, token counts, cost, timestamp, and status. These logs let you monitor spending, audit activity, and debug failed requests.

What gets logged

Each log entry includes:
FieldDescription
TimestampWhen the request was received
ModelThe model name used (e.g., gpt-4o)
Prompt tokensNumber of input tokens consumed
Completion tokensNumber of output tokens generated
Total tokensSum of prompt and completion tokens
CostCredit cost charged against the token’s quota
StatusWhether the request succeeded or failed
TokenWhich API token was used
ChannelWhich upstream channel handled the request (admin view)

Viewing logs in the console

  1. Log in to the Newapi console and click Logs in the sidebar.
  2. The logs table shows all requests made with your tokens, sorted by most recent first.
  3. Use the filters at the top to narrow results by date range, model, token name, or status.
  4. Click any row to expand the full details for that request, including the error message if the request failed.
Administrators can see logs for all users. Standard users see only the logs for their own tokens.

Querying your logs via API

Use GET /api/log/self to retrieve your own logs programmatically. This endpoint requires a valid API token (User permission).
curl "https://YOUR_NEWAPI_BASE_URL/api/log/self?p=1&page_size=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

Query parameters

ParameterTypeDescription
pintegerPage number (1-indexed). Defaults to 1.
page_sizeintegerNumber of results per page. Defaults to 10.
The response body contains a data array of log objects and a total count you can use for pagination.

Aggregated statistics

For a summary of your usage rather than individual request logs, call GET /api/data/self. This endpoint returns aggregated data — daily totals and model breakdowns — useful for tracking trends and forecasting costs.
curl "https://YOUR_NEWAPI_BASE_URL/api/data/self" \
  -H "Authorization: Bearer YOUR_API_KEY"
The response includes fields such as total quota consumed, request count, and a per-model breakdown for the queried period.

Using logs to debug failed requests

When a request fails, the log entry records the HTTP status code and error message returned by the upstream provider. To find failed requests:
1

Filter by status

In the console Logs view, use the Status filter to show only failed requests. Alternatively, query the API and filter for entries where the status field indicates an error.
2

Check the error message

Click the failed log entry to expand it. The Error field shows the upstream provider’s error message — for example, rate_limit_exceeded or invalid_api_key.
3

Identify the channel

Administrators can see which channel handled the request. If a specific channel is consistently failing, test it from the Channels page to verify connectivity.
4

Check your token quota

If requests are failing with a quota error, go to Token Management and verify the token still has remaining quota. You can request a quota increase from your administrator.
If you are seeing unexpected failures, compare the prompt and completion token counts in the log against the limits for that model. Requests that exceed a model’s context window are rejected by the upstream provider.

Next steps

  • API Tokens — Understand how quotas relate to token spending
  • Channels — Learn how to test and troubleshoot upstream connections
  • Management API: Logs — Full reference for log endpoints