{
  "openapi": "3.1.0",
  "info": {
    "title": "Animica Free AI API",
    "version": "9.0.0",
    "description": "Free, OpenAI-compatible inference. No API key required. Every response includes a post-quantum-signed proof-of-inference receipt. Funded by the Animica foundation treasury.",
    "contact": {
      "name": "Animica",
      "url": "https://animica.dev/"
    },
    "license": {
      "name": "Free to use"
    }
  },
  "servers": [
    {
      "url": "https://animica.dev/v1",
      "description": "Free public endpoint (no auth)"
    }
  ],
  "paths": {
    "/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List available models",
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            }
          }
        }
      }
    },
    "/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion (OpenAI-compatible)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completion (or SSE stream if stream=true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (30 req/min per IP) \u2014 back off and retry"
          }
        }
      }
    },
    "/embeddings": {
      "post": {
        "operationId": "createEmbedding",
        "summary": "Create embeddings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Embedding vectors"
          }
        }
      }
    },
    "/api/mkt/v1/media/uploads": {
      "post": {
        "summary": "Upload a binary input for a GPU Studios media job",
        "description": "Raw binary body (no multipart). Caps: video/blend 512 MB, audio/reference 200 MB. Unconsumed uploads expire after 4 h; inputs are wiped when the owning job delivers or expires.",
        "parameters": [
          {
            "name": "content-type",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-anm-purpose",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "video",
                "audio",
                "blend",
                "reference"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored"
          },
          "413": {
            "description": "File exceeds the size cap"
          },
          "429": {
            "description": "Rate limited"
          },
          "507": {
            "description": "Gateway storage full"
          }
        }
      }
    },
    "/api/mkt/v1/media/jobs": {
      "post": {
        "summary": "Submit a media job to the GPU-miner queue",
        "description": "GPU Studios kinds (9.0.0): video_upscale, video_interpolate, video_subtitles, video_bgremove, video_shorts, audio_stems, audio_isolate, audio_enhance, audio_master, render_blender. Plus existing prompt kinds (image, video_t2v, video_multiscene, video_i2v, audio). Upload-consuming jobs reference inputs via upload_ids.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object"
                  },
                  "upload_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued"
          }
        }
      }
    },
    "/api/mkt/v1/media/jobs/{id}": {
      "get": {
        "summary": "Poll a media job",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job state; small results inline as result.b64, large results at result_url; render_blender parents report chunks_done/chunks_total"
          }
        }
      }
    },
    "/api/mkt/v1/media/artifacts/{id}": {
      "get": {
        "summary": "Download a finished job's artifact",
        "description": "Streams the result (mime + Content-Disposition). Addressed by job id (from result_url). Wiped on TTL (6 h private / 24 h public).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The artifact bytes"
          },
          "404": {
            "description": "Unknown job or artifact wiped"
          }
        }
      }
    },
    "/api/mkt/v1/media/capabilities": {
      "get": {
        "summary": "Live per-kind GPU-miner availability",
        "responses": {
          "200": {
            "description": "Counts of online miners per job kind"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ModelList": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ChatRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "default": "animica-chat",
            "description": "e.g. animica-chat, animica-chat-small, animica-chat-flagship (see GET /v1/models)"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "system",
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "type": "string"
                }
              },
              "required": [
                "role",
                "content"
              ]
            }
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "temperature": {
            "type": "number",
            "default": 0.7
          },
          "max_tokens": {
            "type": "integer"
          }
        }
      },
      "ChatResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    }
                  }
                },
                "finish_reason": {
                  "type": "string"
                }
              }
            }
          },
          "usage": {
            "type": "object"
          },
          "animica_receipt": {
            "type": "object",
            "description": "Post-quantum (ML-DSA-65) signed proof-of-inference receipt"
          }
        }
      },
      "EmbeddingRequest": {
        "type": "object",
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "default": "animica-embed"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          }
        }
      }
    }
  }
}