---
title: "Set the AI policy for a connection"
method: PUT
path: "/v1/ai/policies/{connection}"
tags: ["AI"]
---

# Set the AI policy for a connection

`PUT /v1/ai/policies/{connection}`

## Request

- Base URL: `https://www.chatrail.dev`
- URL: `https://www.chatrail.dev/v1/ai/policies/{connection}`
- Auth: HTTP bearer

Draft or auto mode, with token, rate and monthly cost ceilings. Absent policy means AI is off for that connection.

## Path parameters

- `connection` string, required

## Request body

- object
  - `credential_source` 'byok' | 'managed'
  - `credential_id` string, uuid, nullable
  - `enabled` boolean, required
  - `mode` 'draft' | 'auto', required
  - `model` string
  - `system_instruction` string, required
  - `max_context_bytes` integer
  - `max_output_tokens` integer
  - `include_history` boolean
  - `humanize` boolean
  - `human_takeover_minutes` integer
  - `reply_delay_seconds` integer
  - `group_replies` 'off' | 'addressed' | 'all'
  - `monthly_cost_limit_micros` integer, nullable
  - `input_cost_micros_per_million` integer
  - `output_cost_micros_per_million` integer

## Response `200`

The policy.

## Other responses

- `402`: AI is not on this plan.

---

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