Ana içeriğe geç

Update AI Gateway Settings

Endpoint

PUT /apiops/settings/ai-gateway

Authentication

Requires a Personal API Access Token with admin privileges.

Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer {token}Yes
Content-Typeapplication/jsonYes

Path Parameters

None.

Query Parameters

None.

Request Body

This is a partial update: only the top-level fields you send (non-null) are applied — every omitted field preserves its currently stored value.

Full JSON Body Example

{
"defaultConnectTimeoutSeconds": 15,
"defaultStreamTimeoutSeconds": 300,
"defaultRetryCount": 2,
"maxAiRequestBodyBytes": 20971520,
"maxAiBinaryRequestBodyBytes": 52428800,
"maxAiBinaryResponseBodyBytes": 52428800,
"maxToolTurns": 8,
"defaultBudget": {
"enabled": true,
"monthlyBudgetUsd": 500.00,
"hardCapPercent": 100,
"overflowAction": "BLOCK"
}
}

Request Body Fields

FieldTypeRequiredDefaultDescription
defaultConnectTimeoutSecondsintegerNo10Connect timeout to the LLM provider, in seconds. Must be between 1 and 300.
defaultStreamTimeoutSecondsintegerNo120Overall SSE stream timeout, in seconds. Must be between 1 and 3600.
defaultRetryCountintegerNo0Retry attempts on provider error. Must be between 0 and 10.
maxAiRequestBodyBytesintegerNo10485760Max JSON AI request body size in bytes. Must be between 1 and 1073741824 (1 GB).
maxAiBinaryRequestBodyBytesintegerNo26214400Max binary/multipart AI request body size in bytes. Must be between 1 and 1073741824 (1 GB).
maxAiBinaryResponseBodyBytesintegerNo26214400Max binary AI response body size in bytes. Must be between 1 and 1073741824 (1 GB).
maxToolTurnsintegerNo5Ceiling on chained agentic tool-call turns. Must not exceed 100; a value <= 0 disables the loop (passthrough).
defaultBudgetobjectNobudget disabledPlatform-wide default token/cost budget object (see field table below). Sent whole — its nested lists follow null-keeps / empty-wipes semantics.

defaultBudget Object Fields

FieldTypeDescription
enabledbooleanWhether the default budget is enforced
tokensPerHourintegerHourly token cap; if set, must be >= 1 (null = no limit)
tokensPerMinuteintegerPer-minute token cap; if set, must be >= 1 (null = no limit)
tokensPerDayintegerDaily token cap; if set, must be >= 1 (null = no limit)
tokensPerMonthintegerMonthly token cap; if set, must be >= 1 (null = no limit)
monthlyBudgetUsdnumberMonthly USD cost cap; if set, must be > 0 (null = no limit)
usdPerHournumberHourly USD cost cap; if set, must be > 0 (null = no limit)
usdPerDaynumberDaily USD cost cap; if set, must be > 0 (null = no limit)
softCapPercentsarray[integer]Soft-cap warning thresholds, each in [0, 100]
hardCapPercentintegerHard-cap threshold in [1, 100]
overflowActionstringAction on overflow: BLOCK, FAILOVER, ALERT_ONLY, CHEAPER_MODEL
cheaperModelIdstringFallback model id used when overflowAction = CHEAPER_MODEL
modelBudgetsarrayPer-model budget overrides (max 50). null keeps existing, empty list wipes all model-level limits.
providerBudgetsarrayPer-provider budget overrides (max 50). null keeps existing, empty list wipes all provider-level limits.

Notes

  • The request body must not be empty
  • Only non-null top-level fields are applied; all others are preserved
  • Field bounds are enforced identically to the manager UI settings screen (backward-compat invariant)

Response

Success Response (200 OK)

Returns the full settings document after the update (same shape as the read endpoint), with effective values.

{
"status": "SUCCESS",
"resultList": [
{
"defaultBudget": {
"enabled": true,
"tokensPerHour": null,
"tokensPerMinute": null,
"tokensPerDay": null,
"tokensPerMonth": null,
"monthlyBudgetUsd": 500.00,
"usdPerHour": null,
"usdPerDay": null,
"softCapPercents": [],
"hardCapPercent": 100,
"overflowAction": "BLOCK",
"cheaperModelId": null,
"modelBudgets": [],
"providerBudgets": []
},
"defaultConnectTimeoutSeconds": 15,
"defaultStreamTimeoutSeconds": 300,
"defaultRetryCount": 2,
"maxAiRequestBodyBytes": 20971520,
"maxAiBinaryRequestBodyBytes": 52428800,
"maxAiBinaryResponseBodyBytes": 52428800,
"maxToolTurns": 8
}
],
"resultCount": 1
}

Response Fields

FieldTypeDescription
statusstringResponse status: SUCCESS or FAILURE
resultListarrayList containing the single updated settings object
resultCountintegerAlways 1 for this singleton resource

Error Response (400 Bad Request)

Returned on validation failure, an empty body, or when the caller lacks the ADMIN role.

{
"status": "FAILURE",
"resultMessage": "defaultConnectTimeoutSeconds must be between 1 and 300!"
}

Other possible messages:

{
"status": "FAILURE",
"resultMessage": "Request body can not be empty!"
}
{
"status": "FAILURE",
"resultMessage": "maxToolTurns must not exceed 100!"
}
{
"status": "FAILURE",
"resultMessage": "Unauthorized! Only users with ADMIN role can access this resource!"
}

Error Response (401 Unauthorized)

{
"status": "FAILURE",
"resultMessage": "Token is not valid!"
}

cURL Example

curl -X PUT \
"https://demo.apinizer.com/apiops/settings/ai-gateway" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"defaultConnectTimeoutSeconds": 15,
"defaultStreamTimeoutSeconds": 300,
"defaultRetryCount": 2,
"maxToolTurns": 8,
"defaultBudget": {
"enabled": true,
"monthlyBudgetUsd": 500.00,
"hardCapPercent": 100,
"overflowAction": "BLOCK"
}
}'

Notes and Warnings

  • Admin Only:
    • Only sysAdmin users (or users with the ADMIN role) can update AI Gateway settings
    • A project-scoped AI_DEVELOPMENT token is not sufficient
  • Partial Update:
    • Only non-null top-level fields are applied; omitted fields keep their stored value
    • To leave a field unchanged, simply omit it from the body
  • Validation Bounds:
    • Bounds mirror the manager UI settings screen so both entry points enforce the same limits
    • maxToolTurns <= 0 is a valid signal that disables the agentic tool-call loop
  • Singleton:
    • A single document governs the entire platform; if none exists it is created on first update
  • No Secret Fields:
    • This settings document carries no secret (@SecretData) fields, so nothing is masked