# AI Gateway ## List Gateways `ai_gateway.list(AIGatewayListParams**kwargs) -> SyncV4PagePaginationArray[AIGatewayListResponse]` **get** `/accounts/{account_id}/ai-gateway/gateways` Lists all AI Gateway evaluator types configured for the account. ### Parameters - `account_id: str` - `page: Optional[int]` - `per_page: Optional[int]` - `search: Optional[str]` Search by id ### Returns - `class AIGatewayListResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Example ```python 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.list( account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "my-gateway", "cache_invalidate_on_update": true, "cache_ttl": 0, "collect_logs": true, "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "rate_limiting_interval": 0, "rate_limiting_limit": 0, "authentication": true, "dlp": { "action": "BLOCK", "enabled": true, "profiles": [ "string" ] }, "guardrails": { "prompt": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" }, "response": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" } }, "is_default": true, "log_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "content_type": "json" } ], "rate_limiting_technique": "fixed", "retry_backoff": "constant", "retry_delay": 0, "retry_max_attempts": 1, "store_id": "store_id", "stripe": { "authorization": "authorization", "usage_events": [ { "payload": "payload" } ] }, "workers_ai_billing_mode": "postpaid", "zdr": true } ], "success": true } ``` ## Fetch a Gateway `ai_gateway.get(strid, AIGatewayGetParams**kwargs) -> AIGatewayGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{id}` Retrieves details for a specific AI Gateway dataset. ### Parameters - `account_id: str` - `id: str` gateway id ### Returns - `class AIGatewayGetResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) ai_gateway = client.ai_gateway.get( id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) print(ai_gateway.id) ``` #### Response ```json { "result": { "id": "my-gateway", "cache_invalidate_on_update": true, "cache_ttl": 0, "collect_logs": true, "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "rate_limiting_interval": 0, "rate_limiting_limit": 0, "authentication": true, "dlp": { "action": "BLOCK", "enabled": true, "profiles": [ "string" ] }, "guardrails": { "prompt": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" }, "response": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" } }, "is_default": true, "log_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "content_type": "json" } ], "rate_limiting_technique": "fixed", "retry_backoff": "constant", "retry_delay": 0, "retry_max_attempts": 1, "store_id": "store_id", "stripe": { "authorization": "authorization", "usage_events": [ { "payload": "payload" } ] }, "workers_ai_billing_mode": "postpaid", "zdr": true }, "success": true } ``` ## Create a new Gateway `ai_gateway.create(AIGatewayCreateParams**kwargs) -> AIGatewayCreateResponse` **post** `/accounts/{account_id}/ai-gateway/gateways` Creates a new AI Gateway. ### Parameters - `account_id: str` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Returns - `class AIGatewayCreateResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) ai_gateway = client.ai_gateway.create( account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", id="my-gateway", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, ) print(ai_gateway.id) ``` #### Response ```json { "result": { "id": "my-gateway", "cache_invalidate_on_update": true, "cache_ttl": 0, "collect_logs": true, "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "rate_limiting_interval": 0, "rate_limiting_limit": 0, "authentication": true, "dlp": { "action": "BLOCK", "enabled": true, "profiles": [ "string" ] }, "guardrails": { "prompt": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" }, "response": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" } }, "is_default": true, "log_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "content_type": "json" } ], "rate_limiting_technique": "fixed", "retry_backoff": "constant", "retry_delay": 0, "retry_max_attempts": 1, "store_id": "store_id", "stripe": { "authorization": "authorization", "usage_events": [ { "payload": "payload" } ] }, "workers_ai_billing_mode": "postpaid", "zdr": true }, "success": true } ``` ## Update a Gateway `ai_gateway.update(strid, AIGatewayUpdateParams**kwargs) -> AIGatewayUpdateResponse` **put** `/accounts/{account_id}/ai-gateway/gateways/{id}` Updates an existing AI Gateway dataset. ### Parameters - `account_id: str` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: Sequence[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: Iterable[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: Sequence[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[Iterable[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: Iterable[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Returns - `class AIGatewayUpdateResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) ai_gateway = client.ai_gateway.update( id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", cache_invalidate_on_update=True, cache_ttl=0, collect_logs=True, rate_limiting_interval=0, rate_limiting_limit=0, ) print(ai_gateway.id) ``` #### Response ```json { "result": { "id": "my-gateway", "cache_invalidate_on_update": true, "cache_ttl": 0, "collect_logs": true, "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "rate_limiting_interval": 0, "rate_limiting_limit": 0, "authentication": true, "dlp": { "action": "BLOCK", "enabled": true, "profiles": [ "string" ] }, "guardrails": { "prompt": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" }, "response": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" } }, "is_default": true, "log_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "content_type": "json" } ], "rate_limiting_technique": "fixed", "retry_backoff": "constant", "retry_delay": 0, "retry_max_attempts": 1, "store_id": "store_id", "stripe": { "authorization": "authorization", "usage_events": [ { "payload": "payload" } ] }, "workers_ai_billing_mode": "postpaid", "zdr": true }, "success": true } ``` ## Delete a Gateway `ai_gateway.delete(strid, AIGatewayDeleteParams**kwargs) -> AIGatewayDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{id}` Deletes an AI Gateway dataset. ### Parameters - `account_id: str` - `id: str` gateway id ### Returns - `class AIGatewayDeleteResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) ai_gateway = client.ai_gateway.delete( id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) print(ai_gateway.id) ``` #### Response ```json { "result": { "id": "my-gateway", "cache_invalidate_on_update": true, "cache_ttl": 0, "collect_logs": true, "created_at": "2019-12-27T18:11:19.117Z", "modified_at": "2019-12-27T18:11:19.117Z", "rate_limiting_interval": 0, "rate_limiting_limit": 0, "authentication": true, "dlp": { "action": "BLOCK", "enabled": true, "profiles": [ "string" ] }, "guardrails": { "prompt": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" }, "response": { "P1": "FLAG", "S1": "FLAG", "S10": "FLAG", "S11": "FLAG", "S12": "FLAG", "S13": "FLAG", "S2": "FLAG", "S3": "FLAG", "S4": "FLAG", "S5": "FLAG", "S6": "FLAG", "S7": "FLAG", "S8": "FLAG", "S9": "FLAG" } }, "is_default": true, "log_management": 10000, "log_management_strategy": "STOP_INSERTING", "logpush": true, "logpush_public_key": "xxxxxxxxxxxxxxxx", "otel": [ { "authorization": "authorization", "headers": { "foo": "string" }, "url": "https://example.com", "content_type": "json" } ], "rate_limiting_technique": "fixed", "retry_backoff": "constant", "retry_delay": 0, "retry_max_attempts": 1, "store_id": "store_id", "stripe": { "authorization": "authorization", "usage_events": [ { "payload": "payload" } ] }, "workers_ai_billing_mode": "postpaid", "zdr": true }, "success": true } ``` ## Domain Types ### AI Gateway List Response - `class AIGatewayListResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### AI Gateway Get Response - `class AIGatewayGetResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### AI Gateway Create Response - `class AIGatewayCreateResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### AI Gateway Update Response - `class AIGatewayUpdateResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` ### AI Gateway Delete Response - `class AIGatewayDeleteResponse: …` - `id: str` gateway id - `cache_invalidate_on_update: bool` - `cache_ttl: Optional[int]` - `collect_logs: bool` - `created_at: datetime` - `modified_at: datetime` - `rate_limiting_interval: Optional[int]` - `rate_limiting_limit: Optional[int]` - `authentication: Optional[bool]` - `dlp: Optional[DLP]` - `class DLPUnionMember0: …` - `action: Literal["BLOCK", "FLAG"]` - `"BLOCK"` - `"FLAG"` - `enabled: bool` - `profiles: List[str]` - `class DLPUnionMember1: …` - `enabled: bool` - `policies: List[DLPUnionMember1Policy]` - `id: str` - `action: Literal["FLAG", "BLOCK"]` - `"FLAG"` - `"BLOCK"` - `check: List[Literal["REQUEST", "RESPONSE"]]` - `"REQUEST"` - `"RESPONSE"` - `enabled: bool` - `profiles: List[str]` - `guardrails: Optional[Guardrails]` - `prompt: GuardrailsPrompt` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `response: GuardrailsResponse` - `p1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s1: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s10: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s11: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s12: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s13: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s2: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s3: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s4: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s5: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s6: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s7: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s8: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `s9: Optional[Literal["FLAG", "BLOCK"]]` - `"FLAG"` - `"BLOCK"` - `is_default: Optional[bool]` - `log_management: Optional[int]` - `log_management_strategy: Optional[Literal["STOP_INSERTING", "DELETE_OLDEST"]]` - `"STOP_INSERTING"` - `"DELETE_OLDEST"` - `logpush: Optional[bool]` - `logpush_public_key: Optional[str]` - `otel: Optional[List[Otel]]` - `authorization: str` - `headers: Dict[str, str]` - `url: str` - `content_type: Optional[Literal["json", "protobuf"]]` - `"json"` - `"protobuf"` - `rate_limiting_technique: Optional[Literal["fixed", "sliding"]]` - `"fixed"` - `"sliding"` - `retry_backoff: Optional[Literal["constant", "linear", "exponential"]]` Backoff strategy for retry delays - `"constant"` - `"linear"` - `"exponential"` - `retry_delay: Optional[int]` Delay between retry attempts in milliseconds (0-5000) - `retry_max_attempts: Optional[int]` Maximum number of retry attempts for failed requests (1-5) - `store_id: Optional[str]` - `stripe: Optional[Stripe]` - `authorization: str` - `usage_events: List[StripeUsageEvent]` - `payload: str` - `workers_ai_billing_mode: Optional[Literal["postpaid"]]` Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported. - `"postpaid"` - `zdr: Optional[bool]` # Evaluation Types ## List Evaluators `ai_gateway.evaluation_types.list(EvaluationTypeListParams**kwargs) -> SyncV4PagePaginationArray[EvaluationTypeListResponse]` **get** `/accounts/{account_id}/ai-gateway/evaluation-types` List Evaluators ### Parameters - `account_id: str` - `order_by: Optional[str]` - `order_by_direction: Optional[Literal["asc", "desc"]]` - `"asc"` - `"desc"` - `page: Optional[int]` - `per_page: Optional[int]` ### Returns - `class EvaluationTypeListResponse: …` - `id: str` - `created_at: datetime` - `description: str` - `enable: bool` - `mandatory: bool` - `modified_at: datetime` - `name: str` - `type: str` ### Example ```python 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.evaluation_types.list( account_id="0d37909e38d3e99c29fa2cd343ac421a", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "description": "description", "enable": true, "mandatory": true, "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "type": "type" } ], "result_info": { "count": 0, "page": 0, "per_page": 0, "total_count": 0 }, "success": true } ``` ## Domain Types ### Evaluation Type List Response - `class EvaluationTypeListResponse: …` - `id: str` - `created_at: datetime` - `description: str` - `enable: bool` - `mandatory: bool` - `modified_at: datetime` - `name: str` - `type: str` # Logs ## 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 ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `cached: Optional[bool]` - `direction: Optional[Literal["asc", "desc"]]` - `"asc"` - `"desc"` - `end_date: Optional[Union[str, datetime]]` - `feedback: Optional[Literal[0, 1]]` - `0` - `1` - `filters: Optional[Iterable[Filter]]` - `key: Literal["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: Literal["eq", "neq", "contains", 2 more]` - `"eq"` - `"neq"` - `"contains"` - `"lt"` - `"gt"` - `value: Sequence[Union[Optional[str], float, bool]]` - `Optional[str]` - `float` - `bool` - `max_cost: Optional[float]` - `max_duration: Optional[float]` - `max_tokens_in: Optional[float]` - `max_tokens_out: Optional[float]` - `max_total_tokens: Optional[float]` - `meta_info: Optional[bool]` - `min_cost: Optional[float]` - `min_duration: Optional[float]` - `min_tokens_in: Optional[float]` - `min_tokens_out: Optional[float]` - `min_total_tokens: Optional[float]` - `model: Optional[str]` - `model_type: Optional[str]` - `order_by: Optional[Literal["created_at", "provider", "model", 3 more]]` - `"created_at"` - `"provider"` - `"model"` - `"model_type"` - `"success"` - `"cached"` - `order_by_direction: Optional[Literal["asc", "desc"]]` - `"asc"` - `"desc"` - `page: Optional[int]` - `per_page: Optional[int]` - `provider: Optional[str]` - `request_content_type: Optional[str]` - `response_content_type: Optional[str]` - `search: Optional[str]` - `start_date: Optional[Union[str, datetime]]` - `success: Optional[bool]` ### Returns - `class LogListResponse: …` - `id: str` - `cached: bool` - `created_at: datetime` - `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]` ### Example ```python 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) ``` #### 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 `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. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `class LogGetResponse: …` - `id: str` - `cached: bool` - `created_at: datetime` - `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]` ### Example ```python 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) ``` #### 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 `ai_gateway.logs.edit(strid, LogEditParams**kwargs) -> object` **patch** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}` Updates metadata for an AI Gateway log entry. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` - `feedback: Optional[float]` - `metadata: Optional[Dict[str, Union[str, float, bool]]]` - `str` - `float` - `bool` - `score: Optional[float]` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.logs.edit( id="id", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="my-gateway", ) print(response) ``` #### Response ```json { "result": {}, "success": true } ``` ## Delete Gateway Logs `ai_gateway.logs.delete(strgateway_id, LogDeleteParams**kwargs) -> LogDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs` Delete Gateway Logs ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `filters: Optional[Iterable[Filter]]` - `key: Literal["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: Literal["eq", "neq", "contains", 2 more]` - `"eq"` - `"neq"` - `"contains"` - `"lt"` - `"gt"` - `value: Sequence[Union[Optional[str], float, bool]]` - `Optional[str]` - `float` - `bool` - `limit: Optional[int]` - `order_by: Optional[Literal["created_at", "provider", "model", 8 more]]` - `"created_at"` - `"provider"` - `"model"` - `"model_type"` - `"success"` - `"cached"` - `"cost"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `order_by_direction: Optional[Literal["asc", "desc"]]` - `"asc"` - `"desc"` ### Returns - `class LogDeleteResponse: …` - `success: bool` ### Example ```python 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.delete( gateway_id="my-gateway", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) print(log.success) ``` #### Response ```json { "success": true } ``` ## Get Gateway Log Request `ai_gateway.logs.request(strid, LogRequestParams**kwargs) -> object` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/request` Retrieves the original request payload for an AI Gateway log entry. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.logs.request( id="id", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="my-gateway", ) print(response) ``` #### Response ```json {} ``` ## Get Gateway Log Response `ai_gateway.logs.response(strid, LogResponseParams**kwargs) -> object` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/logs/{id}/response` Retrieves the response payload for an AI Gateway log entry. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.logs.response( id="id", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="my-gateway", ) print(response) ``` #### Response ```json {} ``` ## Domain Types ### Log List Response - `class LogListResponse: …` - `id: str` - `cached: bool` - `created_at: datetime` - `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]` ### Log Get Response - `class LogGetResponse: …` - `id: str` - `cached: bool` - `created_at: datetime` - `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]` ### Log Delete Response - `class LogDeleteResponse: …` - `success: bool` # Datasets ## List Datasets `ai_gateway.datasets.list(strgateway_id, DatasetListParams**kwargs) -> SyncV4PagePaginationArray[DatasetListResponse]` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets` Lists all AI Gateway evaluator types configured for the account. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `enable: Optional[bool]` - `name: Optional[str]` - `page: Optional[int]` - `per_page: Optional[int]` - `search: Optional[str]` Search by id, name, filters ### Returns - `class DatasetListResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Example ```python 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.datasets.list( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" } ], "success": true } ``` ## Fetch a Dataset `ai_gateway.datasets.get(strid, DatasetGetParams**kwargs) -> DatasetGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}` Retrieves details for a specific AI Gateway dataset. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `class DatasetGetResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dataset = client.ai_gateway.datasets.get( id="id", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", gateway_id="my-gateway", ) print(dataset.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## Create a new Dataset `ai_gateway.datasets.create(strgateway_id, DatasetCreateParams**kwargs) -> DatasetCreateResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets` Creates a new AI Gateway. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `enable: bool` - `filters: Iterable[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: Sequence[Union[str, float, bool]]` - `str` - `float` - `bool` - `name: str` ### Returns - `class DatasetCreateResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dataset = client.ai_gateway.datasets.create( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", enable=True, filters=[{ "key": "created_at", "operator": "eq", "value": ["string"], }], name="name", ) print(dataset.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## Update a Dataset `ai_gateway.datasets.update(strid, DatasetUpdateParams**kwargs) -> DatasetUpdateResponse` **put** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}` Updates an existing AI Gateway dataset. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` - `enable: bool` - `filters: Iterable[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: Sequence[Union[str, float, bool]]` - `str` - `float` - `bool` - `name: str` ### Returns - `class DatasetUpdateResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dataset = client.ai_gateway.datasets.update( id="id", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", gateway_id="my-gateway", enable=True, filters=[{ "key": "created_at", "operator": "eq", "value": ["string"], }], name="name", ) print(dataset.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## Delete a Dataset `ai_gateway.datasets.delete(strid, DatasetDeleteParams**kwargs) -> DatasetDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/datasets/{id}` Deletes an AI Gateway dataset. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `class DatasetDeleteResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dataset = client.ai_gateway.datasets.delete( id="id", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", gateway_id="my-gateway", ) print(dataset.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## Domain Types ### Dataset List Response - `class DatasetListResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Dataset Get Response - `class DatasetGetResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Dataset Create Response - `class DatasetCreateResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Dataset Update Response - `class DatasetUpdateResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` ### Dataset Delete Response - `class DatasetDeleteResponse: …` - `id: str` - `created_at: datetime` - `enable: bool` - `filters: List[Filter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` # Evaluations ## List Evaluations `ai_gateway.evaluations.list(strgateway_id, EvaluationListParams**kwargs) -> SyncV4PagePaginationArray[EvaluationListResponse]` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations` Lists all AI Gateway evaluator types configured for the account. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `name: Optional[str]` - `page: Optional[int]` - `per_page: Optional[int]` - `processed: Optional[bool]` - `search: Optional[str]` Search by id, name ### Returns - `class EvaluationListResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Example ```python 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.evaluations.list( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "datasets": [ { "id": "id", "account_id": "account_id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "processed": true, "results": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "evaluation_id": "evaluation_id", "evaluation_type_id": "evaluation_type_id", "modified_at": "2019-12-27T18:11:19.117Z", "result": "result", "status": 0, "status_description": "status_description", "total_logs": 0 } ], "total_logs": 0 } ], "success": true } ``` ## Fetch a Evaluation `ai_gateway.evaluations.get(strid, EvaluationGetParams**kwargs) -> EvaluationGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}` Retrieves details for a specific AI Gateway dataset. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `class EvaluationGetResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) evaluation = client.ai_gateway.evaluations.get( id="id", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", gateway_id="my-gateway", ) print(evaluation.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "datasets": [ { "id": "id", "account_id": "account_id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "processed": true, "results": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "evaluation_id": "evaluation_id", "evaluation_type_id": "evaluation_type_id", "modified_at": "2019-12-27T18:11:19.117Z", "result": "result", "status": 0, "status_description": "status_description", "total_logs": 0 } ], "total_logs": 0 }, "success": true } ``` ## Create a new Evaluation `ai_gateway.evaluations.create(strgateway_id, EvaluationCreateParams**kwargs) -> EvaluationCreateResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations` Creates a new AI Gateway. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `dataset_ids: Sequence[str]` - `evaluation_type_ids: Sequence[str]` - `name: str` ### Returns - `class EvaluationCreateResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) evaluation = client.ai_gateway.evaluations.create( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", dataset_ids=["string"], evaluation_type_ids=["string"], name="name", ) print(evaluation.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "datasets": [ { "id": "id", "account_id": "account_id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "processed": true, "results": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "evaluation_id": "evaluation_id", "evaluation_type_id": "evaluation_type_id", "modified_at": "2019-12-27T18:11:19.117Z", "result": "result", "status": 0, "status_description": "status_description", "total_logs": 0 } ], "total_logs": 0 }, "success": true } ``` ## Delete a Evaluation `ai_gateway.evaluations.delete(strid, EvaluationDeleteParams**kwargs) -> EvaluationDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/evaluations/{id}` Deletes an AI Gateway dataset. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `id: str` ### Returns - `class EvaluationDeleteResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) evaluation = client.ai_gateway.evaluations.delete( id="id", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", gateway_id="my-gateway", ) print(evaluation.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "datasets": [ { "id": "id", "account_id": "account_id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "enable": true, "filters": [ { "key": "created_at", "operator": "eq", "value": [ "string" ] } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" } ], "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "processed": true, "results": [ { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "evaluation_id": "evaluation_id", "evaluation_type_id": "evaluation_type_id", "modified_at": "2019-12-27T18:11:19.117Z", "result": "result", "status": 0, "status_description": "status_description", "total_logs": 0 } ], "total_logs": 0 }, "success": true } ``` ## Domain Types ### Evaluation List Response - `class EvaluationListResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Evaluation Get Response - `class EvaluationGetResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Evaluation Create Response - `class EvaluationCreateResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` ### Evaluation Delete Response - `class EvaluationDeleteResponse: …` - `id: str` - `created_at: datetime` - `datasets: List[Dataset]` - `id: str` - `account_id: str` - `account_tag: str` - `created_at: datetime` - `enable: bool` - `filters: List[DatasetFilter]` - `key: Literal["created_at", "request_content_type", "response_content_type", 10 more]` - `"created_at"` - `"request_content_type"` - `"response_content_type"` - `"success"` - `"cached"` - `"provider"` - `"model"` - `"cost"` - `"tokens"` - `"tokens_in"` - `"tokens_out"` - `"duration"` - `"feedback"` - `operator: Literal["eq", "contains", "lt", "gt"]` - `"eq"` - `"contains"` - `"lt"` - `"gt"` - `value: List[Union[str, float, bool]]` - `str` - `float` - `bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `gateway_id: str` gateway id - `modified_at: datetime` - `name: str` - `processed: bool` - `results: List[Result]` - `id: str` - `created_at: datetime` - `evaluation_id: str` - `evaluation_type_id: str` - `modified_at: datetime` - `result: str` - `status: float` - `status_description: str` - `total_logs: float` - `total_logs: float` # Dynamic Routing ## List all AI Gateway Dynamic Routes. `ai_gateway.dynamic_routing.list(strgateway_id, DynamicRoutingListParams**kwargs) -> DynamicRoutingListResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes` List all AI Gateway Dynamic Routes. ### Parameters - `account_id: str` - `gateway_id: str` ### Returns - `class DynamicRoutingListResponse: …` - `data: Data` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `routes: List[DataRoute]` - `id: str` - `account_tag: str` - `created_at: datetime` - `deployment: DataRouteDeployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[DataRouteElement]` - `class DataRouteElementUnionMember0: …` - `id: str` - `outputs: DataRouteElementUnionMember0Outputs` - `next: DataRouteElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class DataRouteElementUnionMember1: …` - `id: str` - `outputs: DataRouteElementUnionMember1Outputs` - `false: DataRouteElementUnionMember1OutputsFalse_` - `element_id: str` - `true: DataRouteElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: DataRouteElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class DataRouteElementUnionMember2: …` - `id: str` - `outputs: Dict[str, DataRouteElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class DataRouteElementUnionMember3: …` - `id: str` - `outputs: DataRouteElementUnionMember3Outputs` - `fallback: DataRouteElementUnionMember3OutputsFallback` - `element_id: str` - `success: DataRouteElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: DataRouteElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class DataRouteElementUnionMember4: …` - `id: str` - `outputs: DataRouteElementUnionMember4Outputs` - `fallback: DataRouteElementUnionMember4OutputsFallback` - `element_id: str` - `success: DataRouteElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: DataRouteElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class DataRouteElementUnionMember5: …` - `id: str` - `outputs: Dict[str, DataRouteElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: DataRouteVersion` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dynamic_routings = client.ai_gateway.dynamic_routing.list( gateway_id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", ) print(dynamic_routings.data) ``` #### Response ```json { "data": { "order_by": "order_by", "order_by_direction": "order_by_direction", "page": 0, "per_page": 0, "routes": [ { "id": "id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "deployment": { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" }, "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version": { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } } ] }, "success": true } ``` ## Get an AI Gateway Dynamic Route. `ai_gateway.dynamic_routing.get(strid, DynamicRoutingGetParams**kwargs) -> DynamicRoutingGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}` Get an AI Gateway Dynamic Route. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` ### Returns - `class DynamicRoutingGetResponse: …` - `id: str` - `created_at: datetime` - `deployment: Deployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: Version` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dynamic_routing = client.ai_gateway.dynamic_routing.get( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", ) print(dynamic_routing.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "deployment": { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" }, "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version": { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } }, "success": true } ``` ## Create a new AI Gateway Dynamic Route. `ai_gateway.dynamic_routing.create(strgateway_id, DynamicRoutingCreateParams**kwargs) -> DynamicRoutingCreateResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes` Create a new AI Gateway Dynamic Route. ### Parameters - `account_id: str` - `gateway_id: str` - `elements: Iterable[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `name: str` ### Returns - `class DynamicRoutingCreateResponse: …` - `id: str` - `created_at: datetime` - `deployment: Deployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: Version` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dynamic_routing = client.ai_gateway.dynamic_routing.create( gateway_id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", elements=[{ "id": "id", "outputs": { "next": { "element_id": "elementId" } }, "type": "start", }], name="name", ) print(dynamic_routing.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "deployment": { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" }, "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version": { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } }, "success": true } ``` ## Update an AI Gateway Dynamic Route. `ai_gateway.dynamic_routing.update(strid, DynamicRoutingUpdateParams**kwargs) -> DynamicRoutingUpdateResponse` **patch** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}` Update an AI Gateway Dynamic Route. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` - `name: str` ### Returns - `class DynamicRoutingUpdateResponse: …` - `route: Route` - `id: str` - `account_tag: str` - `created_at: datetime` - `deployment: RouteDeployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[RouteElement]` - `class RouteElementUnionMember0: …` - `id: str` - `outputs: RouteElementUnionMember0Outputs` - `next: RouteElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class RouteElementUnionMember1: …` - `id: str` - `outputs: RouteElementUnionMember1Outputs` - `false: RouteElementUnionMember1OutputsFalse_` - `element_id: str` - `true: RouteElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: RouteElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class RouteElementUnionMember2: …` - `id: str` - `outputs: Dict[str, RouteElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class RouteElementUnionMember3: …` - `id: str` - `outputs: RouteElementUnionMember3Outputs` - `fallback: RouteElementUnionMember3OutputsFallback` - `element_id: str` - `success: RouteElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: RouteElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class RouteElementUnionMember4: …` - `id: str` - `outputs: RouteElementUnionMember4Outputs` - `fallback: RouteElementUnionMember4OutputsFallback` - `element_id: str` - `success: RouteElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: RouteElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class RouteElementUnionMember5: …` - `id: str` - `outputs: Dict[str, RouteElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: RouteVersion` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dynamic_routing = client.ai_gateway.dynamic_routing.update( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", name="Route Name", ) print(dynamic_routing.route) ``` #### Response ```json { "route": { "id": "id", "account_tag": "account_tag", "created_at": "2019-12-27T18:11:19.117Z", "deployment": { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" }, "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version": { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } }, "success": true } ``` ## Delete an AI Gateway Dynamic Route. `ai_gateway.dynamic_routing.delete(strid, DynamicRoutingDeleteParams**kwargs) -> DynamicRoutingDeleteResponse` **delete** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}` Delete an AI Gateway Dynamic Route. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` ### Returns - `class DynamicRoutingDeleteResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) dynamic_routing = client.ai_gateway.dynamic_routing.delete( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", ) print(dynamic_routing.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## List all AI Gateway Dynamic Route Deployments. `ai_gateway.dynamic_routing.list_deployments(strid, DynamicRoutingListDeploymentsParams**kwargs) -> DynamicRoutingListDeploymentsResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments` List all AI Gateway Dynamic Route Deployments. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` ### Returns - `class DynamicRoutingListDeploymentsResponse: …` - `data: Data` - `deployments: List[DataDeployment]` - `created_at: str` - `deployment_id: str` - `version_id: str` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `success: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.dynamic_routing.list_deployments( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", ) print(response.data) ``` #### Response ```json { "data": { "deployments": [ { "created_at": "created_at", "deployment_id": "deployment_id", "version_id": "version_id" } ], "order_by": "order_by", "order_by_direction": "order_by_direction", "page": 0, "per_page": 0 }, "success": true } ``` ## Create a new AI Gateway Dynamic Route Deployment. `ai_gateway.dynamic_routing.create_deployment(strid, DynamicRoutingCreateDeploymentParams**kwargs) -> DynamicRoutingCreateDeploymentResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/deployments` Create a new AI Gateway Dynamic Route Deployment. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` - `version_id: str` ### Returns - `class DynamicRoutingCreateDeploymentResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.dynamic_routing.create_deployment( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", version_id="54442216", ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## List all AI Gateway Dynamic Route Versions. `ai_gateway.dynamic_routing.list_versions(strid, DynamicRoutingListVersionsParams**kwargs) -> DynamicRoutingListVersionsResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions` List all AI Gateway Dynamic Route Versions. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` ### Returns - `class DynamicRoutingListVersionsResponse: …` - `data: Data` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `versions: List[DataVersion]` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.dynamic_routing.list_versions( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", ) print(response.data) ``` #### Response ```json { "data": { "order_by": "order_by", "order_by_direction": "order_by_direction", "page": 0, "per_page": 0, "versions": [ { "active": "true", "created_at": "created_at", "data": "data", "version_id": "version_id" } ] }, "success": true } ``` ## Create a new AI Gateway Dynamic Route Version. `ai_gateway.dynamic_routing.create_version(strid, DynamicRoutingCreateVersionParams**kwargs) -> DynamicRoutingCreateVersionResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions` Create a new AI Gateway Dynamic Route Version. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` - `elements: Iterable[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` ### Returns - `class DynamicRoutingCreateVersionResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.dynamic_routing.create_version( id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", elements=[{ "id": "id", "outputs": { "next": { "element_id": "elementId" } }, "type": "start", }], ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "created_at": "2019-12-27T18:11:19.117Z", "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name" }, "success": true } ``` ## Get an AI Gateway Dynamic Route Version. `ai_gateway.dynamic_routing.get_version(strversion_id, DynamicRoutingGetVersionParams**kwargs) -> DynamicRoutingGetVersionResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/routes/{id}/versions/{version_id}` Get an AI Gateway Dynamic Route Version. ### Parameters - `account_id: str` - `gateway_id: str` - `id: str` - `version_id: str` ### Returns - `class DynamicRoutingGetVersionResponse: …` - `id: str` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version_id: str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.dynamic_routing.get_version( version_id="54442216", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="54442216", id="54442216", ) print(response.id) ``` #### Response ```json { "result": { "id": "id", "active": "true", "created_at": "created_at", "data": "data", "elements": [ { "id": "id", "outputs": { "next": { "elementId": "elementId" } }, "type": "start" } ], "gateway_id": "gateway_id", "modified_at": "2019-12-27T18:11:19.117Z", "name": "name", "version_id": "version_id" }, "success": true } ``` ## Domain Types ### Dynamic Routing List Response - `class DynamicRoutingListResponse: …` - `data: Data` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `routes: List[DataRoute]` - `id: str` - `account_tag: str` - `created_at: datetime` - `deployment: DataRouteDeployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[DataRouteElement]` - `class DataRouteElementUnionMember0: …` - `id: str` - `outputs: DataRouteElementUnionMember0Outputs` - `next: DataRouteElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class DataRouteElementUnionMember1: …` - `id: str` - `outputs: DataRouteElementUnionMember1Outputs` - `false: DataRouteElementUnionMember1OutputsFalse_` - `element_id: str` - `true: DataRouteElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: DataRouteElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class DataRouteElementUnionMember2: …` - `id: str` - `outputs: Dict[str, DataRouteElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class DataRouteElementUnionMember3: …` - `id: str` - `outputs: DataRouteElementUnionMember3Outputs` - `fallback: DataRouteElementUnionMember3OutputsFallback` - `element_id: str` - `success: DataRouteElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: DataRouteElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class DataRouteElementUnionMember4: …` - `id: str` - `outputs: DataRouteElementUnionMember4Outputs` - `fallback: DataRouteElementUnionMember4OutputsFallback` - `element_id: str` - `success: DataRouteElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: DataRouteElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class DataRouteElementUnionMember5: …` - `id: str` - `outputs: Dict[str, DataRouteElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: DataRouteVersion` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Dynamic Routing Get Response - `class DynamicRoutingGetResponse: …` - `id: str` - `created_at: datetime` - `deployment: Deployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: Version` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` ### Dynamic Routing Create Response - `class DynamicRoutingCreateResponse: …` - `id: str` - `created_at: datetime` - `deployment: Deployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: Version` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` ### Dynamic Routing Update Response - `class DynamicRoutingUpdateResponse: …` - `route: Route` - `id: str` - `account_tag: str` - `created_at: datetime` - `deployment: RouteDeployment` - `created_at: str` - `deployment_id: str` - `version_id: str` - `elements: List[RouteElement]` - `class RouteElementUnionMember0: …` - `id: str` - `outputs: RouteElementUnionMember0Outputs` - `next: RouteElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class RouteElementUnionMember1: …` - `id: str` - `outputs: RouteElementUnionMember1Outputs` - `false: RouteElementUnionMember1OutputsFalse_` - `element_id: str` - `true: RouteElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: RouteElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class RouteElementUnionMember2: …` - `id: str` - `outputs: Dict[str, RouteElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class RouteElementUnionMember3: …` - `id: str` - `outputs: RouteElementUnionMember3Outputs` - `fallback: RouteElementUnionMember3OutputsFallback` - `element_id: str` - `success: RouteElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: RouteElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class RouteElementUnionMember4: …` - `id: str` - `outputs: RouteElementUnionMember4Outputs` - `fallback: RouteElementUnionMember4OutputsFallback` - `element_id: str` - `success: RouteElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: RouteElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class RouteElementUnionMember5: …` - `id: str` - `outputs: Dict[str, RouteElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version: RouteVersion` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Dynamic Routing Delete Response - `class DynamicRoutingDeleteResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Dynamic Routing List Deployments Response - `class DynamicRoutingListDeploymentsResponse: …` - `data: Data` - `deployments: List[DataDeployment]` - `created_at: str` - `deployment_id: str` - `version_id: str` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `success: bool` ### Dynamic Routing Create Deployment Response - `class DynamicRoutingCreateDeploymentResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Dynamic Routing List Versions Response - `class DynamicRoutingListVersionsResponse: …` - `data: Data` - `order_by: str` - `order_by_direction: str` - `page: float` - `per_page: float` - `versions: List[DataVersion]` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `version_id: str` - `success: bool` ### Dynamic Routing Create Version Response - `class DynamicRoutingCreateVersionResponse: …` - `id: str` - `created_at: datetime` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` ### Dynamic Routing Get Version Response - `class DynamicRoutingGetVersionResponse: …` - `id: str` - `active: Literal["true", "false"]` - `"true"` - `"false"` - `created_at: str` - `data: str` - `elements: List[Element]` - `class ElementUnionMember0: …` - `id: str` - `outputs: ElementUnionMember0Outputs` - `next: ElementUnionMember0OutputsNext` - `element_id: str` - `type: Literal["start"]` - `"start"` - `class ElementUnionMember1: …` - `id: str` - `outputs: ElementUnionMember1Outputs` - `false: ElementUnionMember1OutputsFalse_` - `element_id: str` - `true: ElementUnionMember1OutputsTrue_` - `element_id: str` - `properties: ElementUnionMember1Properties` - `conditions: Optional[object]` - `type: Literal["conditional"]` - `"conditional"` - `class ElementUnionMember2: …` - `id: str` - `outputs: Dict[str, ElementUnionMember2Outputs]` - `element_id: str` - `type: Literal["percentage"]` - `"percentage"` - `class ElementUnionMember3: …` - `id: str` - `outputs: ElementUnionMember3Outputs` - `fallback: ElementUnionMember3OutputsFallback` - `element_id: str` - `success: ElementUnionMember3OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember3Properties` - `key: str` - `limit: float` - `limit_type: Literal["count", "cost"]` - `"count"` - `"cost"` - `window: float` - `type: Literal["rate"]` - `"rate"` - `class ElementUnionMember4: …` - `id: str` - `outputs: ElementUnionMember4Outputs` - `fallback: ElementUnionMember4OutputsFallback` - `element_id: str` - `success: ElementUnionMember4OutputsSuccess` - `element_id: str` - `properties: ElementUnionMember4Properties` - `model: str` - `provider: str` - `retries: float` - `timeout: float` - `type: Literal["model"]` - `"model"` - `class ElementUnionMember5: …` - `id: str` - `outputs: Dict[str, ElementUnionMember5Outputs]` - `element_id: str` - `type: Literal["end"]` - `"end"` - `gateway_id: str` - `modified_at: datetime` - `name: str` - `version_id: str` # Provider Configs ## List Provider Configs `ai_gateway.provider_configs.list(strgateway_id, ProviderConfigListParams**kwargs) -> SyncV4PagePaginationArray[ProviderConfigListResponse]` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs` Lists all AI Gateway evaluator types configured for the account. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `page: Optional[int]` - `per_page: Optional[int]` ### Returns - `class ProviderConfigListResponse: …` - `id: str` - `alias: str` - `default_config: bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `provider_slug: str` - `secret_id: str` - `secret_preview: str` - `rate_limit: Optional[float]` - `rate_limit_period: Optional[float]` ### Example ```python 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.provider_configs.list( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", ) page = page.result[0] print(page.id) ``` #### Response ```json { "result": [ { "id": "id", "alias": "alias", "default_config": true, "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "provider_slug": "provider_slug", "secret_id": "secret_id", "secret_preview": "secret_preview", "rate_limit": 0, "rate_limit_period": 0 } ], "success": true } ``` ## Create a new Provider Configs `ai_gateway.provider_configs.create(strgateway_id, ProviderConfigCreateParams**kwargs) -> ProviderConfigCreateResponse` **post** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/provider_configs` Creates a new AI Gateway. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `alias: str` - `default_config: bool` - `provider_slug: str` - `secret: str` - `secret_id: str` - `rate_limit: Optional[float]` - `rate_limit_period: Optional[float]` ### Returns - `class ProviderConfigCreateResponse: …` - `id: str` - `alias: str` - `default_config: bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `provider_slug: str` - `secret_id: str` - `secret_preview: str` - `rate_limit: Optional[float]` - `rate_limit_period: Optional[float]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) provider_config = client.ai_gateway.provider_configs.create( gateway_id="my-gateway", account_id="3ebbcb006d4d46d7bb6a8c7f14676cb0", alias="alias", default_config=True, provider_slug="provider_slug", secret="secret", secret_id="secret_id", ) print(provider_config.id) ``` #### Response ```json { "result": { "id": "id", "alias": "alias", "default_config": true, "gateway_id": "my-gateway", "modified_at": "2019-12-27T18:11:19.117Z", "provider_slug": "provider_slug", "secret_id": "secret_id", "secret_preview": "secret_preview", "rate_limit": 0, "rate_limit_period": 0 }, "success": true } ``` ## Domain Types ### Provider Config List Response - `class ProviderConfigListResponse: …` - `id: str` - `alias: str` - `default_config: bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `provider_slug: str` - `secret_id: str` - `secret_preview: str` - `rate_limit: Optional[float]` - `rate_limit_period: Optional[float]` ### Provider Config Create Response - `class ProviderConfigCreateResponse: …` - `id: str` - `alias: str` - `default_config: bool` - `gateway_id: str` gateway id - `modified_at: datetime` - `provider_slug: str` - `secret_id: str` - `secret_preview: str` - `rate_limit: Optional[float]` - `rate_limit_period: Optional[float]` # URLs ## Get Gateway URL `ai_gateway.urls.get(strprovider, URLGetParams**kwargs) -> URLGetResponse` **get** `/accounts/{account_id}/ai-gateway/gateways/{gateway_id}/url/{provider}` Retrieves the endpoint URL for an AI Gateway. ### Parameters - `account_id: str` - `gateway_id: str` gateway id - `provider: str` ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) url = client.ai_gateway.urls.get( provider="workers-ai", account_id="0d37909e38d3e99c29fa2cd343ac421a", gateway_id="my-gateway", ) print(url) ``` #### Response ```json { "result": "result", "success": true } ``` ## Domain Types ### URL Get Response - `str` # Billing ## Get credit balance `ai_gateway.billing.credit_balance(BillingCreditBalanceParams**kwargs) -> BillingCreditBalanceResponse` **get** `/accounts/{account_id}/ai-gateway/billing/credit-balance` Retrieve the current credit balance, payment method info, and top-up configuration. ### Parameters - `account_id: str` ### Returns - `class BillingCreditBalanceResponse: …` - `balance: float` - `has_default_payment_method: bool` - `payment_method: Optional[PaymentMethod]` - `brand: Optional[str]` - `last4: Optional[str]` - `topup_config: TopupConfig` - `amount: Optional[float]` - `disabled_reason: Optional[str]` - `error: Optional[str]` - `last_failed_at: Optional[float]` - `threshold: Optional[float]` - `first_topup_success: Optional[bool]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.billing.credit_balance( account_id="account_id", ) print(response.balance) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "balance": 0, "has_default_payment_method": true, "payment_method": { "brand": "brand", "last4": "last4" }, "topup_config": { "amount": 0, "disabledReason": "disabledReason", "error": "error", "lastFailedAt": 0, "threshold": 0 }, "first_topup_success": true }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Get usage history `ai_gateway.billing.usage_history(BillingUsageHistoryParams**kwargs) -> BillingUsageHistoryResponse` **get** `/accounts/{account_id}/ai-gateway/billing/usage-history` Retrieve aggregated usage meter event summaries for the given time range. ### Parameters - `account_id: str` - `value_grouping_window: Literal["day", "hour"]` Grouping window for usage data. - `"day"` - `"hour"` - `end_time: Optional[float]` End time as Unix timestamp in milliseconds. - `start_time: Optional[float]` Start time as Unix timestamp in milliseconds. ### Returns - `class BillingUsageHistoryResponse: …` - `history: List[History]` - `id: str` - `aggregated_value: float` - `end_time: float` - `start_time: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.billing.usage_history( account_id="account_id", value_grouping_window="day", ) print(response.history) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "history": [ { "id": "id", "aggregated_value": 0, "end_time": 0, "start_time": 0 } ] }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Get invoice history `ai_gateway.billing.invoice_history(BillingInvoiceHistoryParams**kwargs) -> BillingInvoiceHistoryResponse` **get** `/accounts/{account_id}/ai-gateway/billing/invoice-history` Retrieve a list of past invoices with pagination, optionally filtered by type. ### Parameters - `account_id: str` - `type: Optional[Literal["auto", "all", "manual"]]` Filter invoice type: auto, manual, or all. - `"auto"` - `"all"` - `"manual"` ### Returns - `class BillingInvoiceHistoryResponse: …` - `invoices: List[Invoice]` - `amount_due: float` - `amount_paid: float` - `amount_remaining: float` - `currency: str` - `id: Optional[str]` - `attempt_count: Optional[float]` - `attempted: Optional[bool]` - `auto_advance: Optional[bool]` - `created: Optional[float]` - `created_by: Optional[str]` - `description: Optional[str]` - `invoice_origin: Optional[str]` - `invoice_pdf: Optional[str]` - `status: Optional[str]` - `pagination: Pagination` - `has_more: bool` - `page: float` - `per_page: float` - `total_count: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.billing.invoice_history( account_id="account_id", ) print(response.invoices) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "invoices": [ { "amount_due": 0, "amount_paid": 0, "amount_remaining": 0, "currency": "currency", "id": "id", "attempt_count": 0, "attempted": true, "auto_advance": true, "created": 0, "created_by": "created_by", "description": "description", "invoice_origin": "invoice_origin", "invoice_pdf": "invoice_pdf", "status": "status" } ], "pagination": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Get invoice preview `ai_gateway.billing.invoice_preview(BillingInvoicePreviewParams**kwargs) -> BillingInvoicePreviewResponse` **get** `/accounts/{account_id}/ai-gateway/billing/invoice-preview` Retrieve a preview of the upcoming invoice including line items and tax. ### Parameters - `account_id: str` ### Returns - `class BillingInvoicePreviewResponse: …` - `id: str` - `amount_due: float` - `amount_paid: float` - `amount_remaining: float` - `currency: str` - `invoice_lines: List[InvoiceLine]` - `amount: float` - `currency: str` - `description: Optional[str]` - `period: InvoiceLinePeriod` - `end: float` - `start: float` - `pricing: InvoiceLinePricing` - `unit_amount_decimal: Optional[str]` - `quantity: float` - `pretax_credit_amounts: Optional[List[InvoiceLinePretaxCreditAmount]]` - `amount: float` - `type: str` - `credit_balance_transaction: Optional[str]` - `discount: Optional[str]` - `period_end: float` - `period_start: float` - `status: Literal["draft", "open", "paid", 2 more]` - `"draft"` - `"open"` - `"paid"` - `"uncollectible"` - `"void"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.billing.invoice_preview( account_id="account_id", ) print(response.id) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "id", "amount_due": 0, "amount_paid": 0, "amount_remaining": 0, "currency": "currency", "invoice_lines": [ { "amount": 0, "currency": "currency", "description": "description", "period": { "end": 0, "start": 0 }, "pricing": { "unit_amount_decimal": "unit_amount_decimal" }, "quantity": 0, "pretax_credit_amounts": [ { "amount": 0, "type": "type", "credit_balance_transaction": "credit_balance_transaction", "discount": "discount" } ] } ], "period_end": 0, "period_start": 0, "status": "draft" }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Domain Types ### Billing Credit Balance Response - `class BillingCreditBalanceResponse: …` - `balance: float` - `has_default_payment_method: bool` - `payment_method: Optional[PaymentMethod]` - `brand: Optional[str]` - `last4: Optional[str]` - `topup_config: TopupConfig` - `amount: Optional[float]` - `disabled_reason: Optional[str]` - `error: Optional[str]` - `last_failed_at: Optional[float]` - `threshold: Optional[float]` - `first_topup_success: Optional[bool]` ### Billing Usage History Response - `class BillingUsageHistoryResponse: …` - `history: List[History]` - `id: str` - `aggregated_value: float` - `end_time: float` - `start_time: float` ### Billing Invoice History Response - `class BillingInvoiceHistoryResponse: …` - `invoices: List[Invoice]` - `amount_due: float` - `amount_paid: float` - `amount_remaining: float` - `currency: str` - `id: Optional[str]` - `attempt_count: Optional[float]` - `attempted: Optional[bool]` - `auto_advance: Optional[bool]` - `created: Optional[float]` - `created_by: Optional[str]` - `description: Optional[str]` - `invoice_origin: Optional[str]` - `invoice_pdf: Optional[str]` - `status: Optional[str]` - `pagination: Pagination` - `has_more: bool` - `page: float` - `per_page: float` - `total_count: float` ### Billing Invoice Preview Response - `class BillingInvoicePreviewResponse: …` - `id: str` - `amount_due: float` - `amount_paid: float` - `amount_remaining: float` - `currency: str` - `invoice_lines: List[InvoiceLine]` - `amount: float` - `currency: str` - `description: Optional[str]` - `period: InvoiceLinePeriod` - `end: float` - `start: float` - `pricing: InvoiceLinePricing` - `unit_amount_decimal: Optional[str]` - `quantity: float` - `pretax_credit_amounts: Optional[List[InvoiceLinePretaxCreditAmount]]` - `amount: float` - `type: str` - `credit_balance_transaction: Optional[str]` - `discount: Optional[str]` - `period_end: float` - `period_start: float` - `status: Literal["draft", "open", "paid", 2 more]` - `"draft"` - `"open"` - `"paid"` - `"uncollectible"` - `"void"` # Topup ## Create a top-up `ai_gateway.billing.topup.create(TopupCreateParams**kwargs) -> TopupCreateResponse` **post** `/accounts/{account_id}/ai-gateway/billing/topup` Create a credit top-up via Stripe PaymentIntent for the given account. ### Parameters - `account_id: str` - `amount: int` Top-up amount in cents (min 1000). ### Returns - `class TopupCreateResponse: …` - `client_secret: Optional[str]` Stripe PaymentIntent client secret. - `onboarding: bool` Whether the user was already onboarded. - `payment_intent_id: str` Stripe invoice ID. - `brand: Optional[str]` Card brand (visa, mastercard, etc.). - `last4: Optional[str]` Last 4 digits of card. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) topup = client.ai_gateway.billing.topup.create( account_id="account_id", amount=5000, ) print(topup.payment_intent_id) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "client_secret": "client_secret", "onboarding": true, "payment_intent_id": "payment_intent_id", "brand": "brand", "last4": "last4" }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Check top-up status `ai_gateway.billing.topup.status(TopupStatusParams**kwargs) -> TopupStatusResponse` **post** `/accounts/{account_id}/ai-gateway/billing/topup/status` Get the payment processing status of a top-up by its invoice ID. ### Parameters - `account_id: str` - `payment_intent_id: str` Stripe invoice ID to check status for. ### Returns - `class TopupStatusResponse: …` - `payment_intent_id: str` - `status: Literal["completed", "pending"]` - `"completed"` - `"pending"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.ai_gateway.billing.topup.status( account_id="account_id", payment_intent_id="in_1abc", ) print(response.payment_intent_id) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "payment_intent_id": "payment_intent_id", "status": "completed" }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Domain Types ### Topup Create Response - `class TopupCreateResponse: …` - `client_secret: Optional[str]` Stripe PaymentIntent client secret. - `onboarding: bool` Whether the user was already onboarded. - `payment_intent_id: str` Stripe invoice ID. - `brand: Optional[str]` Card brand (visa, mastercard, etc.). - `last4: Optional[str]` Last 4 digits of card. ### Topup Status Response - `class TopupStatusResponse: …` - `payment_intent_id: str` - `status: Literal["completed", "pending"]` - `"completed"` - `"pending"` # Config ## Get auto top-up configuration `ai_gateway.billing.topup.config.get(ConfigGetParams**kwargs) -> ConfigGetResponse` **get** `/accounts/{account_id}/ai-gateway/billing/topup/config` Retrieve the current auto top-up threshold, amount, and any error state. ### Parameters - `account_id: str` ### Returns - `class ConfigGetResponse: …` - `amount: Optional[float]` - `disabled_reason: Optional[str]` - `error: Optional[str]` - `last_failed_at: Optional[float]` - `threshold: Optional[float]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) config = client.ai_gateway.billing.topup.config.get( account_id="account_id", ) print(config.amount) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "amount": 0, "disabledReason": "disabledReason", "error": "error", "lastFailedAt": 0, "threshold": 0 }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Set auto top-up configuration `ai_gateway.billing.topup.config.create(ConfigCreateParams**kwargs) -> ConfigCreateResponse` **post** `/accounts/{account_id}/ai-gateway/billing/topup/config` Configure auto top-up with a balance threshold and top-up amount. ### Parameters - `account_id: str` - `amount: int` Auto top-up amount in cents (min 1000). - `threshold: int` Balance threshold in cents that triggers auto top-up (min 500). ### Returns - `class ConfigCreateResponse: …` - `amount: float` - `threshold: float` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) config = client.ai_gateway.billing.topup.config.create( account_id="account_id", amount=5000, threshold=500, ) print(config.amount) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "amount": 0, "threshold": 0 }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Delete auto top-up configuration `ai_gateway.billing.topup.config.delete(ConfigDeleteParams**kwargs) -> object` **delete** `/accounts/{account_id}/ai-gateway/billing/topup/config` Remove the auto top-up configuration for the account. ### Parameters - `account_id: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) config = client.ai_gateway.billing.topup.config.delete( account_id="account_id", ) print(config) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": {}, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Domain Types ### Config Get Response - `class ConfigGetResponse: …` - `amount: Optional[float]` - `disabled_reason: Optional[str]` - `error: Optional[str]` - `last_failed_at: Optional[float]` - `threshold: Optional[float]` ### Config Create Response - `class ConfigCreateResponse: …` - `amount: float` - `threshold: float` # Spending Limit ## Get spending limit `ai_gateway.billing.spending_limit.get(SpendingLimitGetParams**kwargs) -> SpendingLimitGetResponse` **get** `/accounts/{account_id}/ai-gateway/billing/spending-limit` Retrieve the current spending limit configuration for the account. ### Parameters - `account_id: str` ### Returns - `class SpendingLimitGetResponse: …` - `config: Config` - `amount: Optional[float]` - `duration: Optional[str]` - `strategy: Optional[str]` - `enabled: bool` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) spending_limit = client.ai_gateway.billing.spending_limit.get( account_id="account_id", ) print(spending_limit.config) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "config": { "amount": 0, "duration": "duration", "strategy": "strategy" }, "enabled": true }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Set spending limit `ai_gateway.billing.spending_limit.create(SpendingLimitCreateParams**kwargs) -> object` **post** `/accounts/{account_id}/ai-gateway/billing/spending-limit` Configure a spending limit with amount, strategy, and duration. ### Parameters - `account_id: str` - `amount: int` Spending limit amount in cents (min 100). - `duration: Literal["daily", "weekly", "monthly"]` Spending limit duration. - `"daily"` - `"weekly"` - `"monthly"` - `strategy: Literal["fixed", "sliding"]` Spending limit strategy. - `"fixed"` - `"sliding"` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) spending_limit = client.ai_gateway.billing.spending_limit.create( account_id="account_id", amount=10000, duration="monthly", strategy="fixed", ) print(spending_limit) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": {}, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Delete spending limit `ai_gateway.billing.spending_limit.delete(SpendingLimitDeleteParams**kwargs) -> object` **delete** `/accounts/{account_id}/ai-gateway/billing/spending-limit` Remove the spending limit for the account. ### Parameters - `account_id: str` ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) spending_limit = client.ai_gateway.billing.spending_limit.delete( account_id="account_id", ) print(spending_limit) ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": {}, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ``` ## Domain Types ### Spending Limit Get Response - `class SpendingLimitGetResponse: …` - `config: Config` - `amount: Optional[float]` - `duration: Optional[str]` - `strategy: Optional[str]` - `enabled: bool`