Skip to content
Start here

List Gateway Logs

ai_gateway.logs.list(strgateway_id, LogListParams**kwargs) -> SyncV4PagePaginationArray[LogListResponse]
GET/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs

List Gateway Logs

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
AI Gateway WriteAI Gateway Read
ParametersExpand Collapse
account_id: str
gateway_id: str

gateway id

maxLength64
minLength1
Deprecatedcached: Optional[bool]
Deprecateddirection: Optional[Literal["asc", "desc"]]
One of the following:
"asc"
"desc"
Deprecatedend_date: Optional[Union[str, datetime]]
formatdate-time
Deprecatedfeedback: Optional[Literal[0, 1]]
One of the following:
0
1
filters: Optional[Iterable[Filter]]
key: Literal["id", "created_at", "request_content_type", 20 more]
One of the following:
"id"
"created_at"
"request_content_type"
"response_content_type"
"request_type"
"success"
"cached"
"provider"
"model"
"model_type"
"cost"
"tokens"
"tokens_in"
"tokens_out"
"duration"
"feedback"
"event_id"
"metadata.key"
"metadata.value"
"authentication"
"wholesale"
"compatibilityMode"
"dlp_action"
operator: Literal["eq", "neq", "contains", 2 more]
One of the following:
"eq"
"neq"
"contains"
"lt"
"gt"
value: SequenceNotStr[Union[Optional[str], float, bool]]
One of the following:
Optional[str]
float
bool
Deprecatedmax_cost: Optional[float]
Deprecatedmax_duration: Optional[float]
Deprecatedmax_tokens_in: Optional[float]
Deprecatedmax_tokens_out: Optional[float]
Deprecatedmax_total_tokens: Optional[float]
meta_info: Optional[bool]
Deprecatedmin_cost: Optional[float]
Deprecatedmin_duration: Optional[float]
Deprecatedmin_tokens_in: Optional[float]
Deprecatedmin_tokens_out: Optional[float]
Deprecatedmin_total_tokens: Optional[float]
Deprecatedmodel: Optional[str]
Deprecatedmodel_type: Optional[str]
order_by: Optional[Literal["created_at", "provider", "model", 3 more]]
One of the following:
"created_at"
"provider"
"model"
"model_type"
"success"
"cached"
order_by_direction: Optional[Literal["asc", "desc"]]
One of the following:
"asc"
"desc"
page: Optional[int]
minimum1
per_page: Optional[int]
maximum50
minimum1
Deprecatedprovider: Optional[str]
Deprecatedrequest_content_type: Optional[str]
Deprecatedresponse_content_type: Optional[str]
Deprecatedstart_date: Optional[Union[str, datetime]]
formatdate-time
Deprecatedsuccess: Optional[bool]
ReturnsExpand Collapse
class LogListResponse:
id: str
cached: bool
created_at: datetime
formatdate-time
duration: int
model: str
path: str
provider: str
success: bool
tokens_in: Optional[int]
tokens_out: Optional[int]
cost: Optional[float]
custom_cost: Optional[bool]
metadata: Optional[str]
model_type: Optional[str]
request_content_type: Optional[str]
request_type: Optional[str]
response_content_type: Optional[str]
status_code: Optional[int]
step: Optional[int]

List Gateway Logs

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
page = client.ai_gateway.logs.list(
    gateway_id="my-gateway",
    account_id="0d37909e38d3e99c29fa2cd343ac421a",
)
page = page.result[0]
print(page.id)
{
  "result": [
    {
      "id": "id",
      "cached": true,
      "created_at": "2019-12-27T18:11:19.117Z",
      "duration": 0,
      "model": "model",
      "path": "path",
      "provider": "provider",
      "success": true,
      "tokens_in": 0,
      "tokens_out": 0,
      "cost": 0,
      "custom_cost": true,
      "metadata": "metadata",
      "model_type": "model_type",
      "request_content_type": "request_content_type",
      "request_type": "request_type",
      "response_content_type": "response_content_type",
      "status_code": 0,
      "step": 0
    }
  ],
  "result_info": {
    "count": 0,
    "max_cost": 0,
    "max_duration": 0,
    "max_tokens_in": 0,
    "max_tokens_out": 0,
    "max_total_tokens": 0,
    "min_cost": 0,
    "min_duration": 0,
    "min_tokens_in": 0,
    "min_tokens_out": 0,
    "min_total_tokens": 0,
    "page": 0,
    "per_page": 0,
    "total_count": 0
  },
  "success": true
}
Returns Examples
{
  "result": [
    {
      "id": "id",
      "cached": true,
      "created_at": "2019-12-27T18:11:19.117Z",
      "duration": 0,
      "model": "model",
      "path": "path",
      "provider": "provider",
      "success": true,
      "tokens_in": 0,
      "tokens_out": 0,
      "cost": 0,
      "custom_cost": true,
      "metadata": "metadata",
      "model_type": "model_type",
      "request_content_type": "request_content_type",
      "request_type": "request_type",
      "response_content_type": "response_content_type",
      "status_code": 0,
      "step": 0
    }
  ],
  "result_info": {
    "count": 0,
    "max_cost": 0,
    "max_duration": 0,
    "max_tokens_in": 0,
    "max_tokens_out": 0,
    "max_total_tokens": 0,
    "min_cost": 0,
    "min_duration": 0,
    "min_tokens_in": 0,
    "min_tokens_out": 0,
    "min_total_tokens": 0,
    "page": 0,
    "per_page": 0,
    "total_count": 0
  },
  "success": true
}