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)
  • USD budget price check: when defaultBudget (or defaultAnonymousBudget) carries a USD limit (monthlyBudgetUsd, usdPerHour or usdPerDay, including inside modelBudgets / providerBudgets) and any AI proxy in the installation routes to a known model that has no input price in the model catalog, the whole update is rejected with 400 Bad Request (error key aiQuota.usdBudgetModelPriceMissing). Nothing is saved — the non-budget fields in the same request are not applied either. Add the missing pricePerMillionInput to the model catalog, or use a token-based limit. Token-only budgets are not checked.

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": "This budget sets a USD limit, but 2 model(s) it would price have no input price in the model catalog, so their cost cannot be measured and the USD limit would never apply to them: gpt-4o-mini, llama3. Set pricePerMillionInput on these models (Model Catalog, or the LLM provider's supported model row), or use a token-based limit instead."
}
{
"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

  • No license gate: This endpoint does not check the AI_GATEWAY license module. The API layer of Apinizer applies no module gate at all, so an installation whose license does not name AI Gateway can read and write the global AI Gateway settings through it. System-admin authority remains the only gate. The AI Gateway screens in the Manager UI remain hidden without the module.
  • 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