{
  "openapi": "3.1.0",
  "info": {
    "title": "Jarvis Cloud API",
    "version": "1.0.0",
    "summary": "OpenAI-compatible inference API for the Autonomous AI ecosystem.",
    "description": "Point any OpenAI SDK at `https://autonomousintelligence.io/v1` with a `jc_live_` API key. One API, multiple models, streaming, wallet-native billing in credits.",
    "contact": { "name": "Autonomous AI", "url": "https://autonomousintelligence.io" }
  },
  "servers": [
    { "url": "https://autonomousintelligence.io/v1", "description": "Production" }
  ],
  "security": [ { "bearerAuth": [] } ],
  "paths": {
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion",
        "description": "OpenAI-compatible chat completion. Set `stream: true` for token-by-token Server-Sent Events. Billed by total tokens against your credit balance; a request that returns no work is never charged.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A chat completion, or an SSE stream when `stream` is true.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ChatCompletionResponse" } },
              "text/event-stream": { "schema": { "type": "string", "description": "SSE frames: `data: {chat.completion.chunk}` ... terminated by `data: [DONE]`." } }
            }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "401": { "$ref": "#/components/responses/Error" },
          "402": { "$ref": "#/components/responses/Error" },
          "429": { "$ref": "#/components/responses/Error" },
          "502": { "$ref": "#/components/responses/Error" }
        }
      }
    },
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List available models",
        "responses": {
          "200": {
            "description": "The list of models.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": { "type": "string", "const": "list" },
                    "data": { "type": "array", "items": { "$ref": "#/components/schemas/Model" } }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your API key from the Jarvis Cloud console, e.g. `Authorization: Bearer jc_live_...`."
      }
    },
    "responses": {
      "Error": {
        "description": "OpenAI-compatible error envelope.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string" },
                    "type": { "type": "string" },
                    "code": { "type": [ "string", "null" ] },
                    "param": { "type": [ "string", "null" ] }
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "type": "object",
        "required": [ "model", "messages" ],
        "properties": {
          "model": { "type": "string", "enum": [ "jarvis-70b", "jarvis-8b", "jarvis-120b" ], "default": "jarvis-70b", "description": "Model id. Common OpenAI ids (e.g. gpt-4o) alias to the closest Jarvis model." },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": { "$ref": "#/components/schemas/Message" }
          },
          "stream": { "type": "boolean", "default": false, "description": "Stream the response as SSE." },
          "max_tokens": { "type": "integer", "minimum": 1, "maximum": 8192, "default": 1024 },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "stop": { "type": [ "string", "array" ], "items": { "type": "string" } },
          "tools": { "type": "array", "description": "OpenAI-format tool definitions (function calling is passed through where the model supports it)." },
          "tool_choice": {},
          "response_format": { "type": "object", "description": "e.g. { \"type\": \"json_object\" }." }
        }
      },
      "Message": {
        "type": "object",
        "required": [ "role", "content" ],
        "properties": {
          "role": { "type": "string", "enum": [ "system", "user", "assistant", "tool" ] },
          "content": { "type": "string" }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "object": { "type": "string", "const": "chat.completion" },
          "created": { "type": "integer" },
          "model": { "type": "string" },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": { "type": "integer" },
                "message": { "$ref": "#/components/schemas/Message" },
                "finish_reason": { "type": [ "string", "null" ] }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": { "type": "integer" },
              "completion_tokens": { "type": "integer" },
              "total_tokens": { "type": "integer" }
            }
          }
        }
      },
      "Model": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "object": { "type": "string", "const": "model" },
          "created": { "type": "integer" },
          "owned_by": { "type": "string", "const": "autonomous-ai" },
          "context_window": { "type": "integer" }
        }
      }
    }
  }
}
