Skip to content
Start here

List Gateway Logs

client.aiGateway.logs.list(stringgatewayId, LogListParams { account_id, cached, direction, 26 more } params, RequestOptionsoptions?): V4PagePaginationArray<LogListResponse { id, cached, created_at, 16 more } >
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
gatewayId: string

gateway id

maxLength64
minLength1
params: LogListParams { account_id, cached, direction, 26 more }
account_id: string

Path param

Deprecatedcached?: boolean

Query param

Deprecateddirection?: "asc" | "desc"

Query param

One of the following:
"asc"
"desc"
Deprecatedend_date?: string

Query param

formatdate-time
Deprecatedfeedback?: 0 | 1

Query param

One of the following:
0
1
filters?: Array<Filter>

Query param

key: "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: "eq" | "neq" | "contains" | 2 more
One of the following:
"eq"
"neq"
"contains"
"lt"
"gt"
value: Array<string | null | number | boolean>
One of the following:
string | null
number
boolean
Deprecatedmax_cost?: number

Query param

Deprecatedmax_duration?: number

Query param

Deprecatedmax_tokens_in?: number

Query param

Deprecatedmax_tokens_out?: number

Query param

Deprecatedmax_total_tokens?: number

Query param

meta_info?: boolean

Query param

Deprecatedmin_cost?: number

Query param

Deprecatedmin_duration?: number

Query param

Deprecatedmin_tokens_in?: number

Query param

Deprecatedmin_tokens_out?: number

Query param

Deprecatedmin_total_tokens?: number

Query param

Deprecatedmodel?: string

Query param

Deprecatedmodel_type?: string

Query param

order_by?: "created_at" | "provider" | "model" | 3 more

Query param

One of the following:
"created_at"
"provider"
"model"
"model_type"
"success"
"cached"
order_by_direction?: "asc" | "desc"

Query param

One of the following:
"asc"
"desc"
page?: number

Query param

minimum1
per_page?: number

Query param

maximum50
minimum1
Deprecatedprovider?: string

Query param

Deprecatedrequest_content_type?: string

Query param

Deprecatedresponse_content_type?: string

Query param

Deprecatedstart_date?: string

Query param

formatdate-time
Deprecatedsuccess?: boolean

Query param

ReturnsExpand Collapse
LogListResponse { id, cached, created_at, 16 more }
id: string
cached: boolean
created_at: string
formatdate-time
duration: number
model: string
path: string
provider: string
success: boolean
tokens_in: number | null
tokens_out: number | null
cost?: number
custom_cost?: boolean
metadata?: string
model_type?: string
request_content_type?: string
request_type?: string
response_content_type?: string
status_code?: number
step?: number

List Gateway Logs

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const logListResponse of client.aiGateway.logs.list('my-gateway', {
  account_id: '0d37909e38d3e99c29fa2cd343ac421a',
})) {
  console.log(logListResponse.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
}