{
  "openapi": "3.1.0",
  "info": {
    "title": "ChinaGenAI short-text API starter",
    "version": "2026-10-21",
    "description": "Documented short-text request subset. Full compatibility and limits: https://chinagenai.com/connect . Free label selects automatic routing; named models are not guaranteed. This is not the complete OpenAI API."
  },
  "servers": [
    {
      "url": "https://chinagenai.com"
    }
  ],
  "paths": {
    "/api/status": {
      "get": {
        "operationId": "getEnablement",
        "summary": "Enablement and configured limits; no inference",
        "responses": {
          "200": {
            "description": "Current site configuration checks; not an uptime guarantee",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ready",
                    "status",
                    "limits"
                  ],
                  "properties": {
                    "ready": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "available",
                        "paused"
                      ]
                    },
                    "limits": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listSiteModels",
        "summary": "List free route when enabled; no inference",
        "responses": {
          "200": {
            "description": "Model list; data is empty when the pool is paused.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "const": "free"
                          },
                          "object": {
                            "const": "model"
                          },
                          "owned_by": {
                            "const": "chinagenai"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createShortChat",
        "summary": "Generate a short text completion",
        "description": "Uses allowance. Requires a site key. At most 6 messages and 6,000characters in the normalized input JSON including tool schemas. Output capped at 256 tokens. One concurrent request per key; shared site limits apply. stream=true yields buffered SSE after the upstream completes.",
        "security": [
          {
            "siteKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "default": "free",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "messages": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 6,
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "enum": [
                            "system",
                            "developer",
                            "user",
                            "assistant"
                          ]
                        },
                        "content": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "max_tokens": {
                    "type": "integer",
                    "minimum": 1,
                    "default": 256,
                    "description": "Values above256 are capped by the route."
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "example": {
                  "model": "free",
                  "messages": [
                    {
                      "role": "user",
                      "content": "Reply in one short sentence."
                    }
                  ],
                  "max_tokens": 128,
                  "stream": false
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat Completions JSON, or buffered SSE when stream=true.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Request rejected or upstream unavailable; error code and message explain the outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Request rejected or upstream unavailable; error code and message explain the outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Request rejected or upstream unavailable; error code and message explain the outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Request rejected or upstream unavailable; error code and message explain the outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Request rejected or upstream unavailable; error code and message explain the outcome.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "siteKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A ChinaGenAI site key. Set it locally; no key is included in this file."
      }
    }
  }
}
