# Logs ## List Gateway Logs `client.aiGateway.logs.list(stringgatewayId, LogListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs` List Gateway Logs ### Parameters - `gatewayId: string` gateway id - `params: LogListParams` - `account_id: string` Path param - `cached?: boolean` Query param - `direction?: "asc" | "desc"` Query param - `"asc"` - `"desc"` - `end_date?: string` Query param - `feedback?: 0 | 1` Query param - `0` - `1` - `filters?: Array` Query param - `key: "id" | "created_at" | "request_content_type" | 20 more` - `"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` - `"eq"` - `"neq"` - `"contains"` - `"lt"` - `"gt"` - `value: Array` - `string | null` - `number` - `boolean` - `max_cost?: number` Query param - `max_duration?: number` Query param - `max_tokens_in?: number` Query param - `max_tokens_out?: number` Query param - `max_total_tokens?: number` Query param - `meta_info?: boolean` Query param - `min_cost?: number` Query param - `min_duration?: number` Query param - `min_tokens_in?: number` Query param - `min_tokens_out?: number` Query param - `min_total_tokens?: number` Query param - `model?: string` Query param - `model_type?: string` Query param - `order_by?: "created_at" | "provider" | "model" | 3 more` Query param - `"created_at"` - `"provider"` - `"model"` - `"model_type"` - `"success"` - `"cached"` - `order_by_direction?: "asc" | "desc"` Query param - `"asc"` - `"desc"` - `page?: number` Query param - `per_page?: number` Query param - `provider?: string` Query param - `request_content_type?: string` Query param - `response_content_type?: string` Query param - `search?: string` Query param - `start_date?: string` Query param - `success?: boolean` Query param ### Returns - `LogListResponse` - `id: string` - `cached: boolean` - `created_at: string` - `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` ### Example ```node 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); } ``` #### Response ```json { "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 } ``` ## Get Gateway Log Detail `client.aiGateway.logs.get(stringgatewayId, stringid, LogGetParamsparams, RequestOptionsoptions?): LogGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}` Retrieves detailed information for a specific AI Gateway log entry. ### Parameters - `gatewayId: string` gateway id - `id: string` - `params: LogGetParams` - `account_id: string` ### Returns - `LogGetResponse` - `id: string` - `cached: boolean` - `created_at: string` - `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_head?: string` - `request_head_complete?: boolean` - `request_size?: number` - `request_type?: string` - `response_content_type?: string` - `response_head?: string` - `response_head_complete?: boolean` - `response_size?: number` - `status_code?: number` - `step?: number` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const log = await client.aiGateway.logs.get('my-gateway', 'id', { account_id: '0d37909e38d3e99c29fa2cd343ac421a', }); console.log(log.id); ``` #### Response ```json { "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_head": "request_head", "request_head_complete": true, "request_size": 0, "request_type": "request_type", "response_content_type": "response_content_type", "response_head": "response_head", "response_head_complete": true, "response_size": 0, "status_code": 0, "step": 0 }, "success": true } ``` ## Patch Gateway Log `client.aiGateway.logs.edit(stringgatewayId, stringid, LogEditParamsparams, RequestOptionsoptions?): LogEditResponse` **patch** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}` Updates metadata for an AI Gateway log entry. ### Parameters - `gatewayId: string` gateway id - `id: string` - `params: LogEditParams` - `account_id: string` Path param - `feedback?: number | null` Body param - `metadata?: Record | null` Body param - `string` - `number` - `boolean` - `score?: number | null` Body param ### Returns - `LogEditResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiGateway.logs.edit('my-gateway', 'id', { account_id: '0d37909e38d3e99c29fa2cd343ac421a', }); console.log(response); ``` #### Response ```json { "result": {}, "success": true } ``` ## Delete Gateway Logs `client.aiGateway.logs.delete(stringgatewayId, LogDeleteParamsparams, RequestOptionsoptions?): LogDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs` Delete Gateway Logs ### Parameters - `gatewayId: string` gateway id - `params: LogDeleteParams` - `account_id: string` Path param - `filters?: Array` Query param - `key: "id" | "created_at" | "request_content_type" | 20 more` - `"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` - `"eq"` - `"neq"` - `"contains"` - `"lt"` - `"gt"` - `value: Array` - `string | null` - `number` - `boolean` - `limit?: number` Query param - `order_by?: "created_at" | "provider" | "model" | 8 more` Query param - `"created_at"` - `"provider"` - `"model"` - `"model_type"` - `"success"` - `"cached"` - `"cost"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `order_by_direction?: "asc" | "desc"` Query param - `"asc"` - `"desc"` ### Returns - `LogDeleteResponse` - `success: boolean` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const log = await client.aiGateway.logs.delete('my-gateway', { account_id: '0d37909e38d3e99c29fa2cd343ac421a', }); console.log(log.success); ``` #### Response ```json { "success": true } ``` ## Get Gateway Log Request `client.aiGateway.logs.request(stringgatewayId, stringid, LogRequestParamsparams, RequestOptionsoptions?): LogRequestResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request` Retrieves the original request payload for an AI Gateway log entry. ### Parameters - `gatewayId: string` gateway id - `id: string` - `params: LogRequestParams` - `account_id: string` ### Returns - `LogRequestResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiGateway.logs.request('my-gateway', 'id', { account_id: '0d37909e38d3e99c29fa2cd343ac421a', }); console.log(response); ``` #### Response ```json {} ``` ## Get Gateway Log Response `client.aiGateway.logs.response(stringgatewayId, stringid, LogResponseParamsparams, RequestOptionsoptions?): LogResponseResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response` Retrieves the response payload for an AI Gateway log entry. ### Parameters - `gatewayId: string` gateway id - `id: string` - `params: LogResponseParams` - `account_id: string` ### Returns - `LogResponseResponse = unknown` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.aiGateway.logs.response('my-gateway', 'id', { account_id: '0d37909e38d3e99c29fa2cd343ac421a', }); console.log(response); ``` #### Response ```json {} ``` ## Domain Types ### Log List Response - `LogListResponse` - `id: string` - `cached: boolean` - `created_at: string` - `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` ### Log Get Response - `LogGetResponse` - `id: string` - `cached: boolean` - `created_at: string` - `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_head?: string` - `request_head_complete?: boolean` - `request_size?: number` - `request_type?: string` - `response_content_type?: string` - `response_head?: string` - `response_head_complete?: boolean` - `response_size?: number` - `status_code?: number` - `step?: number` ### Log Edit Response - `LogEditResponse = unknown` ### Log Delete Response - `LogDeleteResponse` - `success: boolean` ### Log Request Response - `LogRequestResponse = unknown` ### Log Response Response - `LogResponseResponse = unknown`