API7 Docs
AISIX AI GatewayAISIX Cloud Admin APIList Models

List Models

GET /environments/{env_id}/models

GET /environments/{env_id}/models

Interactive request editor loads with JavaScript.

Authorization

BearerAdminToken
AuthorizationBearer <token>

Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.

In: header

Path Parameters

env_id*string

Environment ID that scopes the request.

Formatuuid

Response Body

application/json

application/json

application/json

application/json

curl -X GET "$AISIX_CP/environments/$ENV_ID/models" \  -H "Authorization: Bearer $AISIX_TOKEN"

OK

{
  "data": [
    {
      "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"
    }
  ]
}
Complete operation details and schema variants

GET /environments/{env_id}/models

List Models

Return every direct, routing, ensemble, semantic, and embedding model configured in the environment. The response is not paginated.

Parameters

  • env_id (path, string, required): Environment ID that scopes the request.

Responses

  • 200: OK

  • data (array, required): Models visible in the environment.

  • data[].id (string, required): Model ID.

  • data[].env_id (string, required): Environment ID that owns this model.

  • data[].kind (string, required): Model kind. The value is fixed at creation.

  • data[].display_name (string, required): Model alias that callers use in requests.

  • data[].model_name (string, optional): Upstream model identifier for direct models, such as gpt-4o-2024-08-06.

  • data[].provider_key_id (string, optional): Provider key ID that supplies the upstream credential for direct models.

  • data[].rate_limit (object, optional): Per-model rate limit. null means no model-level limit.

  • allOf variant 1

  • data[].rate_limit.rps (integer, optional): Requests per second.

  • data[].rate_limit.rpm (integer, optional): Requests per minute.

  • data[].rate_limit.rph (integer, optional): Requests per hour.

  • data[].rate_limit.rpd (integer, optional): Requests per day.

  • data[].rate_limit.tpm (integer, optional): Tokens per minute.

  • data[].rate_limit.tpd (integer, optional): Tokens per day.

  • data[].rate_limit.concurrency (integer, optional): Maximum in-flight requests.

  • data[].background_model_check (object, optional): Periodic upstream health probe configuration for direct models.

  • data[].background_model_check.enabled (boolean, required): Whether background health checks are active.

  • data[].background_model_check.interval_seconds (integer, required): Probe interval in seconds.

  • data[].background_model_check.timeout_seconds (integer, required): Probe timeout in seconds.

  • data[].background_model_check.prompt (string, required): Prompt sent by the background health probe.

  • data[].background_model_check.max_tokens (integer, required): Maximum tokens requested for the probe response.

  • data[].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).

  • data[].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 to interval_seconds.

  • data[].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.

  • data[].cooldown.enabled (boolean, optional): Whether cooldown is active for this model.

  • data[].cooldown.default_seconds (integer, optional): Hold duration, in seconds, applied when a cooldown is triggered and no upstream Retry-After is honored.

  • data[].cooldown.max_seconds (integer, optional): Upper bound, in seconds, on any single hold. This value caps an honored upstream Retry-After header.

  • data[].cooldown.honor_retry_after (boolean, optional): Whether an upstream Retry-After response header can set the hold duration, capped at max_seconds.

  • data[].cooldown.trigger_statuses (array, optional): HTTP status codes that trigger a cooldown.

  • data[].cooldown.trigger_on_timeout (boolean, optional): Whether a request timeout triggers a cooldown.

  • data[].cooldown.trigger_on_transport (boolean, optional): Whether a transport-level error (connection failure, TLS error) triggers a cooldown.

  • data[].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/completions and /v1/responses requests that carry none of their own, so callers can receive provider-side prompt-cache discounts without adding markers. The native /v1/messages route preserves caller-supplied markers but does not add them automatically.

  • data[].auto_prompt_caching.enabled (boolean, optional): Whether automatic prompt-cache injection is active for this model.

  • data[].auto_prompt_caching.ttl (string, optional): Cache lifetime for injected breakpoints. 5m is written at 1.25x the base input rate and breaks even after one cache read; 1h is written at 2x and pays off only when the cached prefix is reused across a longer session.

  • data[].timeout (integer, optional): Non-streaming request timeout in milliseconds. Accepted on every model kind except ensemble (whose own deadline is ensemble.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; 0 disables the timeout.

  • data[].stream_timeout (integer, optional): Streaming read timeout in milliseconds for first-token and inter-chunk waits. Accepted on every model kind except ensemble. 0 or unset falls back to the group/router stream_timeout, then to timeout, then to gateway defaults.

  • data[].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 is routing.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; 0 disables retrying for this model.

  • data[].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 with code: ip_restricted.

  • data[].routing (object, optional): Virtual-router configuration for routing models. Shape is identical between request and response.

  • data[].routing.strategy (string, required): Target-selection strategy, applied within each priority tier (see targets[].priority). round_robin is smooth WEIGHTED round-robin over targets[].weight — equal or absent weights degrade to a plain declaration-order cycle. consistent_hash hashes a per-request key (see hash_on) over a ketama-style ring so the same key keeps landing on the same target, with weight scaling each target's share of the ring; on failure the walk follows the ring, so only the failed target's keys move. failover always 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_cost by the target model's combined input+output price, least_latency by a moving average of recent upstream latency, least_busy by in-flight requests divided by weight. weight is accepted with every strategy; failover, least_cost, and least_latency do not use it.

  • data[].routing.targets (array, required): Candidate direct models used by the routing model.

  • data[].routing.targets[].model_id (string, required): UUID of a direct model in the same environment.

  • data[].routing.targets[].weight (integer, optional): Target weight, default 1, accepted with every strategy. Used by round_robin (rotation share), consistent_hash (share of the hash ring), and least_busy (in-flight divided by weight); failover, least_cost, and least_latency do not use it.

  • data[].routing.targets[].priority (integer, optional): Priority tier, default 0; 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.

  • data[].routing.targets[].tags (array, optional): Tags for tag/metadata-conditional routing, orthogonal to strategy. When a request carries routing tags (via the x-aisix-routing-tags header), only targets whose tags intersect the request's are eligible; a target tagged default is 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.

  • data[].routing.retries (integer, optional): Number of retry attempts before trying another target.

  • data[].routing.max_fallbacks (integer, optional): Maximum number of fallback targets tried for one request.

  • data[].routing.retry_on_429 (boolean, optional): Whether upstream 429 responses are retryable.

  • data[].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_anyway ignores the filtering for this request and attempts the targets regardless. Optional; omitted = fail.

  • data[].routing.hash_on (array, optional): Where the consistent_hash key comes from: an ordered chain of sources, the first one yielding a non-empty value wins. Omitted = the x-aisix-routing-key request header, falling back to the caller's API key id. Only valid with strategy: consistent_hash — sending it with any other strategy returns 400 INVALID_REQUEST. When updating a model, the routing object is a full replacement — omitting this field restores the default chain.

  • data[].routing.hash_on[].type (string, required): Which request attribute supplies the hash key: a request header or cookie (both named by name), the caller's api_key id, or the caller's resolved client_ip.

  • data[].routing.hash_on[].name (string, optional): The header or cookie name to read. Required for header and cookie sources; must be absent for api_key and client_ip — invalid combinations return 400 INVALID_REQUEST.

  • data[].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 than 429 in 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 return 400 INVALID_REQUEST. Optional; omitted keeps the default behavior. When updating a model, the routing object is a full replacement — omitting this field clears it.

  • data[].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.

  • data[].ensemble.panel (array, required): Direct models that produce candidate responses.

  • data[].ensemble.panel[].model_id (string, required): UUID of a direct model in the same environment.

  • data[].ensemble.panel[].temperature (number, optional): Temperature override for this panel member.

  • data[].ensemble.panel[].seed (integer, optional): Seed passed to this panel member.

  • data[].ensemble.panel[].weight (integer, optional): Member weight used in the synthesis context.

  • data[].ensemble.judge (object, required): Direct model that synthesizes an ensemble's candidate responses.

  • data[].ensemble.judge.model_id (string, required): UUID of a direct model in the same environment.

  • data[].ensemble.judge.synthesis_prompt (string, optional): Custom instruction used by the judge during synthesis.

  • data[].ensemble.min_responses (integer, optional): Minimum successful panel responses before synthesis runs. The value must be within the panel size.

  • data[].ensemble.timeout_ms (integer, optional): Per-panel-member upstream timeout in milliseconds.

  • data[].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.

  • data[].semantic.embedding_model_id (string, required): UUID of an embedding model in the same environment.

  • data[].semantic.default_model_id (string, required): UUID of the direct model used when no route matches.

  • data[].semantic.threshold (number, required): Default similarity threshold for routes without their own.

  • data[].semantic.embedding_timeout_ms (integer, optional): Per-call embedding deadline in milliseconds.

  • data[].semantic.on_embedding_failure (object, optional): Behavior when the embedding call fails or times out. Use default to route to the default model, fail to reject with 503, or target to route to target_model_id.

  • data[].semantic.on_embedding_failure.mode (string, required): Fallback behavior when embedding fails.

  • data[].semantic.on_embedding_failure.target_model_id (string, optional): UUID of a direct model; set only when mode is target.

  • data[].semantic.routes (array, required): Semantic routes evaluated for each request.

  • data[].semantic.routes[].name (string, required): Route label, surfaced in the x-aisix-route header.

  • data[].semantic.routes[].target_model_id (string, required): UUID of a direct model in the same environment.

  • data[].semantic.routes[].description (string, optional): Human-readable description of this semantic route.

  • data[].semantic.routes[].examples (array, required): Example utterances matched against the request.

  • data[].semantic.routes[].threshold (number, optional): Per-route threshold override; falls back to the router threshold.

  • data[].embedding (object, optional): Embedding-modality metadata for models that point at an OpenAI-compatible /v1/embeddings endpoint.

  • data[].embedding.dimensions (integer, required): Output vector dimensionality.

  • data[].embedding.normalize (boolean, optional): Whether the endpoint already returns L2-normalized vectors.

  • data[].created_at (string, required): Time when the model was created.

  • data[].updated_at (string, required): Time when the model was last updated.

  • 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 to GET /environments/{env_id}/models, response 400 above.

  • 404: Resource not found. Response fields (application/json): identical to GET /environments/{env_id}/models, response 400 above.

cURL

curl -X GET '$AISIX_CP/environments/{env_id}/models' -H 'Authorization: Bearer $AISIX_TOKEN'