---
title: "Set AI Gateway configuration"
method: PUT
path: "/v1/ai-gateway"
---

# Set AI Gateway configuration

`PUT /v1/ai-gateway`

## Request

- Base URL: `https://api.runbear.io`
- URL: `https://api.runbear.io/v1/ai-gateway`
- Auth: HTTP bearer

Create or update the organization-level Cloudflare AI Gateway configuration. While `enabled` is true here, Anthropic and OpenAI agents route through this gateway unless an agent overrides the default with its own `aiGateway` field on create or update agent — pass `enabled: false` there to opt a single agent out.

## Request body

- object
  - `cloudflareAccountId` string, required: Cloudflare account ID
  - `gatewayName` string, required: Cloudflare AI Gateway name
  - `cfApiToken` string, required: Cloudflare API token with AI Gateway permissions
  - `enabled` boolean, required: Whether to actively route requests through the gateway

## Response `200`

Default Response

- AiGatewayConfig
  - `cloudflareAccountId` string, required: Cloudflare account ID
  - `gatewayName` string, required: Cloudflare AI Gateway name
  - `enabled` boolean, required: Whether routing through the gateway is active

## Other responses

- `403`: The organization is not entitled to AI Gateway; `code` is `forbidden_ai_gateway_not_permitted`. Terminal until the plan changes.

---

[API](https://skmtc.dev/runbear/apis/runbear-api.md) - [All operations](https://skmtc.dev/runbear/apis/runbear-api/llms.txt) - [OpenAPI document](https://skmtc.dev/runbear/apis/runbear-api/revisions/c6a9c3066a5a?raw)
