Skip to content
Start here

Get Gateway Log Detail

ai_gateway.logs.get(strid, LogGetParams**kwargs) -> LogGetResponse
GET/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}

Retrieves detailed information for a specific AI Gateway log entry.

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
id: str
ReturnsExpand Collapse
class LogGetResponse:
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_head: Optional[str]
request_head_complete: Optional[bool]
request_size: Optional[int]
request_type: Optional[str]
response_content_type: Optional[str]
response_head: Optional[str]
response_head_complete: Optional[bool]
response_size: Optional[int]
status_code: Optional[int]
step: Optional[int]

Get Gateway Log Detail

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
log = client.ai_gateway.logs.get(
    id="id",
    account_id="0d37909e38d3e99c29fa2cd343ac421a",
    gateway_id="my-gateway",
)
print(log.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_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
}
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_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
}