Ana içeriğe geç

Update AI Routing

Endpoint

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

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",
"clientModelPresentBehavior": "OVERWRITE",
"clientModelAbsentBehavior": "KEEP_ABSENT",
"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)
clientModelPresentBehaviorstringWhat to do when the client's request body already has a model field — USE_CLIENT, OVERWRITE, or ERROR. Default OVERWRITE when unset
clientModelAbsentBehaviorstringWhat to do when the client's request body has no model field — KEEP_ABSENT, ADD_ROUTING_MODEL, or ERROR. Default KEEP_ABSENT when unset
streamingbooleanEnable SSE streaming responses. Default false
timeoutSecondsintegerPer-call LLM timeout in seconds. Default 60
USE_CLIENT is not honored on Azure OpenAI

Gemini, Vertex, and Bedrock carry the effective model in the URL path, which the gateway builds itself — attribution and the model that answers always agree. An Azure OpenAI deployment endpoint pins the deployment in the endpoint the operator configured, so the request body's model field cannot change which model actually answers — it could only shift the attribution (the catalog entry that rate limits, quota, semantic cache, cost calculation, and traffic logs are booked against) to a value the client supplies. Apinizer therefore does not apply clientModelPresentBehavior: "USE_CLIENT" on an AZURE_OPENAI provider: the effective model stays the configured modelId and no catalog check is run against the client's value. The upstream request carries the configured modelId in its body, exactly as it does under OVERWRITE — the client's value only stops being a reason to reject the request. OVERWRITE, ERROR, and clientModelAbsentBehavior are unaffected.

A failover entry without its own modelId inherits the configured modelId above, not the client's model, and re-evaluates USE_CLIENT against its own provider's catalog.

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
400A USD budget covering the proxy would meter a model that has no input price in the model catalog (error key aiQuota.usdBudgetModelPriceMissing, parameters modelCount / models). Raised when the body's aiAppBudget or the routing changed; an unchanged re-save is not re-checked. Add the price to the model catalog or use a token-based limit.
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
}'