{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "MYRILUM Unified AI Router API",
    "version": "1.0.0",
    "summary": "Unified multi-provider inference, credit reservation, BYOK custody, guardrails, and OTLP broadcast API for MYRILUM Router.",
    "description": "OpenAPI 3.1.0 specification for MYRILUM Router (/api/router/v1/*). Supports OpenAI Chat Completions, Legacy Completions, OpenAI Responses, Anthropic Messages, Embeddings, Rerank, Files, Batches, OAuth 2.0 PKCE S256 key exchange, Provisioned Inference Keys (sk-myr-v1-*), Management Keys (sk-myr-mgmt-*), Credits, Activity OLAP, Guardrails, Cloud Presets (@preset/*), AES-256-GCM BYOK custody, OTLP Broadcast Sinks, Intent Classifiers, Server Tools, Notifications, CIDR IP Allowlists, and Auto-Topup.",
    "license": {
      "name": "Proprietary — MYRILUM",
      "identifier": "LicenseRef-MYRILUM-Commercial"
    }
  },
  "servers": [
    {
      "url": "https://app.myrilum.cn",
      "description": "MYRILUM CN Mainland Sovereign Cell"
    }
  ],
  "tags": [
    {
      "name": "Inference",
      "description": "Real-time & streaming multimodal generation, embeddings, reranking, and generation ledger lookup."
    },
    {
      "name": "Discovery",
      "description": "Canonical model catalog, user-accessible models, provider endpoints, and parameter schemas."
    },
    {
      "name": "Files & Batches",
      "description": "Multimodal/JSONL file storage and asynchronous batch inference lifecycle."
    },
    {
      "name": "Keys & OAuth PKCE",
      "description": "Key self-introspection, OAuth 2.0 PKCE S256 consent exchange, inference keys, and management keys."
    },
    {
      "name": "Credits & Activity",
      "description": "Micro-credit balance summary, cell-native top-up checkout, voucher redemption, and OLAP activity."
    },
    {
      "name": "Governance & Workspace Config",
      "description": "Guardrails, presets, BYOK custody, broadcast sinks, routing policy, tools, classifiers, alerts, CIDR allowlists, and auto-topup."
    }
  ],
  "x-endpoint-groups": [
    "chat-completions",
    "completions",
    "responses",
    "anthropic-messages",
    "embeddings",
    "rerank",
    "generation-lookup",
    "models-list",
    "models-count",
    "models-user",
    "model-endpoints",
    "model-parameters",
    "providers-list",
    "files-list-create",
    "files-item-delete",
    "batches-list-create",
    "batches-item",
    "batches-cancel",
    "key-self-introspection",
    "oauth-pkce-auth-keys",
    "provisioned-keys-list-create",
    "provisioned-keys-item",
    "management-keys-list-create",
    "management-keys-revoke",
    "credits-summary",
    "credits-checkout",
    "credits-redeem",
    "activity-analytics",
    "guardrails-crud",
    "presets-crud",
    "byok-crud",
    "byok-test",
    "broadcast-sinks-crud",
    "broadcast-sinks-test",
    "default-routing",
    "server-tools",
    "classifiers-crud",
    "notifications-policy",
    "ip-allowlist-and-auto-topup"
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/api/router/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "tags": [
          "Inference"
        ],
        "summary": "Create OpenAI-compatible chat completion (JSON or SSE)",
        "description": "Supports model suffixes (:nitro, :floor, :online, :free, :extended), @preset/<slug>, myrilum/auto, provider routing preferences, guardrails, BYOK, and mid-stream abort settlement.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion response or text/event-stream SSE chunks",
            "headers": {
              "x-myrilum-generation-id": {
                "schema": {
                  "type": "string"
                }
              },
              "x-myrilum-provider": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenGuardrail"
          }
        }
      }
    },
    "/api/router/v1/completions": {
      "post": {
        "operationId": "createTextCompletion",
        "tags": [
          "Inference"
        ],
        "summary": "Create legacy prompt text completion",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completion response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompletionResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          }
        }
      }
    },
    "/api/router/v1/responses": {
      "post": {
        "operationId": "createModelResponse",
        "tags": [
          "Inference"
        ],
        "summary": "Create OpenAI Responses API structured/stateful output",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Responses API object or SSE stream",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesObject"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          }
        }
      }
    },
    "/api/router/v1/messages": {
      "post": {
        "operationId": "createAnthropicMessage",
        "tags": [
          "Inference"
        ],
        "summary": "Create Anthropic Messages native protocol completion",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "AnthropicApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessagesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Anthropic Message object or SSE event stream",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessagesResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientCredits"
          }
        }
      }
    },
    "/api/router/v1/embeddings": {
      "post": {
        "operationId": "createEmbeddings",
        "tags": [
          "Inference"
        ],
        "summary": "Generate dense vector embeddings",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Embedding vector list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbeddingResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/router/v1/rerank": {
      "post": {
        "operationId": "rerankDocuments",
        "tags": [
          "Inference"
        ],
        "summary": "Cross-encoder relevance reranking over candidate documents",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RerankRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ranked document indices and relevance scores",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RerankResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/router/v1/generation": {
      "get": {
        "operationId": "getGenerationById",
        "tags": [
          "Inference"
        ],
        "summary": "Lookup settled generation record by id",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^gen_"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Generation telemetry & settlement record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/GenerationRecord"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/router/v1/models": {
      "get": {
        "operationId": "listModels",
        "tags": [
          "Discovery"
        ],
        "summary": "List canonical router models available in the active cell",
        "security": [],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RouterModelSummary"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/models/count": {
      "get": {
        "operationId": "getModelsCount",
        "tags": [
          "Discovery"
        ],
        "summary": "Return count of indexed models in the active cell",
        "security": [],
        "responses": {
          "200": {
            "description": "Model count",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": [
                        "count"
                      ],
                      "properties": {
                        "count": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/models/user": {
      "get": {
        "operationId": "listUserAccessibleModels",
        "tags": [
          "Discovery"
        ],
        "summary": "List models permitted for the caller's workspace guardrails and BYOK posture",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered model list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RouterModelSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/router/v1/models/{author}/{slug}/endpoints": {
      "get": {
        "operationId": "listModelEndpoints",
        "tags": [
          "Discovery"
        ],
        "summary": "List upstream provider endpoints hosting a specific model",
        "security": [],
        "parameters": [
          {
            "name": "author",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Model provider endpoints",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModelEndpointsPayload"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/router/v1/parameters/{author}/{slug}": {
      "get": {
        "operationId": "getModelParameters",
        "tags": [
          "Discovery"
        ],
        "summary": "Retrieve supported sampling and structured-output parameters for a model",
        "security": [],
        "parameters": [
          {
            "name": "author",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Supported parameters descriptor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ModelParametersPayload"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/router/v1/providers": {
      "get": {
        "operationId": "listProviders",
        "tags": [
          "Discovery"
        ],
        "summary": "List inference providers, quantization levels, and ZDR posture",
        "security": [],
        "responses": {
          "200": {
            "description": "Provider directory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RouterProviderSummary"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/files": {
      "get": {
        "operationId": "listFiles",
        "tags": [
          "Files & Batches"
        ],
        "summary": "List uploaded workspace files",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Workspace files",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/FileRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "uploadFile",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Upload a JSONL batch, PDF, or vision asset file",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateFileRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created file metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileRecord"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/files/{id}": {
      "get": {
        "operationId": "getFile",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Inspect uploaded file metadata by ID",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileRecord"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "operationId": "deleteFile",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Delete workspace file",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deletion confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/batches": {
      "get": {
        "operationId": "listBatches",
        "tags": [
          "Files & Batches"
        ],
        "summary": "List asynchronous batch jobs",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Batch job list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BatchJobRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createBatch",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Create asynchronous batch inference job",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBatchRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created batch job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchJobRecord"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/batches/{id}": {
      "get": {
        "operationId": "getBatch",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Retrieve batch job status",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Batch job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchJobRecord"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/router/v1/batches/{id}/cancel": {
      "post": {
        "operationId": "cancelBatch",
        "tags": [
          "Files & Batches"
        ],
        "summary": "Cancel an in-progress batch job",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cancelled batch job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchJobRecord"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/key": {
      "get": {
        "operationId": "introspectCurrentKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Self-introspect active sk-myr-v1-* inference key limits and usage window",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current key metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKeyRecord"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/router/v1/auth/keys": {
      "post": {
        "operationId": "exchangeOAuthPkceKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Exchange OAuth 2.0 PKCE S256 authorization code for a scoped sk-myr-v1-* key",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PkceCodeExchangeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Issued plaintext key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PkceCodeExchangeResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      },
      "put": {
        "operationId": "issueOAuthPkceAuthorizationCode",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Issue single-use OAuth PKCE authorization code from authenticated consent session",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PkceIssueCodeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Issued authorization code",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/keys": {
      "get": {
        "operationId": "listProvisionedKeys",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "List provisioned sk-myr-v1-* keys via Management Key or Workspace Session",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Provisioned keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKeyRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProvisionedKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Provision a new sk-myr-v1-* inference key",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created key with one-time plaintext secret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedApiKeyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/keys/{hash}": {
      "get": {
        "operationId": "getProvisionedKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Inspect provisioned key by hash or keyId",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Key record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKeyRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateProvisionedKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Update key status, credit limit, or reset window",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateApiKeyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated key record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ApiKeyRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "revokeProvisionedKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Revoke provisioned inference key immediately",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/management-keys": {
      "get": {
        "operationId": "listManagementKeys",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "List account-scoped sk-myr-mgmt-* management keys",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Management keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ManagementKeyRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createManagementKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Create a new sk-myr-mgmt-* management key",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateManagementKeyRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created management key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedManagementKeyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/management-keys/{id}": {
      "delete": {
        "operationId": "revokeManagementKey",
        "tags": [
          "Keys & OAuth PKCE"
        ],
        "summary": "Revoke an sk-myr-mgmt-* management key",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revocation receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/credits": {
      "get": {
        "operationId": "getCreditsSummary",
        "tags": [
          "Credits & Activity"
        ],
        "summary": "Read total, used, reserved, and available router micro-credits",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Credits ledger summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CreditsSummary"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/credits/checkout": {
      "post": {
        "operationId": "createCreditsCheckoutIntent",
        "tags": [
          "Credits & Activity"
        ],
        "summary": "Create regional credit top-up checkout session (CN WeChat/Alipay or GLOBAL Stripe/PayPal)",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutIntentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkout session intent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutIntentResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/credits/redeem": {
      "post": {
        "operationId": "redeemCreditsVoucher",
        "tags": [
          "Credits & Activity"
        ],
        "summary": "Redeem compute voucher code into router credit balance",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VoucherRedeemRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated credit balance",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CreditsSummary"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/activity": {
      "get": {
        "operationId": "getActivityAnalytics",
        "tags": [
          "Credits & Activity"
        ],
        "summary": "Query daily token, spend, cache, and BYOK activity buckets",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspaceKey",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activity OLAP buckets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ActivityBucket"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/guardrails": {
      "get": {
        "operationId": "listGuardrails",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "List account and workspace guardrails",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Guardrail list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GuardrailRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertGuardrail",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Create or update a guardrail rule",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GuardrailUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved guardrail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/GuardrailRecord"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/guardrails/{id}": {
      "get": {
        "operationId": "getGuardrail",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Get guardrail by ID",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Guardrail record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/GuardrailRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchGuardrail",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update guardrail configuration",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GuardrailUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated guardrail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/GuardrailRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteGuardrail",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Delete guardrail rule",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/presets": {
      "get": {
        "operationId": "listPresets",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "List workspace @preset/<slug> configurations",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Preset list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PresetRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertPreset",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Create or version-bump a cloud preset",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PresetUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved preset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PresetRecord"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/presets/{id}": {
      "get": {
        "operationId": "getPreset",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Get cloud preset by ID or slug",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Preset record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PresetRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchPreset",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update cloud preset parameters",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PresetUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated preset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PresetRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePreset",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Delete cloud preset",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/byok": {
      "get": {
        "operationId": "listByokCredentials",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "List AES-256-GCM encrypted BYOK provider credentials (key hints only)",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "BYOK credentials",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ByokRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertByokCredential",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Store or rotate an envelope-encrypted BYOK upstream secret",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ByokUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored BYOK record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ByokRecord"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/byok/{id}": {
      "patch": {
        "operationId": "updateByokCredential",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Toggle Always-Use-BYOK or credit fallback flags",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ByokUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated BYOK record",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ByokRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "revokeByokCredential",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Revoke encrypted BYOK credential",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/byok/{id}/test": {
      "post": {
        "operationId": "testByokCredential",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Verify AAD envelope decryption and upstream provider reachability",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connectivity verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticProbeResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/observability/sinks": {
      "get": {
        "operationId": "listBroadcastSinks",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "List OTLP/observability broadcast sinks",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Broadcast sinks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BroadcastSinkRecord"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertBroadcastSink",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Configure Arize, Langfuse, Datadog, Honeycomb, Braintrust, S3, or custom OTLP sink",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BroadcastSinkUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved broadcast sink",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BroadcastSinkRecord"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/observability/sinks/{id}": {
      "patch": {
        "operationId": "patchBroadcastSink",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update broadcast sink sampling rate or enabled state",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BroadcastSinkUpsertRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated broadcast sink",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/BroadcastSinkRecord"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteBroadcastSink",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Delete broadcast telemetry sink",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/observability/sinks/{id}/test": {
      "post": {
        "operationId": "testBroadcastSink",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Deliver synthetic OpenTelemetry span to verify sink endpoint",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Delivery probe result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiagnosticProbeResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/routing/default": {
      "get": {
        "operationId": "getDefaultRoutingPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Read workspace default routing policy",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Routing policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/RoutingPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateDefaultRoutingPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update workspace default model, fallback chain, sort, quantization floor, and ZDR posture",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoutingPolicy"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved routing policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/RoutingPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/tools": {
      "get": {
        "operationId": "getServerToolConfig",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Read hosted server tools & plugins configuration",
        "security": [
          {
            "BearerAuth": []
          },
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Server tool config",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ServerToolConfig"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateServerToolConfig",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update :online web search, PDF parser, JSON healing, and image generation plugins",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServerToolConfig"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved server tool config",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ServerToolConfig"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/classifiers": {
      "get": {
        "operationId": "listClassifiers",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "List traffic intent classifiers for myrilum/auto routing",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Classifier list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ClassifierRule"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertClassifier",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Create or update an intent-to-model classifier rule",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClassifierRule"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Saved classifier",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ClassifierRule"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/classifiers/{id}": {
      "patch": {
        "operationId": "patchClassifier",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update intent classifier threshold or target model",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClassifierRule"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated classifier",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ClassifierRule"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteClassifier",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Delete intent classifier rule",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAck"
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/notifications": {
      "get": {
        "operationId": "getNotificationRule",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Read low-balance, monthly digest, and BYOK failure notification rules",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Notification rule",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NotificationRule"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateNotificationRule",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update account notification thresholds and webhook callback URL",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationRule"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved notification rule",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NotificationRule"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/ip-allowlist": {
      "get": {
        "operationId": "getIpAllowlistPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Read CIDR IPv4/IPv6 allowlist policy",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "IP allowlist policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/IpAllowlistPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateIpAllowlistPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Update CIDR IPv4/IPv6 allowlist enforcement",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IpAllowlistPolicy"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved IP allowlist policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/IpAllowlistPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/router/v1/auto-topup": {
      "get": {
        "operationId": "getAutoTopupPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Read automatic credit reload policy",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Auto-topup policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AutoTopupPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateAutoTopupPolicy",
        "tags": [
          "Governance & Workspace Config"
        ],
        "summary": "Configure automatic reload threshold, amount, monthly cap, and payment rail",
        "security": [
          {
            "ManagementKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoTopupPolicy"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved auto-topup policy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AutoTopupPolicy"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk-myr-v1-<48hex>",
        "description": "Workspace-scoped inference API key prefixed with sk-myr-v1-."
      },
      "ManagementKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk-myr-mgmt-<48hex>",
        "description": "Account-scoped provisioning and governance key prefixed with sk-myr-mgmt-."
      },
      "AnthropicApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Native Anthropic Messages header accepting sk-myr-v1-* keys."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Malformed payload or unsupported parameter",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, expired, or revoked Bearer key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "InsufficientCredits": {
        "description": "Available router credit balance below reservation requirement",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "ForbiddenGuardrail": {
        "description": "Request blocked by CIDR allowlist or active workspace/account guardrail",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "NotFound": {
        "description": "Requested resource does not exist in caller scope",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "metadata": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "DeleteAck": {
        "type": "object",
        "required": [
          "deleted",
          "id"
        ],
        "properties": {
          "deleted": {
            "type": "boolean"
          },
          "id": {
            "type": "string"
          }
        }
      },
      "DiagnosticProbeResult": {
        "type": "object",
        "required": [
          "ok",
          "latencyMs",
          "checkedAt"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "latencyMs": {
            "type": "number"
          },
          "statusMessage": {
            "type": "string"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ProviderRoutingPreferences": {
        "type": "object",
        "properties": {
          "order": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sort": {
            "type": "string",
            "enum": [
              "throughput",
              "price",
              "latency"
            ]
          },
          "allow_fallbacks": {
            "type": "boolean",
            "default": true
          },
          "data_collection": {
            "type": "string",
            "enum": [
              "deny",
              "allow"
            ]
          },
          "zdr": {
            "type": "boolean"
          },
          "quantizations": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "fp16",
                "bf16",
                "fp8",
                "int8"
              ]
            }
          },
          "ignore": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {
            "type": [
              "string",
              "array"
            ]
          },
          "name": {
            "type": "string"
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "ToolDefinition": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "function"
          },
          "function": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "examples": [
              "deepseek/deepseek-v4-pro",
              "openai/gpt-6-2-astra:nitro",
              "@preset/prod-agent",
              "myrilum/auto"
            ]
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            }
          },
          "models": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderRoutingPreferences"
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "max_cost_usd": {
            "type": "number",
            "minimum": 0
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolDefinition"
            }
          },
          "response_format": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices",
          "usage"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "index",
                "message",
                "finish_reason"
              ],
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "$ref": "#/components/schemas/ChatMessage"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/TokenUsage"
          }
        }
      },
      "TokenUsage": {
        "type": "object",
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          },
          "cost_micro": {
            "type": "integer"
          }
        }
      },
      "CompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "prompt": {
            "type": [
              "string",
              "array"
            ]
          },
          "max_tokens": {
            "type": "integer"
          },
          "temperature": {
            "type": "number"
          },
          "stream": {
            "type": "boolean"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderRoutingPreferences"
          }
        }
      },
      "CompletionResponse": {
        "type": "object",
        "required": [
          "id",
          "object",
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "text_completion"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "index": {
                  "type": "integer"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/TokenUsage"
          }
        }
      },
      "ResponsesRequest": {
        "type": "object",
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "input": {
            "type": [
              "string",
              "array"
            ]
          },
          "instructions": {
            "type": "string"
          },
          "max_output_tokens": {
            "type": "integer"
          },
          "stream": {
            "type": "boolean"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderRoutingPreferences"
          }
        }
      },
      "ResponsesObject": {
        "type": "object",
        "required": [
          "id",
          "object",
          "model",
          "output"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "response"
          },
          "model": {
            "type": "string"
          },
          "output_text": {
            "type": "string"
          },
          "output": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "usage": {
            "$ref": "#/components/schemas/TokenUsage"
          }
        }
      },
      "AnthropicMessagesRequest": {
        "type": "object",
        "required": [
          "model",
          "max_tokens",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "max_tokens": {
            "type": "integer"
          },
          "system": {
            "type": [
              "string",
              "array"
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "role",
                "content"
              ],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "type": [
                    "string",
                    "array"
                  ]
                }
              }
            }
          },
          "stream": {
            "type": "boolean"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderRoutingPreferences"
          }
        }
      },
      "AnthropicMessagesResponse": {
        "type": "object",
        "required": [
          "id",
          "type",
          "role",
          "model",
          "content"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "const": "message"
          },
          "role": {
            "type": "string",
            "const": "assistant"
          },
          "model": {
            "type": "string"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                }
              }
            }
          },
          "stop_reason": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EmbeddingRequest": {
        "type": "object",
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "input": {
            "type": [
              "string",
              "array"
            ]
          },
          "dimensions": {
            "type": "integer"
          },
          "encoding_format": {
            "type": "string",
            "enum": [
              "float",
              "base64"
            ]
          }
        }
      },
      "EmbeddingResponse": {
        "type": "object",
        "required": [
          "object",
          "data",
          "model"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "model": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "index",
                "embedding"
              ],
              "properties": {
                "index": {
                  "type": "integer"
                },
                "embedding": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/TokenUsage"
          }
        }
      },
      "RerankRequest": {
        "type": "object",
        "required": [
          "model",
          "query",
          "documents"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "documents": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "top_n": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "RerankResponse": {
        "type": "object",
        "required": [
          "id",
          "model",
          "results"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "index",
                "relevance_score"
              ],
              "properties": {
                "index": {
                  "type": "integer"
                },
                "relevance_score": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "GenerationRecord": {
        "type": "object",
        "required": [
          "generationId",
          "workspaceKey",
          "requestedModel",
          "resolvedModel",
          "resolvedProvider",
          "modality",
          "promptTokens",
          "completionTokens",
          "costMicro",
          "createdAt"
        ],
        "properties": {
          "generationId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "apiKeyPrefix": {
            "type": "string"
          },
          "sessionId": {
            "type": [
              "string",
              "null"
            ]
          },
          "reservationId": {
            "type": [
              "string",
              "null"
            ]
          },
          "requestedModel": {
            "type": "string"
          },
          "resolvedModel": {
            "type": "string"
          },
          "resolvedProvider": {
            "type": "string"
          },
          "modality": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "video",
              "audio",
              "embedding",
              "rerank"
            ]
          },
          "finishReason": {
            "type": "string"
          },
          "promptTokens": {
            "type": "integer"
          },
          "completionTokens": {
            "type": "integer"
          },
          "reasoningTokens": {
            "type": "integer"
          },
          "cachedTokens": {
            "type": "integer"
          },
          "ttftMs": {
            "type": "number"
          },
          "totalLatencyMs": {
            "type": "number"
          },
          "costMicro": {
            "type": "integer"
          },
          "upstreamCostMicro": {
            "type": "integer"
          },
          "isByok": {
            "type": "boolean"
          },
          "zdrEnforced": {
            "type": "boolean"
          },
          "appReferer": {
            "type": [
              "string",
              "null"
            ]
          },
          "appTitle": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RouterModelSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "context_length",
          "pricing"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "context_length": {
            "type": "integer"
          },
          "max_completion_tokens": {
            "type": "integer"
          },
          "pricing": {
            "type": "object",
            "required": [
              "prompt",
              "completion"
            ],
            "properties": {
              "prompt": {
                "type": "string"
              },
              "completion": {
                "type": "string"
              },
              "input_cache_read": {
                "type": "string"
              }
            }
          }
        }
      },
      "ModelEndpointsPayload": {
        "type": "object",
        "required": [
          "id",
          "endpoints"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "provider_slug",
                "quantization",
                "context_length"
              ],
              "properties": {
                "provider_slug": {
                  "type": "string"
                },
                "quantization": {
                  "type": "string"
                },
                "context_length": {
                  "type": "integer"
                },
                "zdr_status": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ModelParametersPayload": {
        "type": "object",
        "required": [
          "model",
          "supported_parameters"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "supported_parameters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "RouterProviderSummary": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "quantization",
          "byokSupported"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "regionLabel": {
            "type": "string"
          },
          "cnDirectReachable": {
            "type": "boolean"
          },
          "zdrSupported": {
            "type": "boolean"
          },
          "byokSupported": {
            "type": "boolean"
          },
          "quantization": {
            "type": "string"
          }
        }
      },
      "CreateFileRequest": {
        "type": "object",
        "required": [
          "filename",
          "purpose",
          "content"
        ],
        "properties": {
          "filename": {
            "type": "string"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "batch",
              "batch_output",
              "assistants",
              "vision",
              "pdf"
            ]
          },
          "mimeType": {
            "type": "string"
          },
          "content": {
            "type": "string"
          }
        }
      },
      "FileRecord": {
        "type": "object",
        "required": [
          "fileId",
          "workspaceKey",
          "filename",
          "purpose",
          "bytes",
          "sha256",
          "createdAt"
        ],
        "properties": {
          "fileId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "batch",
              "batch_output",
              "assistants",
              "vision",
              "pdf"
            ]
          },
          "bytes": {
            "type": "integer"
          },
          "mimeType": {
            "type": "string"
          },
          "sha256": {
            "type": "string"
          },
          "contentPreview": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateBatchRequest": {
        "type": "object",
        "required": [
          "inputFileId",
          "endpoint",
          "model"
        ],
        "properties": {
          "inputFileId": {
            "type": "string"
          },
          "endpoint": {
            "type": "string",
            "examples": [
              "/api/router/v1/chat/completions",
              "/api/router/v1/embeddings"
            ]
          },
          "model": {
            "type": "string"
          }
        }
      },
      "BatchJobRecord": {
        "type": "object",
        "required": [
          "batchId",
          "workspaceKey",
          "inputFileId",
          "endpoint",
          "model",
          "status",
          "totalRequests",
          "completedRequests",
          "failedRequests",
          "createdAt"
        ],
        "properties": {
          "batchId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "inputFileId": {
            "type": "string"
          },
          "outputFileId": {
            "type": [
              "string",
              "null"
            ]
          },
          "endpoint": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "VALIDATING",
              "IN_PROGRESS",
              "COMPLETED",
              "FAILED",
              "CANCELLED"
            ]
          },
          "totalRequests": {
            "type": "integer"
          },
          "completedRequests": {
            "type": "integer"
          },
          "failedRequests": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ApiKeyRecord": {
        "type": "object",
        "required": [
          "keyId",
          "workspaceKey",
          "name",
          "keyPrefix",
          "status",
          "limitResetPeriod",
          "usageWindowMicro",
          "totalUsageMicro",
          "createdAt"
        ],
        "properties": {
          "keyId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "keyPrefix": {
            "type": "string"
          },
          "keyHashHex": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DISABLED",
              "REVOKED"
            ]
          },
          "creditLimitMicro": {
            "type": [
              "integer",
              "null"
            ]
          },
          "limitResetPeriod": {
            "type": "string",
            "enum": [
              "NONE",
              "DAILY",
              "WEEKLY",
              "MONTHLY"
            ]
          },
          "usageWindowMicro": {
            "type": "integer"
          },
          "totalUsageMicro": {
            "type": "integer"
          },
          "includeByokInLimit": {
            "type": "boolean"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateApiKeyRequest": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "creditLimitMicro": {
            "type": [
              "integer",
              "null"
            ]
          },
          "limitResetPeriod": {
            "type": "string",
            "enum": [
              "NONE",
              "DAILY",
              "WEEKLY",
              "MONTHLY"
            ]
          },
          "includeByokInLimit": {
            "type": "boolean"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateApiKeyRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DISABLED"
            ]
          },
          "creditLimitMicro": {
            "type": [
              "integer",
              "null"
            ]
          },
          "limitResetPeriod": {
            "type": "string",
            "enum": [
              "NONE",
              "DAILY",
              "WEEKLY",
              "MONTHLY"
            ]
          }
        }
      },
      "CreatedApiKeyResponse": {
        "type": "object",
        "required": [
          "key",
          "data"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "One-time plaintext sk-myr-v1-<48hex> key"
          },
          "data": {
            "$ref": "#/components/schemas/ApiKeyRecord"
          }
        }
      },
      "PkceIssueCodeRequest": {
        "type": "object",
        "required": [
          "code_challenge",
          "code_challenge_method"
        ],
        "properties": {
          "app_name": {
            "type": "string"
          },
          "workspace_key": {
            "type": "string"
          },
          "code_challenge": {
            "type": "string"
          },
          "code_challenge_method": {
            "type": "string",
            "const": "S256"
          },
          "credit_limit_micro": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "PkceCodeExchangeRequest": {
        "type": "object",
        "required": [
          "code",
          "code_verifier"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "code_verifier": {
            "type": "string"
          },
          "code_challenge_method": {
            "type": "string",
            "enum": [
              "S256"
            ],
            "default": "S256"
          }
        }
      },
      "PkceCodeExchangeResponse": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^sk-myr-v1-"
          },
          "user_id": {
            "type": "string"
          }
        }
      },
      "ManagementKeyRecord": {
        "type": "object",
        "required": [
          "keyId",
          "name",
          "keyPrefix",
          "scopes",
          "status",
          "createdAt"
        ],
        "properties": {
          "keyId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "keyPrefix": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "keys:read",
                "keys:write",
                "credits:read",
                "logs:read",
                "guardrails:write"
              ]
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "REVOKED"
            ]
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreateManagementKeyRequest": {
        "type": "object",
        "required": [
          "name",
          "scopes"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "keys:read",
                "keys:write",
                "credits:read",
                "logs:read",
                "guardrails:write"
              ]
            }
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "CreatedManagementKeyResponse": {
        "type": "object",
        "required": [
          "key",
          "data"
        ],
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^sk-myr-mgmt-"
          },
          "data": {
            "$ref": "#/components/schemas/ManagementKeyRecord"
          }
        }
      },
      "CreditsSummary": {
        "type": "object",
        "required": [
          "totalCreditsMicro",
          "totalUsageMicro",
          "reservedMicro",
          "availableMicro",
          "currencyCode"
        ],
        "properties": {
          "totalCreditsMicro": {
            "type": "integer"
          },
          "totalUsageMicro": {
            "type": "integer"
          },
          "reservedMicro": {
            "type": "integer"
          },
          "availableMicro": {
            "type": "integer"
          },
          "currencyCode": {
            "type": "string",
            "enum": [
              "CNY",
              "USD"
            ]
          }
        }
      },
      "CheckoutIntentRequest": {
        "type": "object",
        "required": [
          "amountMicro",
          "channel"
        ],
        "properties": {
          "amountMicro": {
            "type": "integer",
            "minimum": 1000000
          },
          "channel": {
            "type": "string",
            "enum": [
              "WECHAT_NATIVE",
              "ALIPAY_PC",
              "STRIPE",
              "PAYPAL"
            ]
          }
        }
      },
      "CheckoutIntentResponse": {
        "type": "object",
        "required": [
          "intentId",
          "channel",
          "amountMicro",
          "checkoutUrl"
        ],
        "properties": {
          "intentId": {
            "type": "string"
          },
          "channel": {
            "type": "string"
          },
          "amountMicro": {
            "type": "integer"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "VoucherRedeemRequest": {
        "type": "object",
        "required": [
          "voucherCode"
        ],
        "properties": {
          "voucherCode": {
            "type": "string"
          }
        }
      },
      "ActivityBucket": {
        "type": "object",
        "required": [
          "date",
          "model",
          "provider",
          "workspaceKey",
          "requests",
          "promptTokens",
          "completionTokens",
          "costMicro"
        ],
        "properties": {
          "date": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "requests": {
            "type": "integer"
          },
          "promptTokens": {
            "type": "integer"
          },
          "completionTokens": {
            "type": "integer"
          },
          "reasoningTokens": {
            "type": "integer"
          },
          "cachedTokens": {
            "type": "integer"
          },
          "costMicro": {
            "type": "integer"
          },
          "byokRequests": {
            "type": "integer"
          }
        }
      },
      "GuardrailUpsertRequest": {
        "type": "object",
        "required": [
          "name",
          "scope"
        ],
        "properties": {
          "scope": {
            "type": "string",
            "enum": [
              "ACCOUNT",
              "WORKSPACE"
            ]
          },
          "workspaceKey": {
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "maxCostPerRequestMicro": {
            "type": [
              "integer",
              "null"
            ]
          },
          "maxPromptChars": {
            "type": [
              "integer",
              "null"
            ]
          },
          "blockPii": {
            "type": "boolean"
          },
          "blockedRegexes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "allowedModels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "blockedModels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "assignedTargets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "GuardrailRecord": {
        "allOf": [
          {
            "$ref": "#/components/schemas/GuardrailUpsertRequest"
          },
          {
            "type": "object",
            "required": [
              "guardrailId",
              "hitsCount",
              "updatedAt"
            ],
            "properties": {
              "guardrailId": {
                "type": "string"
              },
              "hitsCount": {
                "type": "integer"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "PresetUpsertRequest": {
        "type": "object",
        "required": [
          "slug",
          "displayName",
          "model"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "fallbackModels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "systemPrompt": {
            "type": "string"
          },
          "temperature": {
            "type": "number"
          },
          "maxTokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "providerSort": {
            "type": "string",
            "enum": [
              "throughput",
              "price",
              "latency"
            ]
          },
          "zdrOnly": {
            "type": "boolean"
          }
        }
      },
      "PresetRecord": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PresetUpsertRequest"
          },
          {
            "type": "object",
            "required": [
              "presetId",
              "version",
              "updatedAt"
            ],
            "properties": {
              "presetId": {
                "type": "string"
              },
              "version": {
                "type": "integer"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "ByokUpsertRequest": {
        "type": "object",
        "required": [
          "providerSlug",
          "label"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "providerSlug": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "plaintextApiKey": {
            "type": "string"
          },
          "alwaysUseByok": {
            "type": "boolean"
          },
          "fallbackToPlatformCredits": {
            "type": "boolean"
          }
        }
      },
      "ByokRecord": {
        "type": "object",
        "required": [
          "credentialId",
          "workspaceKey",
          "providerSlug",
          "label",
          "keyHint",
          "alwaysUseByok",
          "fallbackToPlatformCredits",
          "status",
          "updatedAt"
        ],
        "properties": {
          "credentialId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "providerSlug": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "keyHint": {
            "type": "string"
          },
          "alwaysUseByok": {
            "type": "boolean"
          },
          "fallbackToPlatformCredits": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DISABLED",
              "REVOKED"
            ]
          },
          "lastVerifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BroadcastSinkUpsertRequest": {
        "type": "object",
        "required": [
          "destinationType",
          "name",
          "endpointUrl"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "destinationType": {
            "type": "string",
            "enum": [
              "arize",
              "langfuse",
              "datadog",
              "honeycomb",
              "braintrust",
              "otlp",
              "s3"
            ]
          },
          "name": {
            "type": "string"
          },
          "endpointUrl": {
            "type": "string",
            "format": "uri"
          },
          "authHeaderSecret": {
            "type": "string"
          },
          "samplingRate": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "enabled": {
            "type": "boolean"
          }
        }
      },
      "BroadcastSinkRecord": {
        "type": "object",
        "required": [
          "sinkId",
          "workspaceKey",
          "destinationType",
          "name",
          "endpointUrl",
          "samplingRate",
          "enabled",
          "lastDeliveryStatus",
          "updatedAt"
        ],
        "properties": {
          "sinkId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "destinationType": {
            "type": "string",
            "enum": [
              "arize",
              "langfuse",
              "datadog",
              "honeycomb",
              "braintrust",
              "otlp",
              "s3"
            ]
          },
          "name": {
            "type": "string"
          },
          "endpointUrl": {
            "type": "string"
          },
          "authHeaderHint": {
            "type": "string"
          },
          "samplingRate": {
            "type": "number"
          },
          "enabled": {
            "type": "boolean"
          },
          "lastDeliveryStatus": {
            "type": "string",
            "enum": [
              "IDLE",
              "OK",
              "FAILED"
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RoutingPolicy": {
        "type": "object",
        "required": [
          "workspaceKey",
          "defaultModel",
          "fallbackModels",
          "providerSort",
          "allowFallbacks",
          "zdrOnly",
          "dataCollectionDeny",
          "minQuantization",
          "ignoredProviders"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "defaultModel": {
            "type": "string"
          },
          "fallbackModels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "providerSort": {
            "type": "string",
            "enum": [
              "throughput",
              "price",
              "latency"
            ]
          },
          "allowFallbacks": {
            "type": "boolean"
          },
          "zdrOnly": {
            "type": "boolean"
          },
          "dataCollectionDeny": {
            "type": "boolean"
          },
          "minQuantization": {
            "type": "string",
            "enum": [
              "none",
              "fp16",
              "bf16",
              "fp8",
              "int8"
            ]
          },
          "ignoredProviders": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ServerToolConfig": {
        "type": "object",
        "required": [
          "workspaceKey",
          "webSearchEnabled",
          "webSearchMaxResults",
          "pdfParserEnabled",
          "responseHealingEnabled",
          "imageGenEnabled"
        ],
        "properties": {
          "workspaceKey": {
            "type": "string"
          },
          "webSearchEnabled": {
            "type": "boolean"
          },
          "webSearchMaxResults": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20
          },
          "pdfParserEnabled": {
            "type": "boolean"
          },
          "responseHealingEnabled": {
            "type": "boolean"
          },
          "imageGenEnabled": {
            "type": "boolean"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClassifierRule": {
        "type": "object",
        "required": [
          "name",
          "intentKind",
          "targetModel",
          "confidenceThreshold",
          "enabled"
        ],
        "properties": {
          "classifierId": {
            "type": "string"
          },
          "workspaceKey": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "intentKind": {
            "type": "string",
            "enum": [
              "coding",
              "reasoning",
              "general_chat",
              "vision",
              "translation"
            ]
          },
          "targetModel": {
            "type": "string"
          },
          "confidenceThreshold": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "enabled": {
            "type": "boolean"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "NotificationRule": {
        "type": "object",
        "required": [
          "lowBalanceEnabled",
          "lowBalanceThresholdMicro",
          "monthlyDigestEnabled",
          "byokFailureAlertEnabled"
        ],
        "properties": {
          "lowBalanceEnabled": {
            "type": "boolean"
          },
          "lowBalanceThresholdMicro": {
            "type": "integer"
          },
          "monthlyDigestEnabled": {
            "type": "boolean"
          },
          "byokFailureAlertEnabled": {
            "type": "boolean"
          },
          "webhookUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "IpAllowlistPolicy": {
        "type": "object",
        "required": [
          "enabled",
          "cidrs",
          "applyToInferenceKeys",
          "applyToManagementKeys"
        ],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "cidrs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "applyToInferenceKeys": {
            "type": "boolean"
          },
          "applyToManagementKeys": {
            "type": "boolean"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AutoTopupPolicy": {
        "type": "object",
        "required": [
          "enabled",
          "thresholdMicro",
          "reloadAmountMicro",
          "monthlyCapMicro",
          "paymentChannel"
        ],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "thresholdMicro": {
            "type": "integer"
          },
          "reloadAmountMicro": {
            "type": "integer"
          },
          "monthlyCapMicro": {
            "type": "integer"
          },
          "paymentChannel": {
            "type": "string",
            "enum": [
              "WECHAT_NATIVE",
              "ALIPAY_PC",
              "STRIPE",
              "PAYPAL"
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "MYRILUM Router Public Documentation & Manifold Catalog",
    "url": "https://myrilum.cn/router/docs"
  },
  "x-myrilum-region": "CN",
  "x-myrilum-openapi-url": "https://myrilum.cn/router/openapi.json",
  "x-myrilum-catalog-url": "https://myrilum.cn/router/api/v1/index.json",
  "x-myrilum-snapshot": {
    "snapshotVersion": "1.1.0",
    "snapshotDate": "2026-11-21",
    "dataProvenance": "UNMEASURED_REFERENCE_BASELINE"
  }
}
