Ana içeriğe geç

Update AI Routing

Endpoint

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/ai-routing/
uyarı

This endpoint returns HTTP 400 for API proxies whose type is not AIaiRouting can only be set on AI proxies. To create a new AI proxy in one call, use Create AI API Proxy — this endpoint only updates the routing config of a proxy that already exists.

Authentication

Requires a Personal API Access Token.

Permission: API_MANAGEMENT × MANAGE (consistent with the mcp-routing and a2a-routing endpoints).

Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer {token}Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAI API Proxy name

Request Body

The body is the full AiRouting object — it replaces the proxy's current AI routing configuration.

Full JSON Body Example

{
"llmProviderRefName": "openai-prod",
"modelId": "gpt-4o-mini",
"streaming": false,
"timeoutSeconds": 60,
"connectTimeoutSeconds": 10,
"streamTimeoutSeconds": 120,
"retryCount": 0,
"failoverStrategy": "SEQUENTIAL",
"providerFailoverChain": [],
"conditionalRoutes": [],
"primaryPool": [],
"enumAiRoutingAlgorithm": "ROUND_ROBIN",
"circuitBreakerEnabled": false,
"proxyEnabled": false,
"mTLSSettings": null,
"blockAnonymousRequests": false,
"anonymousBudget": null
}

Field Reference — Primary Routing

FieldTypeDescription
llmProviderRefstringPrimary LLM provider connection id. Use llmProviderRefName instead when referencing by name
llmProviderRefNamestringName-based sidecar for llmProviderRef. Resolved to an id within the project when present
modelIdstringPrimary catalog model id (for example gpt-4o-mini, deepseek-chat)
streamingbooleanEnable SSE streaming responses. Default false
timeoutSecondsintegerPer-call LLM timeout in seconds. Default 60

Field Reference — Timeouts, Limits, and Retry

FieldTypeDescription
connectTimeoutSecondsintegerConnection establish timeout (DNS + TCP + TLS). Default 10
streamTimeoutSecondsintegerSSE stream idle timeout. Default 120
maxResponseByteslongMaximum response body size; null or ≤ 0 = unlimited
maxChunkslongMaximum SSE chunks; null or ≤ 0 = unlimited
retryCountintegerPre-stream connection retry count for transient errors. Default 0
retryDelayTypestringNO_DELAY, FIXED, EXPONENTIAL_BACKOFF
retryFixedDelayMsintegerFixed retry delay in ms. Default 500
retryInitialDelayMsintegerInitial backoff delay in ms. Default 500
retryMaxDelayMsintegerMaximum backoff delay in ms. Default 10000
retryBackoffMultipliernumberBackoff multiplier. Default 2.0

Field Reference — Failover and Load Balancing

FieldTypeDescription
failoverStrategystringSEQUENTIAL, ROUND_ROBIN, or CONDITIONAL
providerFailoverChainarrayOrdered failover entries — each with llmProviderRef/llmProviderRefName, optional modelId, credentialRef, timeoutMs, orderIndex, displayName
failoverStatusCodeListarray[integer]HTTP status codes eligible for failover. Empty = default 5xx/408/429
failoverRetryCountintegerInner retry count per failover entry. Default 1
conditionalLatencyThresholdMsintegerFor CONDITIONAL strategy — proactive latency threshold in ms
primaryPoolarrayN-primary load-balancing pool — each entry with llmProviderRef/llmProviderRefName, optional modelId, weight, displayName
enumAiRoutingAlgorithmstringROUND_ROBIN, WEIGHTED, RANDOM, LEAST_COST, PREFIX_AFFINITY, LRU
leastCostOutputRationumberOutput-to-input cost weight for LEAST_COST. Default 0.25
affinityKeyHeaderstringHeader for PREFIX_AFFINITY affinity key. Default session_id
affinityLoadFactornumberBounded-load factor for PREFIX_AFFINITY. Default 1.25

Field Reference — Conditional Routes

FieldTypeDescription
conditionalRoutesarrayOrdered route variants — each with name, condition, optional llmProviderRef/llmProviderRefName, modelId, semanticUtterances, semanticThreshold
semanticEmbeddingProviderRefstringEmbedding provider id for semantic route matching
semanticEmbeddingModelIdstringEmbedding model id. Default text-embedding-3-small

Field Reference — Circuit Breaker

FieldTypeDescription
circuitBreakerEnabledbooleanEnable circuit breaker. Default false
errorWindowintegerError observation window in seconds. Default 10
errorThresholdValueintegerError threshold. Default 1
enumErrorThresholdTypestringCOUNT or PERCENTAGE
sleepWindowintegerOpen-circuit sleep window in seconds. Default 10
halfOpenEnabledbooleanEnable half-open probe. Default false

Field Reference — Outbound Proxy, mTLS, and SSL

FieldTypeDescription
proxyEnabledbooleanRoute outbound LLM calls through an HTTP proxy
proxyHoststringOutbound proxy host
proxyPortintegerOutbound proxy port
proxyAuthorizationNeededbooleanProxy requires authentication
proxyUsernamestringProxy username
proxyPasswordstringProxy password (encrypted at rest; blank preserves existing on update)
mTLSSettingsobjectClient mTLS settings for provider connections
disableSslValidationbooleanAccept self-signed certificates (lab only)

Field Reference — Anonymous Traffic and Trace

FieldTypeDescription
blockAnonymousRequestsbooleanReject unauthenticated requests with HTTP 401. Default false
anonymousBudgetobjectToken/cost budget override for anonymous requests
traceModestringAI trace mode override — METRIC, FULL, etc.
enableAiTracebooleanAI trace lifecycle flag
aiTraceEnvironmentNamestringEnvironment where AI trace was started
aiTraceCustomQueryIdstringCustomQuery filter id for AI trace
aiTraceMaxDurationSecondsintegerMaximum AI trace duration. Default 300

Behavior

  • llmProviderRefName (and name sidecars on failover entries, primary pool entries, and conditional routes) are resolved to connection ids within the project before save.
  • Every environment the proxy is currently deployed to is marked redeploy required — redeploy to activate the new configuration.
  • AI proxies do not use the classic routing object. Settings endpoints that target classic routing (circuit breaker, connection, mTLS, addresses, …) return HTTP 400 for AI proxies and point here instead.

Response

Success Response (200 OK)

{
"result": {
"success": true
}
}

Error Responses

StatusCondition
400Blank apiProxyName, empty body, proxy not found, or proxy is not an AI proxy
401Invalid or missing token
500Unexpected server error

cURL Example

curl -X PUT \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/my-ai-proxy/ai-routing/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"llmProviderRefName": "openai-prod",
"modelId": "gpt-4o-mini",
"streaming": false
}'