# Model Logs

Model logs let you view and trace model API invocations, helping you understand token consumption and invocation performance, and troubleshoot abnormal requests.

Model logs consist of the following two types of information:

- **Audit logs**: record the request ID, invocation time, model, API Key, invocation status, token consumption, performance metrics, and other information.
- **Inference logs**: on top of the audit information, additionally record the request and response content of model API invocations. Inference logs are disabled by default and must be enabled manually for each project.

> Inference logs are stored using the log service ULogService. Enabling them incurs ULogService charges.

## Supported Scope

Currently, logs are recorded for synchronous and streaming invocations of text models. Inference logs are not yet supported for asynchronous invocations, batch invocations, or other model types. The supported scope displayed in the console prevails.

Inference logs take effect on a per-project basis. Once enabled, invocations that fall within the supported scope and are initiated by API Keys of the current project are recorded; other projects are not affected.

## Enabling Inference Logs

1. Log in to the AstraFlow console and go to **UModelVerse > Model Logs**.
2. Click **Model Log Settings** in the upper-right corner of the page.
3. Turn on **Inference Logs**, read the notes on charges and data recording, and confirm.

Once enabled, the system starts recording the request and response content of model API invocations. Log data writing and display may be delayed by about 3 minutes; refresh the page later to view it.

> **Data Security Notice**
> Requests and responses may contain personal information, business data, or other sensitive content. Before enabling this feature, make sure that log recording complies with the data security and compliance requirements of your organization, and avoid passing sensitive credentials such as plaintext keys in requests.

## Viewing Model Logs

Go to **UModelVerse > Model Logs**, where you can filter invocation records by the following criteria:

- Time range
- API Key
- Region
- Model ID
- Invocation ID

The page displays the total number of invocations, the number of failures, and the log details within the filtered scope. Each log entry mainly contains:

| Information | Description |
| --- | --- |
| Invocation ID / Invocation time | Identifies a single model invocation and when it was initiated |
| Token consumption | Shows the total number of tokens as well as input and output tokens |
| Time to first token | Time elapsed from sending the request to receiving the first token |
| Output token speed per request | Average output speed of a single request, in tokens/s |
| Request and response content | Shows the input and model output of this invocation; requires inference logs to be enabled |
| Raw log | View the raw audit log or inference log of this invocation |

### Viewing Request and Response Content

After inference logs are enabled and invocations occur, you can view the input and output of an invocation in the **Request and Response Content** column of the log details, which helps you reproduce the context, analyze model performance, or locate abnormal results.

If inference logs are not enabled, the request and response bodies are not recorded in this area, and content generated while the feature was disabled cannot be backfilled or recovered.

## Exporting Logs

- **Exporting audit logs**: on the Model Logs page, click **Export Audit Logs** to export the audit data within the current filter scope.
- **Exporting inference logs**: if inference logs are enabled, click **View Inference Logs** to go to the log service ULogService, select the project and region corresponding to the current service, and then search or export the log data.

Inference logs support retrieval by log field, making it easy to locate invocation records by request ID, model, API Key, and other criteria. For details about retrieval and export, see the [ULogService documentation](https://docs.ucloud.cn/ulogservice/README).

## Disabling Inference Logs

After you turn off inference logs in **Model Log Settings**, the system stops recording new request and response content. Inference logs generated while the feature is disabled cannot be backfilled or recovered.

Inference logs that have already been recorded remain stored in ULogService and continue to incur charges based on actual storage and usage. If you no longer need them, go to ULogService to adjust the retention period or delete the relevant log data.

## Data Retention and Charges

- The queryable time range and the data retention period on the Model Logs page are subject to the notices displayed in the console.
- The retention period of inference logs can be managed in ULogService; the actual retention period is subject to the ULogService configuration.
- After inference logs are enabled, the related data is written to ULogService and billed according to actual usage of resources such as log writing, storage, indexing, and querying.
- Disabling inference logs only stops new records from being added; it does not automatically delete stored logs, so storage charges may still apply.

For billing items and prices, see [ULogService Billing](https://docs.ucloud.cn/ulogservice/bill/billing).

## FAQ

### I have invoked a model, why don't I see the request and response content?

Check the following in order:

1. Whether inference logs are enabled for the current project;
2. Whether the invocation occurred after inference logs were enabled;
3. Whether the invoked model and execution mode are within the supported scope;
4. Whether the filtered project, region, time range, API Key, and model are correct;
5. Whether you have waited about 3 minutes and refreshed the page.

### Will existing logs be deleted after I disable inference logs?

No. Disabling only stops new inference logs from being recorded. Data that has already been recorded remains stored in ULogService and may continue to incur storage charges.

### Why is the data on the platform different from the data in ULogService?

The synchronization time, filter criteria, and retention periods of the two may differ. Check whether the project, region, time range, and ULogService retention settings are consistent.
