Create Model
POST /environments/{env_id}/models
POST /environments/{env_id}/modelsInteractive request editor loads with JavaScript.
Authorization
BearerAdminToken Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.
In: header
Path Parameters
Environment ID that scopes the request.
uuidRequest Body
application/json
Model create body. Each model kind accepts the configuration block that matches its runtime behavior.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "$AISIX_CP/environments/$ENV_ID/models" \ -H "Authorization: Bearer $AISIX_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "display_name": "string" }'Created
{
"model": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"env_id": "3f917d0d-4dff-42f3-97c4-6a5455dfe8c2",
"kind": "direct",
"display_name": "string",
"model_name": "string",
"provider_key_id": "f265db88-9bcc-4e5b-add5-bfd9a815465c",
"rate_limit": {
"rps": 1,
"rpm": 1,
"rph": 1,
"rpd": 1,
"tpm": 1,
"tpd": 1,
"concurrency": 1
},
"background_model_check": {
"enabled": true,
"interval_seconds": 5,
"timeout_seconds": 1,
"prompt": "string",
"max_tokens": 1,
"ignore_statuses": [
100
],
"stale_after_seconds": 1
},
"cooldown": {
"enabled": true,
"default_seconds": 0,
"max_seconds": 1,
"honor_retry_after": true,
"trigger_statuses": [
100
],
"trigger_on_timeout": true,
"trigger_on_transport": true
},
"auto_prompt_caching": {
"enabled": true,
"ttl": "5m"
},
"timeout": 0,
"stream_timeout": 0,
"retries": 0,
"allowed_cidrs": [
"string"
],
"routing": {
"strategy": "round_robin",
"targets": [
{
"model_id": "f8ff2fb8-4acc-4e48-bd83-cbdac23e1224",
"weight": 1,
"priority": 0,
"tags": [
"string"
]
}
],
"retries": 0,
"max_fallbacks": 0,
"retry_on_429": true,
"when_all_unavailable": "fail",
"hash_on": [
{
"type": "header",
"name": "string"
}
],
"fallback_on_statuses": [
400
]
},
"ensemble": {
"panel": [
{
"model_id": "f8ff2fb8-4acc-4e48-bd83-cbdac23e1224",
"temperature": 0,
"seed": 0,
"weight": 1
}
],
"judge": {
"model_id": "f8ff2fb8-4acc-4e48-bd83-cbdac23e1224",
"synthesis_prompt": "string"
},
"min_responses": 1,
"timeout_ms": 0
},
"semantic": {
"embedding_model_id": "2959178f-981f-441b-a0b6-cedb1eb6201d",
"default_model_id": "19067d48-f6d4-4d9b-9baf-e795f86d67ff",
"threshold": 0,
"embedding_timeout_ms": 0,
"on_embedding_failure": {
"mode": "default",
"target_model_id": "9bf13660-4617-4413-89cf-6f2a5911177d"
},
"routes": [
{
"name": "string",
"target_model_id": "9bf13660-4617-4413-89cf-6f2a5911177d",
"description": "string",
"examples": [
"string"
],
"threshold": 0
}
]
},
"embedding": {
"dimensions": 1,
"normalize": true
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
},
"warnings": [
{
"code": "field_ignored",
"field": "string",
"min_dp_version": "string",
"affected_dp_count": 0,
"affected_dp_versions": [
"string"
]
}
]
}Request body or parameters failed validation.
{
"error": {
"code": "string",
"message": "string"
}
}Missing or invalid bearer.
{
"error": {
"code": "UNAUTHENTICATED",
"message": "no org context"
}
}Authenticated request is not permitted.
{
"error": {
"code": "CUSTOM_KEY_DISABLED",
"message": "custom API key values are disabled for this organization"
}
}Resource not found.
{
"error": {
"code": "NOT_FOUND",
"message": "provider key not found"
}
}Request conflicts with current resource state.
{
"error": {
"code": "CREDENTIAL_IN_USE",
"message": "models still reference this provider_key"
}
}Complete operation details and schema variants
POST /environments/{env_id}/models
Create Model
Create a model alias in an environment. The AISIX Cloud control plane creates a direct model unless another kind is selected.
Parameters
env_id(path, string, required): Environment ID that scopes the request.
Request body
Content type: application/json
-
kind(string, optional): Model kind to create. New models are direct models unless another kind is selected. -
display_name(string, required): Model alias that callers use in requests. -
model_name(string, optional): Direct model upstream identifier. -
provider_key_id(string, optional): Provider key ID that supplies the upstream credential for direct models. -
rate_limit(object, optional): Per-model rate limit. -
allOf variant 1
-
rate_limit.rps(integer, optional): Requests per second. -
rate_limit.rpm(integer, optional): Requests per minute. -
rate_limit.rph(integer, optional): Requests per hour. -
rate_limit.rpd(integer, optional): Requests per day. -
rate_limit.tpm(integer, optional): Tokens per minute. -
rate_limit.tpd(integer, optional): Tokens per day. -
rate_limit.concurrency(integer, optional): Maximum in-flight requests. -
background_model_check(object, optional): Periodic upstream health probe configuration for direct models. -
background_model_check.enabled(boolean, required): Whether background health checks are active. -
background_model_check.interval_seconds(integer, required): Probe interval in seconds. -
background_model_check.timeout_seconds(integer, required): Probe timeout in seconds. -
background_model_check.prompt(string, required): Prompt sent by the background health probe. -
background_model_check.max_tokens(integer, required): Maximum tokens requested for the probe response. -
background_model_check.ignore_statuses(array, required): Upstream status codes that count as "still healthy" even when returned during a probe (e.g.429,408). -
background_model_check.stale_after_seconds(integer, required): How long an unhealthy probe result is honored before it expires and the model re-enters rotation. The value must be greater than or equal tointerval_seconds. -
cooldown(object, optional): Per-request cooldown settings for direct models. When a target returns a configured error, times out, or has a transport error, the gateway skips it until the cooldown expires. -
cooldown.enabled(boolean, optional): Whether cooldown is active for this model. -
cooldown.default_seconds(integer, optional): Hold duration, in seconds, applied when a cooldown is triggered and no upstreamRetry-Afteris honored. -
cooldown.max_seconds(integer, optional): Upper bound, in seconds, on any single hold. This value caps an honored upstreamRetry-Afterheader. -
cooldown.honor_retry_after(boolean, optional): Whether an upstreamRetry-Afterresponse header can set the hold duration, capped atmax_seconds. -
cooldown.trigger_statuses(array, optional): HTTP status codes that trigger a cooldown. -
cooldown.trigger_on_timeout(boolean, optional): Whether a request timeout triggers a cooldown. -
cooldown.trigger_on_transport(boolean, optional): Whether a transport-level error (connection failure, TLS error) triggers a cooldown. -
auto_prompt_caching(object, optional): Automatic prompt-cache breakpoint injection for normalized requests to direct Anthropic models. When enabled, the gateway adds cache-control markers to/v1/chat/completionsand/v1/responsesrequests that carry none of their own, so callers can receive provider-side prompt-cache discounts without adding markers. The native/v1/messagesroute preserves caller-supplied markers but does not add them automatically. -
auto_prompt_caching.enabled(boolean, optional): Whether automatic prompt-cache injection is active for this model. -
auto_prompt_caching.ttl(string, optional): Cache lifetime for injected breakpoints.5mis written at 1.25x the base input rate and breaks even after one cache read;1his written at 2x and pays off only when the cached prefix is reused across a longer session. -
timeout(integer, optional): Non-streaming request timeout in milliseconds. Accepted on every model kind except ensemble (whose own deadline isensemble.timeout_ms); on a routing model or semantic router it is the group/router-level slot. Unset values inherit that value, then the gateway default;0disables the timeout. -
stream_timeout(integer, optional): Streaming read timeout in milliseconds. Accepted on every model kind except ensemble.0or unset falls back to the group/routerstream_timeout, then totimeout, then to gateway defaults. -
retries(integer, optional): Retry attempts after a retryable upstream failure. Accepted on direct, embedding and semantic models — not ensemble, and a routing model rejects the top-level field (setrouting.retriesinstead). Unset falls back to the group slot (routing.retriesfor a model group, the top-level value for a semantic router), then to the gateway default;0disables retrying for this model. -
allowed_cidrs(array, optional): Client-IP allowlist in CIDR notation for direct and routing models. Empty values allow all client IPs. Requests outside the allowlist receive 403 withcode: ip_restricted. -
routing(object, optional): Virtual-router configuration for routing models. Shape is identical between request and response. -
routing.strategy(string, required): Target-selection strategy, applied within each priority tier (seetargets[].priority).round_robinis smooth WEIGHTED round-robin overtargets[].weight— equal or absent weights degrade to a plain declaration-order cycle.consistent_hashhashes a per-request key (seehash_on) over a ketama-style ring so the same key keeps landing on the same target, withweightscaling each target's share of the ring; on failure the walk follows the ring, so only the failed target's keys move.failoveralways starts at the tier's first target (declaration order) and moves on only after failure. The runtime-signal strategies re-rank every target best-first on each request:least_costby the target model's combined input+output price,least_latencyby a moving average of recent upstream latency,least_busyby in-flight requests divided byweight.weightis accepted with every strategy;failover,least_cost, andleast_latencydo not use it. -
routing.targets(array, required): Candidate direct models used by the routing model. -
routing.targets[].model_id(string, required): UUID of a direct model in the same environment. -
routing.targets[].weight(integer, optional): Target weight, default1, accepted with every strategy. Used byround_robin(rotation share),consistent_hash(share of the hash ring), andleast_busy(in-flight divided by weight);failover,least_cost, andleast_latencydo not use it. -
routing.targets[].priority(integer, optional): Priority tier, default0; a HIGHER value is preferred (the APISIX node-priority convention — give backup targets-1). The strategy orders targets within each tier; a lower tier only receives traffic when every higher-tier target failed or was removed from rotation by health/cooldown filtering. Accepted with every strategy. -
routing.targets[].tags(array, optional): Tags for tag/metadata-conditional routing, orthogonal tostrategy. When a request carries routing tags (via thex-aisix-routing-tagsheader), only targets whose tags intersect the request's are eligible; a target taggeddefaultis the fallback used when nothing matches and for untagged requests. Omitted/empty means the target opts out of tag filtering. The configured strategy then orders whatever target set survives filtering. -
routing.retries(integer, optional): Number of retry attempts before trying another target. -
routing.max_fallbacks(integer, optional): Maximum number of fallback targets tried for one request. -
routing.retry_on_429(boolean, optional): Whether upstream 429 responses are retryable. -
routing.when_all_unavailable(string, optional): What the router does when every target has been removed from rotation by runtime health/cooldown filtering and none remain to receive the request.fail(default) returns an error to the caller;try_anywayignores the filtering for this request and attempts the targets regardless. Optional; omitted =fail. -
routing.hash_on(array, optional): Where theconsistent_hashkey comes from: an ordered chain of sources, the first one yielding a non-empty value wins. Omitted = thex-aisix-routing-keyrequest header, falling back to the caller's API key id. Only valid withstrategy: consistent_hash— sending it with any other strategy returns400 INVALID_REQUEST. When updating a model, theroutingobject is a full replacement — omitting this field restores the default chain. -
routing.hash_on[].type(string, required): Which request attribute supplies the hash key: a requestheaderorcookie(both named byname), the caller'sapi_keyid, or the caller's resolvedclient_ip. -
routing.hash_on[].name(string, optional): The header or cookie name to read. Required forheaderandcookiesources; must be absent forapi_keyandclient_ip— invalid combinations return400 INVALID_REQUEST. -
routing.fallback_on_statuses(array, optional): Upstream HTTP status codes that trigger retries and failover in addition to the defaults. Out of the box, a response with a status other than429in the 400-499 range is treated as a request problem and returned to the caller without trying other targets. Some model services use such codes for transient conditions — overload, queue saturation, quota exhaustion — and listing those codes here (for example[408, 409]) lets the router try the remaining targets instead. Codes in the 500-599 range already trigger failover, so listing them changes nothing. Duplicate entries return400 INVALID_REQUEST. Optional; omitted keeps the default behavior. When updating a model, theroutingobject is a full replacement — omitting this field clears it. -
ensemble(object, optional): Ensemble configuration for models that fan out to a panel and synthesize the result with a judge model. Panel members and the judge reference direct models in the same environment. -
ensemble.panel(array, required): Direct models that produce candidate responses. -
ensemble.panel[].model_id(string, required): UUID of a direct model in the same environment. -
ensemble.panel[].temperature(number, optional): Temperature override for this panel member. -
ensemble.panel[].seed(integer, optional): Seed passed to this panel member. -
ensemble.panel[].weight(integer, optional): Member weight used in the synthesis context. -
ensemble.judge(object, required): Direct model that synthesizes an ensemble's candidate responses. -
ensemble.judge.model_id(string, required): UUID of a direct model in the same environment. -
ensemble.judge.synthesis_prompt(string, optional): Custom instruction used by the judge during synthesis. -
ensemble.min_responses(integer, optional): Minimum successful panel responses before synthesis runs. The value must be within the panel size. -
ensemble.timeout_ms(integer, optional): Per-panel-member upstream timeout in milliseconds. -
semantic(object, optional): Semantic-router configuration. The router embeds each request, compares it with route examples, and selects the best matching direct model. If no route clears the threshold, the request uses the default model. -
semantic.embedding_model_id(string, required): UUID of an embedding model in the same environment. -
semantic.default_model_id(string, required): UUID of the direct model used when no route matches. -
semantic.threshold(number, required): Default similarity threshold for routes without their own. -
semantic.embedding_timeout_ms(integer, optional): Per-call embedding deadline in milliseconds. -
semantic.on_embedding_failure(object, optional): Behavior when the embedding call fails or times out. Usedefaultto route to the default model,failto reject with 503, ortargetto route totarget_model_id. -
semantic.on_embedding_failure.mode(string, required): Fallback behavior when embedding fails. -
semantic.on_embedding_failure.target_model_id(string, optional): UUID of adirectmodel; set only whenmodeistarget. -
semantic.routes(array, required): Semantic routes evaluated for each request. -
semantic.routes[].name(string, required): Route label, surfaced in thex-aisix-routeheader. -
semantic.routes[].target_model_id(string, required): UUID of a direct model in the same environment. -
semantic.routes[].description(string, optional): Human-readable description of this semantic route. -
semantic.routes[].examples(array, required): Example utterances matched against the request. -
semantic.routes[].threshold(number, optional): Per-route threshold override; falls back to the router threshold. -
embedding(object, optional): Embedding-modality metadata for models that point at an OpenAI-compatible/v1/embeddingsendpoint. -
embedding.dimensions(integer, required): Output vector dimensionality. -
embedding.normalize(boolean, optional): Whether the endpoint already returns L2-normalized vectors.
Responses
-
201: Created -
model(object, required): Model resource. Thekindvalue determines which variant block is present: -
direct: usesmodel_nameandprovider_key_id. -
routing: usesrouting. -
ensemble: usesensemble. -
semantic: usessemantic. -
embedding: usesembedding, plusmodel_nameandprovider_key_id. -
model.id(string, required): Model ID. -
model.env_id(string, required): Environment ID that owns this model. -
model.kind(string, required): Model kind. The value is fixed at creation. -
model.display_name(string, required): Model alias that callers use in requests. -
model.model_name(string, optional): Upstream model identifier for direct models, such asgpt-4o-2024-08-06. -
model.provider_key_id(string, optional): Provider key ID that supplies the upstream credential for direct models. -
model.rate_limit(object, optional): Per-model rate limit.nullmeans no model-level limit. -
allOf variant 1
-
model.rate_limit.rps(integer, optional): Requests per second. -
model.rate_limit.rpm(integer, optional): Requests per minute. -
model.rate_limit.rph(integer, optional): Requests per hour. -
model.rate_limit.rpd(integer, optional): Requests per day. -
model.rate_limit.tpm(integer, optional): Tokens per minute. -
model.rate_limit.tpd(integer, optional): Tokens per day. -
model.rate_limit.concurrency(integer, optional): Maximum in-flight requests. -
model.background_model_check(object, optional): Periodic upstream health probe configuration for direct models. -
model.background_model_check.enabled(boolean, required): Whether background health checks are active. -
model.background_model_check.interval_seconds(integer, required): Probe interval in seconds. -
model.background_model_check.timeout_seconds(integer, required): Probe timeout in seconds. -
model.background_model_check.prompt(string, required): Prompt sent by the background health probe. -
model.background_model_check.max_tokens(integer, required): Maximum tokens requested for the probe response. -
model.background_model_check.ignore_statuses(array, required): Upstream status codes that count as "still healthy" even when returned during a probe (e.g.429,408). -
model.background_model_check.stale_after_seconds(integer, required): How long an unhealthy probe result is honored before it expires and the model re-enters rotation. The value must be greater than or equal tointerval_seconds. -
model.cooldown(object, optional): Per-request cooldown settings for direct models. When a target returns a configured error, times out, or has a transport error, the gateway skips it until the cooldown expires. -
model.cooldown.enabled(boolean, optional): Whether cooldown is active for this model. -
model.cooldown.default_seconds(integer, optional): Hold duration, in seconds, applied when a cooldown is triggered and no upstreamRetry-Afteris honored. -
model.cooldown.max_seconds(integer, optional): Upper bound, in seconds, on any single hold. This value caps an honored upstreamRetry-Afterheader. -
model.cooldown.honor_retry_after(boolean, optional): Whether an upstreamRetry-Afterresponse header can set the hold duration, capped atmax_seconds. -
model.cooldown.trigger_statuses(array, optional): HTTP status codes that trigger a cooldown. -
model.cooldown.trigger_on_timeout(boolean, optional): Whether a request timeout triggers a cooldown. -
model.cooldown.trigger_on_transport(boolean, optional): Whether a transport-level error (connection failure, TLS error) triggers a cooldown. -
model.auto_prompt_caching(object, optional): Automatic prompt-cache breakpoint injection for normalized requests to direct Anthropic models. When enabled, the gateway adds cache-control markers to/v1/chat/completionsand/v1/responsesrequests that carry none of their own, so callers can receive provider-side prompt-cache discounts without adding markers. The native/v1/messagesroute preserves caller-supplied markers but does not add them automatically. -
model.auto_prompt_caching.enabled(boolean, optional): Whether automatic prompt-cache injection is active for this model. -
model.auto_prompt_caching.ttl(string, optional): Cache lifetime for injected breakpoints.5mis written at 1.25x the base input rate and breaks even after one cache read;1his written at 2x and pays off only when the cached prefix is reused across a longer session. -
model.timeout(integer, optional): Non-streaming request timeout in milliseconds. Accepted on every model kind except ensemble (whose own deadline isensemble.timeout_ms). On a routing model or semantic router the value is the group/router-level slot applied to every target that does not set its own; on a direct or embedding model it applies to that model's own upstream call. Unset values inherit that group/router value, then the gateway default;0disables the timeout. -
model.stream_timeout(integer, optional): Streaming read timeout in milliseconds for first-token and inter-chunk waits. Accepted on every model kind except ensemble.0or unset falls back to the group/routerstream_timeout, then totimeout, then to gateway defaults. -
model.retries(integer, optional): Retry attempts after a retryable upstream failure before the request gives up, or fails over to the next target inside a model group or semantic router. Accepted on direct, embedding and semantic models — not ensemble, and a routing model rejects the top-level field (its group slot isrouting.retries). On a semantic router the top-level value is the router slot. Unset values fall back to that slot, then to the gateway's deployment-wide default;0disables retrying for this model. -
model.allowed_cidrs(array, optional): Client-IP allowlist in CIDR notation for direct and routing models. Empty values allow all client IPs. Requests outside the allowlist receive 403 withcode: ip_restricted. -
model.routing(object, optional): Virtual-router configuration for routing models. Shape is identical between request and response. -
model.routing.strategy(string, required): Target-selection strategy, applied within each priority tier (seetargets[].priority).round_robinis smooth WEIGHTED round-robin overtargets[].weight— equal or absent weights degrade to a plain declaration-order cycle.consistent_hashhashes a per-request key (seehash_on) over a ketama-style ring so the same key keeps landing on the same target, withweightscaling each target's share of the ring; on failure the walk follows the ring, so only the failed target's keys move.failoveralways starts at the tier's first target (declaration order) and moves on only after failure. The runtime-signal strategies re-rank every target best-first on each request:least_costby the target model's combined input+output price,least_latencyby a moving average of recent upstream latency,least_busyby in-flight requests divided byweight.weightis accepted with every strategy;failover,least_cost, andleast_latencydo not use it. -
model.routing.targets(array, required): Candidate direct models used by the routing model. -
model.routing.targets[].model_id(string, required): UUID of a direct model in the same environment. -
model.routing.targets[].weight(integer, optional): Target weight, default1, accepted with every strategy. Used byround_robin(rotation share),consistent_hash(share of the hash ring), andleast_busy(in-flight divided by weight);failover,least_cost, andleast_latencydo not use it. -
model.routing.targets[].priority(integer, optional): Priority tier, default0; a HIGHER value is preferred (the APISIX node-priority convention — give backup targets-1). The strategy orders targets within each tier; a lower tier only receives traffic when every higher-tier target failed or was removed from rotation by health/cooldown filtering. Accepted with every strategy. -
model.routing.targets[].tags(array, optional): Tags for tag/metadata-conditional routing, orthogonal tostrategy. When a request carries routing tags (via thex-aisix-routing-tagsheader), only targets whose tags intersect the request's are eligible; a target taggeddefaultis the fallback used when nothing matches and for untagged requests. Omitted/empty means the target opts out of tag filtering. The configured strategy then orders whatever target set survives filtering. -
model.routing.retries(integer, optional): Number of retry attempts before trying another target. -
model.routing.max_fallbacks(integer, optional): Maximum number of fallback targets tried for one request. -
model.routing.retry_on_429(boolean, optional): Whether upstream 429 responses are retryable. -
model.routing.when_all_unavailable(string, optional): What the router does when every target has been removed from rotation by runtime health/cooldown filtering and none remain to receive the request.fail(default) returns an error to the caller;try_anywayignores the filtering for this request and attempts the targets regardless. Optional; omitted =fail. -
model.routing.hash_on(array, optional): Where theconsistent_hashkey comes from: an ordered chain of sources, the first one yielding a non-empty value wins. Omitted = thex-aisix-routing-keyrequest header, falling back to the caller's API key id. Only valid withstrategy: consistent_hash— sending it with any other strategy returns400 INVALID_REQUEST. When updating a model, theroutingobject is a full replacement — omitting this field restores the default chain. -
model.routing.hash_on[].type(string, required): Which request attribute supplies the hash key: a requestheaderorcookie(both named byname), the caller'sapi_keyid, or the caller's resolvedclient_ip. -
model.routing.hash_on[].name(string, optional): The header or cookie name to read. Required forheaderandcookiesources; must be absent forapi_keyandclient_ip— invalid combinations return400 INVALID_REQUEST. -
model.routing.fallback_on_statuses(array, optional): Upstream HTTP status codes that trigger retries and failover in addition to the defaults. Out of the box, a response with a status other than429in the 400-499 range is treated as a request problem and returned to the caller without trying other targets. Some model services use such codes for transient conditions — overload, queue saturation, quota exhaustion — and listing those codes here (for example[408, 409]) lets the router try the remaining targets instead. Codes in the 500-599 range already trigger failover, so listing them changes nothing. Duplicate entries return400 INVALID_REQUEST. Optional; omitted keeps the default behavior. When updating a model, theroutingobject is a full replacement — omitting this field clears it. -
model.ensemble(object, optional): Ensemble configuration for models that fan out to a panel and synthesize the result with a judge model. Panel members and the judge reference direct models in the same environment. -
model.ensemble.panel(array, required): Direct models that produce candidate responses. -
model.ensemble.panel[].model_id(string, required): UUID of a direct model in the same environment. -
model.ensemble.panel[].temperature(number, optional): Temperature override for this panel member. -
model.ensemble.panel[].seed(integer, optional): Seed passed to this panel member. -
model.ensemble.panel[].weight(integer, optional): Member weight used in the synthesis context. -
model.ensemble.judge(object, required): Direct model that synthesizes an ensemble's candidate responses. -
model.ensemble.judge.model_id(string, required): UUID of a direct model in the same environment. -
model.ensemble.judge.synthesis_prompt(string, optional): Custom instruction used by the judge during synthesis. -
model.ensemble.min_responses(integer, optional): Minimum successful panel responses before synthesis runs. The value must be within the panel size. -
model.ensemble.timeout_ms(integer, optional): Per-panel-member upstream timeout in milliseconds. -
model.semantic(object, optional): Semantic-router configuration. The router embeds each request, compares it with route examples, and selects the best matching direct model. If no route clears the threshold, the request uses the default model. -
model.semantic.embedding_model_id(string, required): UUID of an embedding model in the same environment. -
model.semantic.default_model_id(string, required): UUID of the direct model used when no route matches. -
model.semantic.threshold(number, required): Default similarity threshold for routes without their own. -
model.semantic.embedding_timeout_ms(integer, optional): Per-call embedding deadline in milliseconds. -
model.semantic.on_embedding_failure(object, optional): Behavior when the embedding call fails or times out. Usedefaultto route to the default model,failto reject with 503, ortargetto route totarget_model_id. -
model.semantic.on_embedding_failure.mode(string, required): Fallback behavior when embedding fails. -
model.semantic.on_embedding_failure.target_model_id(string, optional): UUID of adirectmodel; set only whenmodeistarget. -
model.semantic.routes(array, required): Semantic routes evaluated for each request. -
model.semantic.routes[].name(string, required): Route label, surfaced in thex-aisix-routeheader. -
model.semantic.routes[].target_model_id(string, required): UUID of a direct model in the same environment. -
model.semantic.routes[].description(string, optional): Human-readable description of this semantic route. -
model.semantic.routes[].examples(array, required): Example utterances matched against the request. -
model.semantic.routes[].threshold(number, optional): Per-route threshold override; falls back to the router threshold. -
model.embedding(object, optional): Embedding-modality metadata for models that point at an OpenAI-compatible/v1/embeddingsendpoint. -
model.embedding.dimensions(integer, required): Output vector dimensionality. -
model.embedding.normalize(boolean, optional): Whether the endpoint already returns L2-normalized vectors. -
model.created_at(string, required): Time when the model was created. -
model.updated_at(string, required): Time when the model was last updated. -
warnings(array, optional): Present on save operations when some data plane nodes in the environment run a gateway version that will not execute part of the saved model. Never present on reads. -
warnings[].code(string, required): How affected nodes treat the saved resource.field_ignored: the resource stays in service on those nodes but the named field has no effect there — beware when the field is restrictive, since the restriction is silently not enforced.row_rejected: those nodes refuse the whole resource, so it stops serving there entirely (or, if a previously accepted version exists, they keep serving the old values). -
warnings[].field(string, required): Dot-separated path of the field that triggered the warning, as delivered to gateway nodes. -
warnings[].min_dp_version(string, required): Oldest gateway version that fully executes the field. The literal valueunreleasedmeans no released gateway version executes it yet. -
warnings[].affected_dp_count(integer, required): Number of currently registered nodes in the environment running an older gateway version thanmin_dp_version. -
warnings[].affected_dp_versions(array, required): Distinct gateway versions reported by the affected nodes, capped at five entries. Nodes that report no version appear asunknown. -
400: Request body or parameters failed validation. -
error(object, required): Error details. -
error.code(string, required): Machine-readable identifier. Examples:UNAUTHENTICATED,INVALID_REQUEST,MASTER_KEY_UNSET,INTERNAL. -
error.message(string, required): Human-readable explanation; safe to surface to operators. -
401: Missing or invalid bearer. Response fields (application/json): identical toPOST /environments/{env_id}/models, response 400 above. -
403: Authenticated request is not permitted. Response fields (application/json): identical toPOST /environments/{env_id}/models, response 400 above. -
404: Resource not found. Response fields (application/json): identical toPOST /environments/{env_id}/models, response 400 above. -
409: Request conflicts with current resource state. Response fields (application/json): identical toPOST /environments/{env_id}/models, response 400 above.
cURL
curl -X POST '$AISIX_CP/environments/{env_id}/models' -H 'Authorization: Bearer $AISIX_TOKEN'