Update group AI policy
Viewing v2, the current version
curl --request PATCH \ --url https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model_defaults": { "flux-2-dev": { "inference_steps": { "value": 30 } } }, "models": { "flux-2-pro": { "value": false } }}'import requests
url = "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy"
payload = { "model_defaults": { "flux-2-dev": { "inference_steps": { "value": 30 } } }, "models": { "flux-2-pro": { "value": False } }}headers = { "Authorization": "Bearer <token>", "Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())const url = 'https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model_defaults":{"flux-2-dev":{"inference_steps":{"value":30}}},"models":{"flux-2-pro":{"value":false}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy"
payload := strings.NewReader("{\n \"model_defaults\": {\n \"flux-2-dev\": {\n \"inference_steps\": {\n \"value\": 30\n }\n }\n },\n \"models\": {\n \"flux-2-pro\": {\n \"value\": false\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "PATCH", CURLOPT_POSTFIELDS => json_encode([ 'model_defaults' => [ 'flux-2-dev' => [ 'inference_steps' => [ 'value' => 30 ] ] ], 'models' => [ 'flux-2-pro' => [ 'value' => null ] ] ]), CURLOPT_HTTPHEADER => [ "Authorization: Bearer <token>", "Content-Type: application/json" ],]);
$response = curl_exec($curl);$err = curl_error($curl);
curl_close($curl);
if ($err) { echo "cURL Error #:" . $err;} else { echo $response;}OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{\n \"model_defaults\": {\n \"flux-2-dev\": {\n \"inference_steps\": {\n \"value\": 30\n }\n }\n },\n \"models\": {\n \"flux-2-pro\": {\n \"value\": false\n }\n }\n}");Request request = new Request.Builder() .url("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy") .patch(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();require 'uri'require 'net/http'
url = URI("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = true
request = Net::HTTP::Patch.new(url)request["Authorization"] = 'Bearer <token>'request["Content-Type"] = 'application/json'request.body = "{\n \"model_defaults\": {\n \"flux-2-dev\": {\n \"inference_steps\": {\n \"value\": 30\n }\n }\n },\n \"models\": {\n \"flux-2-pro\": {\n \"value\": false\n }\n }\n}"
response = http.request(request)puts response.read_bodyvar client = new RestClient("https://api.app.layer.ai/api/v2/workspaces/:workspace_id/groups/:group_id/ai-policy");var request = new RestRequest("", Method.Patch);request.AddHeader("Authorization", "Bearer <token>");request.AddHeader("Content-Type", "application/json");request.AddParameter("application/json", "{\n \"model_defaults\": {\n \"flux-2-dev\": {\n \"inference_steps\": {\n \"value\": 30\n }\n }\n },\n \"models\": {\n \"flux-2-pro\": {\n \"value\": false\n }\n }\n}", ParameterType.RequestBody);var response = client.Execute(request);Unchanged from v1. This endpoint’s documented request and response schemas are identical in v1 and v2 — change the
/v1prefix to/v2. Schema equality is not a promise about behavior, so keep your usual smoke tests.
Change the controls the group sets itself as a JSON merge patch: a control or key you name is set, one you name as null is removed so it is inherited again, and anything you leave out stays as it is. A setting is replaced whole, value and lock. Setting most controls here is an Enterprise feature. Requires workspace settings admin. Usage caps take workspace billing admin as well.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”ID of the workspace that owns the resource.
ID of the workspace that owns the resource.
ID of the group.
ID of the group.
Header Parameters
Section titled “Header Parameters”Opaque key making a retry of this request return the first result. A 2xx response is replayed for 24 hours with Idempotent-Replayed: true. A 4xx releases the key. A 5xx, or a request still running, holds the key for 120 seconds, during which a retry gets 409; after that a retry executes again. The key covers the method, path, query, and byte-identical body it was first used with; reusing it for a different request is rejected with 422. Protection is best effort: if the key store is unavailable, or a record is lost early, a retry can execute again even after an earlier 409. See the Idempotency section of the API description.
Request Bodyrequired
Section titled “Request Bodyrequired”A change to the AI controls one scope sets, as a JSON merge patch (RFC 7396) of its policy.
A control or key the patch names is set; one it names as null is removed, so the scope inherits it again; anything it leaves out stays as it is. A setting is one value: naming it replaces both its value and its lock. Guardrails and output scoring belong to the services that own them, and naming one is refused. Usage caps take workspace billing admin as well.
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
A cap on the Creative Units each member may spend in a workspace over one period, as a policy sets it.
object
What a cap does once its member has used all of it.
Example
{ "model_defaults": { "flux-2-dev": { "inference_steps": { "value": 30 } } }, "models": { "flux-2-pro": { "value": false } }}Responses
Section titled “ Responses ”Successful Response
object
What the policy is attached to.
object
What an AI policy is attached to, from least to most specific.
What the scope sets itself, each value as {value, locked}. Anything absent is inherited.
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
A cap on the Creative Units each member may spend in a workspace over one period, as a policy sets it.
object
What a cap does once its member has used all of it.
What the scope inherits from the less specific scopes, each value as {value, source}. A value with no source is the platform default.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
object
object
A cap on the Creative Units each member may spend in a workspace over one period, as a policy sets it.
object
What a cap does once its member has used all of it.
The policy a resolved value comes from.
object
Where a policy is attached: a workspace, or a project, group or member inside one.
object
What an AI policy is attached to, from least to most specific.
When the policy was last written; null if it sets nothing.
Who last wrote the policy, when known.
Example
{ "scope": { "kind": "workspace" }, "policy": { "agent_enabled": { "locked": false }, "agents": {}, "agent_confirm_above_cu": { "locked": false }, "modalities": {}, "new_models_enabled": { "locked": false }, "models": {}, "model_defaults": {}, "guardrails": {}, "output_scoring": {}, "nsfw_tolerance": { "locked": false }, "reference_set_sharing_enabled": { "locked": false }, "workflow_sharing_enabled": { "locked": false }, "invisible_watermark_enabled": { "locked": false }, "usage_caps": {} }, "inherited": { "agent_enabled": { "source": { "scope": { "kind": "workspace" } } }, "agents": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } }, "agent_confirm_above_cu": { "source": { "scope": { "kind": "workspace" } } }, "modalities": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } }, "new_models_enabled": { "source": { "scope": { "kind": "workspace" } } }, "models": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } }, "model_defaults": { "additionalProperty": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } } }, "guardrails": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } }, "output_scoring": { "additionalProperty": { "source": { "scope": { "kind": "workspace" } } } }, "nsfw_tolerance": { "value": 5 }, "reference_set_sharing_enabled": { "value": true }, "workflow_sharing_enabled": { "value": true }, "invisible_watermark_enabled": { "value": false }, "usage_caps": {} }}Unauthenticated — missing or invalid Bearer token.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}Forbidden — insufficient permissions, or the access token lacks the scope the operation requires.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}Resource not found.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}The outcome of the request with this Idempotency-Key is not known yet: it is still running, or it failed without a stored response. Retry after the number of seconds in Retry-After.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}Invalid input parameters, or an Idempotency-Key reused for a different request.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}Rate limited — retry after the number of seconds in Retry-After.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}Internal server error.
object
Machine-readable error code: the last path segment of type.
The request field the error is about, by its name in the body (on a tool run, in input), on the errors that name one: so far the value a Layer tool fixes on an INFERENCE_TOOL_PIN_MISMATCH, and the scale factor on an INFERENCE_TOOL_UPSCALE_COPIES_SOURCE. Absent otherwise, even when detail names a field.
Example
{ "type": "https://api.layer.ai/errors/ERROR_CODE", "title": "Error Title", "status": 400, "detail": "Human-readable description.", "error_code": "ERROR_CODE", "field": "tileability"}