Skip to content
Start here

List Gateway Logs

client.AIGateway.Logs.List(ctx, gatewayID, params) (*V4PagePaginationArray[LogListResponse], error)
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
AccountID param.Field[string]

Path param

DeprecatedCached param.Field[bool]optional

Query param

DeprecatedDirection param.Field[LogListParamsDirection]optional

Query param

const LogListParamsDirectionAsc LogListParamsDirection = "asc"
const LogListParamsDirectionDesc LogListParamsDirection = "desc"
DeprecatedEndDate param.Field[Time]optional

Query param

formatdate-time
DeprecatedFeedback param.Field[LogListParamsFeedback]optional

Query param

const LogListParamsFeedback0 LogListParamsFeedback = 0
const LogListParamsFeedback1 LogListParamsFeedback = 1
Filters param.Field[[]LogListParamsFilter]optional

Query param

Key LogListParamsFiltersKey
One of the following:
const LogListParamsFiltersKeyID LogListParamsFiltersKey = "id"
const LogListParamsFiltersKeyCreatedAt LogListParamsFiltersKey = "created_at"
const LogListParamsFiltersKeyRequestContentType LogListParamsFiltersKey = "request_content_type"
const LogListParamsFiltersKeyResponseContentType LogListParamsFiltersKey = "response_content_type"
const LogListParamsFiltersKeyRequestType LogListParamsFiltersKey = "request_type"
const LogListParamsFiltersKeySuccess LogListParamsFiltersKey = "success"
const LogListParamsFiltersKeyCached LogListParamsFiltersKey = "cached"
const LogListParamsFiltersKeyProvider LogListParamsFiltersKey = "provider"
const LogListParamsFiltersKeyModel LogListParamsFiltersKey = "model"
const LogListParamsFiltersKeyModelType LogListParamsFiltersKey = "model_type"
const LogListParamsFiltersKeyCost LogListParamsFiltersKey = "cost"
const LogListParamsFiltersKeyTokens LogListParamsFiltersKey = "tokens"
const LogListParamsFiltersKeyTokensIn LogListParamsFiltersKey = "tokens_in"
const LogListParamsFiltersKeyTokensOut LogListParamsFiltersKey = "tokens_out"
const LogListParamsFiltersKeyDuration LogListParamsFiltersKey = "duration"
const LogListParamsFiltersKeyFeedback LogListParamsFiltersKey = "feedback"
const LogListParamsFiltersKeyEventID LogListParamsFiltersKey = "event_id"
const LogListParamsFiltersKeyMetadataKey LogListParamsFiltersKey = "metadata.key"
const LogListParamsFiltersKeyMetadataValue LogListParamsFiltersKey = "metadata.value"
const LogListParamsFiltersKeyAuthentication LogListParamsFiltersKey = "authentication"
const LogListParamsFiltersKeyWholesale LogListParamsFiltersKey = "wholesale"
const LogListParamsFiltersKeyCompatibilityMode LogListParamsFiltersKey = "compatibilityMode"
const LogListParamsFiltersKeyDLPAction LogListParamsFiltersKey = "dlp_action"
Operator LogListParamsFiltersOperator
One of the following:
const LogListParamsFiltersOperatorEq LogListParamsFiltersOperator = "eq"
const LogListParamsFiltersOperatorNeq LogListParamsFiltersOperator = "neq"
const LogListParamsFiltersOperatorContains LogListParamsFiltersOperator = "contains"
const LogListParamsFiltersOperatorLt LogListParamsFiltersOperator = "lt"
const LogListParamsFiltersOperatorGt LogListParamsFiltersOperator = "gt"
Value []LogListParamsFiltersValueUnion
One of the following:
UnionString
UnionFloat
UnionBool
DeprecatedMaxCost param.Field[float64]optional

Query param

DeprecatedMaxDuration param.Field[float64]optional

Query param

DeprecatedMaxTokensIn param.Field[float64]optional

Query param

DeprecatedMaxTokensOut param.Field[float64]optional

Query param

DeprecatedMaxTotalTokens param.Field[float64]optional

Query param

MetaInfo param.Field[bool]optional

Query param

DeprecatedMinCost param.Field[float64]optional

Query param

DeprecatedMinDuration param.Field[float64]optional

Query param

DeprecatedMinTokensIn param.Field[float64]optional

Query param

DeprecatedMinTokensOut param.Field[float64]optional

Query param

DeprecatedMinTotalTokens param.Field[float64]optional

Query param

DeprecatedModel param.Field[string]optional

Query param

DeprecatedModelType param.Field[string]optional

Query param

OrderBy param.Field[LogListParamsOrderBy]optional

Query param

const LogListParamsOrderByCreatedAt LogListParamsOrderBy = "created_at"
const LogListParamsOrderByProvider LogListParamsOrderBy = "provider"
const LogListParamsOrderByModel LogListParamsOrderBy = "model"
const LogListParamsOrderByModelType LogListParamsOrderBy = "model_type"
const LogListParamsOrderBySuccess LogListParamsOrderBy = "success"
const LogListParamsOrderByCached LogListParamsOrderBy = "cached"
OrderByDirection param.Field[LogListParamsOrderByDirection]optional

Query param

const LogListParamsOrderByDirectionAsc LogListParamsOrderByDirection = "asc"
const LogListParamsOrderByDirectionDesc LogListParamsOrderByDirection = "desc"
Page param.Field[int64]optional

Query param

minimum1
PerPage param.Field[int64]optional

Query param

maximum50
minimum1
DeprecatedProvider param.Field[string]optional

Query param

DeprecatedRequestContentType param.Field[string]optional

Query param

DeprecatedResponseContentType param.Field[string]optional

Query param

DeprecatedStartDate param.Field[Time]optional

Query param

formatdate-time
DeprecatedSuccess param.Field[bool]optional

Query param

ReturnsExpand Collapse
type LogListResponse struct{…}
ID string
Cached bool
CreatedAt Time
formatdate-time
Duration int64
Model string
Path string
Provider string
Success bool
TokensIn int64
TokensOut int64
Cost float64optional
CustomCost booloptional
Metadata stringoptional
ModelType stringoptional
RequestContentType stringoptional
RequestType stringoptional
ResponseContentType stringoptional
StatusCode int64optional
Step int64optional

List Gateway Logs

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/ai_gateway"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.AIGateway.Logs.List(
    context.TODO(),
    "my-gateway",
    ai_gateway.LogListParams{
      AccountID: cloudflare.F("0d37909e38d3e99c29fa2cd343ac421a"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "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
}