{
  "openapi": "3.1.0",
  "info": {
    "title": "Aitherium Public Developer API",
    "version": "2.5.0",
    "summary": "Public HTTPS APIs for Bonsai 2.5 inference, embeddings, audio, MCP, AitherRetrieval, A2A, Workflows, Agent Notebooks, and AitherIdentity.",
    "description": "Canonical public API specification for the Aitherium platform. OpenAI-compatible inference and Streamable HTTP MCP live on https://mcp.aitherium.com (with https://gateway.aitherium.com fronting the same gateway origin). Platform workflows, Agent Notebooks (.anb), and OpenAW live on https://api.aitherium.com; hybrid search and document ingest live on https://retrieval.aitherium.com; OIDC / OAuth 2.1 and RFC 8628 Device Flow live on https://id.aitherium.com.",
    "contact": {
      "name": "Aitherium Developer Support",
      "email": "agents@aitherium.com",
      "url": "https://developer.aitherium.com"
    }
  },
  "servers": [
    {
      "url": "https://mcp.aitherium.com",
      "description": "Canonical public MCP and OpenAI-compatible inference gateway"
    },
    {
      "url": "https://gateway.aitherium.com",
      "description": "Public AI and tool gateway alias (same origin as mcp.aitherium.com)"
    },
    {
      "url": "https://api.aitherium.com",
      "description": "Platform and workspace API (workflows, notebooks, OpenAW, licenses, doors)"
    },
    {
      "url": "https://retrieval.aitherium.com",
      "description": "AitherRetrieval hybrid search, vector/graph/code search, and document ingest API"
    },
    {
      "url": "https://id.aitherium.com",
      "description": "AitherIdentity OIDC / OAuth 2.1 + PKCE and Device Flow provider"
    }
  ],
  "externalDocs": {
    "description": "Aitherium Developer Portal & Machine-Readable Documentation",
    "url": "https://developer.aitherium.com/llms.txt"
  },
  "tags": [
    {
      "name": "MCP & Discovery",
      "description": "Streamable HTTP MCP transport, routed 3-tool mode, tool manifests, and well-known discovery documents"
    },
    {
      "name": "Inference & Audio",
      "description": "OpenAI-compatible chat completions (Bonsai 2.5 27B, Bonsai 2 4B, Gemma 4 12B, DeepSeek V4 Flash), embeddings (aither-code-embed), STT, and TTS"
    },
    {
      "name": "Auth & Device Flow",
      "description": "OIDC / OAuth 2.1 + PKCE, RFC 8628 CLI Device Flow, API keys, wallet balance, and x402 top-ups"
    },
    {
      "name": "Retrieval",
      "description": "AitherRetrieval hybrid, vector, text, graph, code, and memory search plus document/artifact ingest"
    },
    {
      "name": "A2A",
      "description": "Google A2A v0.3.0 agent discovery, JSON-RPC 2.0 messaging/tasks, SSE streaming, and signed delegation"
    },
    {
      "name": "Workflows",
      "description": "Deterministic multi-stage workflow definitions, execution, lineage, stage replay, and human approval gates"
    },
    {
      "name": "Agent Notebooks",
      "description": "Executable, reviewable .anb Agent Notebooks with 14 typed cells, interactive sessions, and SSE streaming"
    },
    {
      "name": "Platform & OpenAW",
      "description": "OpenAW public projects/posts, door capability attestation, and x402 agent brief"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "ACTA API key (aither_sk_live_*), workspace/external key (ak_*, aither_ext_*), endpoint-scoped bearer (endpoint:retrieval, endpoint:a2a), or OAuth 2.1 access token from https://id.aitherium.com"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Workspace or external agent API key alternative to Authorization: Bearer"
      },
      "anonToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Anon-Token",
        "description": "Short-lived anonymous token issued by POST /api/v1/anon/register for POST /api/v1/chat/hosted"
      },
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://id.aitherium.com/oidc/authorize",
            "tokenUrl": "https://id.aitherium.com/oidc/token",
            "scopes": {
              "openid": "OpenID Connect identity",
              "agent:read": "Read agent state and catalogs",
              "agent:write": "Invoke inference and act as an agent",
              "tools:execute": "Run MCP tools",
              "endpoint:retrieval": "Access tenant-scoped AitherRetrieval endpoints",
              "endpoint:a2a": "Access tenant-scoped A2A endpoints"
            }
          }
        }
      }
    },
    "schemas": {
      "GatewayFlatError": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message or machine code (e.g. rate_limit_exceeded)"
          },
          "retry_after": {
            "type": "integer",
            "description": "Seconds to wait before retrying (present on HTTP 429)"
          }
        }
      },
      "RetrievalErrorEnvelope": {
        "type": "object",
        "required": ["success", "error", "request_id"],
        "properties": {
          "success": { "type": "boolean", "const": false },
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "description": "Structured RET-* error code (RET-1001..6002)"
              },
              "message": { "type": "string" },
              "details": { "type": "object" }
            }
          },
          "request_id": { "type": "string" },
          "metadata": { "type": "object" },
          "duration_ms": { "type": "number" },
          "data": { "type": "object" }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": ["jsonrpc", "method"],
        "properties": {
          "jsonrpc": { "type": "string", "const": "2.0" },
          "id": { "type": ["string", "integer", "null"] },
          "method": { "type": "string" },
          "params": { "type": "object" }
        }
      },
      "JsonRpcError": {
        "type": "object",
        "required": ["jsonrpc", "error"],
        "properties": {
          "jsonrpc": { "type": "string", "const": "2.0" },
          "id": { "type": ["string", "integer", "null"] },
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": { "type": "integer" },
              "message": { "type": "string" },
              "data": {}
            }
          }
        }
      },
      "ChatMessage": {
        "type": "object",
        "required": ["role", "content"],
        "properties": {
          "role": {
            "type": "string",
            "enum": ["system", "user", "assistant", "tool"]
          },
          "content": {
            "oneOf": [
              { "type": "string" },
              {
                "type": "array",
                "description": "Multimodal content parts (text and OpenAI image_url parts for Bonsai 2.5 / Gemma 4)",
                "items": { "type": "object" }
              }
            ]
          },
          "name": { "type": "string" },
          "tool_call_id": { "type": "string" }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": {
            "type": "string",
            "description": "Public gateway model ID. Recommended: aither-bonsai (Bonsai 2.5 27B) or aither-small (free Bonsai 2 4B lane).",
            "enum": [
              "aither-small",
              "aither-bonsai",
              "aither-orchestrator",
              "aither-deliberate",
              "aither-vision",
              "aither-coding",
              "aither-reasoning"
            ]
          },
          "messages": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/ChatMessage" }
          },
          "stream": { "type": "boolean", "default": false },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": { "type": "boolean" }
            }
          },
          "max_tokens": { "type": "integer", "minimum": 1 },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "top_k": { "type": "integer", "minimum": 0 },
          "min_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "min_tokens": { "type": "integer", "minimum": 0 },
          "seed": { "type": "integer" },
          "stop": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "string" } }
            ]
          },
          "tools": {
            "type": "array",
            "description": "OpenAI function tool definitions",
            "items": { "type": "object" }
          },
          "tool_choice": {
            "oneOf": [
              { "type": "string", "enum": ["auto", "none", "required"] },
              { "type": "object" }
            ]
          },
          "response_format": {
            "type": "object",
            "description": "Structured output format ({type: json_object} or json_schema)"
          },
          "logprobs": { "type": "boolean" },
          "top_logprobs": { "type": "integer", "minimum": 0, "maximum": 20 },
          "chat_template_kwargs": {
            "type": "object",
            "description": "Reasoning control, e.g. {\"enable_thinking\": true}",
            "properties": {
              "enable_thinking": { "type": "boolean" }
            }
          }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": ["id", "object", "created", "model", "choices"],
        "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": {
                  "type": "object",
                  "properties": {
                    "role": { "type": "string" },
                    "content": { "type": ["string", "null"] },
                    "reasoning_content": { "type": ["string", "null"] },
                    "tool_calls": { "type": "array", "items": { "type": "object" } }
                  }
                },
                "finish_reason": { "type": ["string", "null"] }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": { "type": "integer" },
              "completion_tokens": { "type": "integer" },
              "total_tokens": { "type": "integer" }
            }
          },
          "aither_route": {
            "type": "object",
            "description": "Honest routing provenance disclosing actual serving lane",
            "properties": {
              "served_by": { "type": "string" },
              "cross_model": { "type": "boolean" }
            }
          },
          "aither_deliberation": {
            "type": "object",
            "description": "Present on aither-deliberate structured reasoning responses",
            "properties": {
              "analysis": { "type": "string" },
              "viable": { "type": "boolean" }
            }
          }
        }
      },
      "EmbeddingRequest": {
        "type": "object",
        "required": ["input"],
        "properties": {
          "model": {
            "type": "string",
            "default": "aither-code-embed",
            "description": "aither-code-embed (1024-dim, Apache-2.0). Legacy nomic-embed-text is rewritten transparently."
          },
          "input": {
            "oneOf": [
              { "type": "string", "maxLength": 32000 },
              {
                "type": "array",
                "maxItems": 256,
                "items": { "type": "string", "maxLength": 32000 }
              }
            ]
          }
        }
      },
      "RetrievalSearchRequest": {
        "type": "object",
        "required": ["query"],
        "properties": {
          "query": { "type": "string" },
          "modality": {
            "type": "string",
            "enum": ["hybrid", "vector", "text", "graph", "code", "memory"]
          },
          "collection": { "type": "string" },
          "limit": { "type": "integer", "minimum": 1, "maximum": 100, "default": 10 },
          "cursor": { "type": "string" },
          "filters": { "type": "object" }
        }
      },
      "RetrievalIngestRequest": {
        "type": "object",
        "required": ["content"],
        "properties": {
          "content": { "type": "string" },
          "doc_id": { "type": "string" },
          "collection": { "type": "string" },
          "source": { "type": "string" },
          "metadata": { "type": "object" },
          "idempotency_key": { "type": "string" }
        }
      },
      "WorkflowDefinition": {
        "type": "object",
        "required": ["name", "stages"],
        "properties": {
          "name": { "type": "string" },
          "description": { "type": "string" },
          "budget_tokens": { "type": "integer" },
          "stages": {
            "type": "array",
            "items": { "type": "object" }
          }
        }
      },
      "NotebookCreateRequest": {
        "type": "object",
        "required": ["title"],
        "properties": {
          "title": { "type": "string" },
          "description": { "type": "string" },
          "cells": {
            "type": "array",
            "description": "Typed .anb cells (context, plan, note, result, prompt, tool_call, agent_delegate, service_call, transform, checkpoint, parallel_block, loop, condition, script)",
            "items": { "type": "object" }
          }
        }
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "gatewayHealth",
        "summary": "Gateway liveness and route health",
        "responses": {
          "200": { "description": "Gateway is healthy" }
        }
      }
    },
    "/.well-known/oauth-protected-resource": {
      "get": {
        "tags": ["MCP & Discovery", "Auth & Device Flow"],
        "operationId": "oauthProtectedResource",
        "summary": "RFC 9728 OAuth 2.1 protected-resource metadata for MCP clients",
        "responses": {
          "200": { "description": "Protected resource metadata pointing to AitherIdentity" }
        }
      }
    },
    "/.well-known/mcp.json": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpDiscovery",
        "summary": "Machine-readable MCP server discovery metadata",
        "responses": {
          "200": { "description": "MCP server metadata and capabilities" }
        }
      }
    },
    "/.well-known/mcp-registry.json": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpRegistry",
        "summary": "MCP servers fronted by this gateway",
        "responses": {
          "200": { "description": "MCP registry document" }
        }
      }
    },
    "/.well-known/doors.json": {
      "get": {
        "tags": ["MCP & Discovery", "Platform & OpenAW"],
        "operationId": "doorsDiscovery",
        "summary": "List of public door-gated surfaces and their capability requirements",
        "responses": {
          "200": { "description": "Doors registry document" }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpPost",
        "summary": "Streamable HTTP MCP JSON-RPC 2.0 endpoint",
        "description": "Primary MCP transport (Streamable HTTP with Mcp-Session-Id). Supports initialize, tools/list, tools/call, and routed 3-tool mode via the CLI bridge (aither_find_tools, aither_call, aither_gateway_status).",
        "security": [{ "bearer": [] }, { "oauth2": ["tools:execute"] }],
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": false,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/JsonRpcRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "JSON-RPC 2.0 response or text/event-stream SSE stream" },
          "401": { "description": "Missing or invalid bearer / OAuth token" }
        }
      },
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpStream",
        "summary": "Open Streamable HTTP SSE notification channel for an MCP session",
        "security": [{ "bearer": [] }, { "oauth2": ["tools:execute"] }],
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "SSE event stream (text/event-stream)" }
        }
      },
      "delete": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpCloseSession",
        "summary": "Terminate an active MCP session",
        "security": [{ "bearer": [] }, { "oauth2": ["tools:execute"] }],
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "Session closed" }
        }
      }
    },
    "/tools/manifest": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "toolsManifest",
        "summary": "List available MCP tool schemas for the caller's tier",
        "security": [{ "bearer": [] }, { "oauth2": ["tools:execute"] }],
        "responses": {
          "200": { "description": "Tool manifest JSON" }
        }
      }
    },
    "/v1/tools/search": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "searchTools",
        "summary": "Search available MCP tools by keyword",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": { "type": "string" }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "default": 20, "maximum": 100 }
          }
        ],
        "responses": {
          "200": { "description": "Matching tools with descriptions and input schemas" }
        }
      }
    },
    "/v1/mcp/config/{ide}": {
      "get": {
        "tags": ["MCP & Discovery"],
        "operationId": "mcpIdeConfig",
        "summary": "Generate a ready-to-paste MCP client configuration for an IDE or harness",
        "parameters": [
          {
            "name": "ide",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["claude-code", "antigravity", "cursor", "windsurf", "vscode", "codex", "gemini", "opencode", "hermes"]
            }
          }
        ],
        "responses": {
          "200": { "description": "IDE-specific MCP configuration snippet" }
        }
      }
    },
    "/v1/models": {
      "get": {
        "tags": ["Inference & Audio"],
        "operationId": "listModels",
        "summary": "List public inference models available to the caller's tier",
        "responses": {
          "200": { "description": "OpenAI-compatible model list (includes aither-small, aither-bonsai [Bonsai 2.5 27B], aither-orchestrator, aither-deliberate, aither-vision, aither-coding, aither-reasoning)" }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "chatCompletions",
        "summary": "OpenAI-compatible chat completions (Bonsai 2.5 27B, Bonsai 2 4B, Gemma 4 12B, DeepSeek V4 Flash)",
        "description": "Public OpenAI-compatible inference endpoint. Keyless or unknown-bearer requests fall back to the anonymous free tier (aither-small) and never answer 401. Signed-in Starter+ keys unlock aither-bonsai (Bonsai 2.5 27B) and Pro keys unlock aither-vision, aither-coding, and aither-reasoning. All errors use a flat {\"error\": \"...\"} JSON envelope.",
        "security": [{}, { "bearer": [] }, { "oauth2": ["agent:write"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion object (or text/event-stream SSE chunks when stream=true)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChatCompletionResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid JSON, missing messages, or unknown model ID",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GatewayFlatError" }
              }
            }
          },
          "402": {
            "description": "Insufficient Aitherium token balance",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GatewayFlatError" }
              }
            }
          },
          "403": {
            "description": "Model requires a higher plan tier or is outside tenant allowlist",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GatewayFlatError" }
              }
            }
          },
          "429": {
            "description": "Rate or per-model concurrency limit exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GatewayFlatError" }
              }
            }
          },
          "502": { "description": "Upstream inference backend error" },
          "503": { "description": "Inference lane unavailable (honest no_substitute refusal)" }
        }
      }
    },
    "/v1/hosted/chat/completions": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "hostedChatCompletions",
        "summary": "Strict-auth metered hosted chat completions",
        "description": "Unlike /v1/chat/completions, missing or invalid credentials return HTTP 401 and daily quota caps are enforced before inference starts.",
        "security": [{ "bearer": [] }, { "oauth2": ["agent:write"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion object",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChatCompletionResponse" }
              }
            }
          },
          "401": { "description": "Missing or invalid API key" },
          "402": { "description": "Insufficient credit balance" },
          "403": { "description": "Scope or plan entitlement mismatch" },
          "429": { "description": "Daily quota exceeded" }
        }
      }
    },
    "/v1/hosted/chat/completions/stream": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "hostedChatCompletionsStream",
        "summary": "Strict-auth metered hosted streaming chat completions (SSE)",
        "security": [{ "bearer": [] }, { "oauth2": ["agent:write"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "OpenAI-compatible SSE stream (text/event-stream)" },
          "401": { "description": "Missing or invalid API key" }
        }
      }
    },
    "/api/v1/chat/hosted": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "anonHostedChat",
        "summary": "Anonymous hosted Bonsai chat floor (X-Anon-Token required)",
        "description": "Rate-limited anonymous Bonsai endpoint (60 requests/day per principal, 300/day per IP; inline base64 images up to 5 MB).",
        "security": [{ "anonToken": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Chat completion response" },
          "401": { "description": "Missing or expired X-Anon-Token" },
          "429": { "description": "Anonymous daily quota exceeded" }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "createEmbeddings",
        "summary": "OpenAI-compatible text and code embeddings (aither-code-embed, 1024-dim)",
        "description": "Generates 1024-dimensional embeddings via aither-code-embed (Apache-2.0, up to 256 strings per batch, max 32,000 chars each). Free across all tiers.",
        "security": [{}, { "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/EmbeddingRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "OpenAI-compatible embedding list with 1024-dim float vectors" },
          "400": { "description": "Missing input or batch limit exceeded" }
        }
      }
    },
    "/v1/audio/speech": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "createSpeech",
        "summary": "OpenAI-compatible text-to-speech (Kokoro-82M & aither-voice)",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["input"],
                "properties": {
                  "model": { "type": "string", "default": "kokoro-82m" },
                  "voice": { "type": "string", "description": "e.g. kokoro:af_heart or local:aither" },
                  "input": { "type": "string" },
                  "response_format": { "type": "string", "enum": ["mp3", "wav", "opus", "flac"], "default": "mp3" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Synthesized audio binary stream" }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "tags": ["Inference & Audio"],
        "operationId": "createTranscription",
        "summary": "OpenAI-compatible speech-to-text (faster-distil-whisper-large-v3)",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["file"],
                "properties": {
                  "file": { "type": "string", "format": "binary" },
                  "model": { "type": "string", "default": "faster-distil-whisper-large-v3" },
                  "language": { "type": "string" },
                  "response_format": { "type": "string", "enum": ["json", "text", "srt", "vtt"], "default": "json" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Transcription result" }
        }
      }
    },
    "/.well-known/openid-configuration": {
      "servers": [{ "url": "https://id.aitherium.com" }],
      "get": {
        "tags": ["Auth & Device Flow"],
        "operationId": "openidConfiguration",
        "summary": "AitherIdentity OpenID Connect discovery document",
        "responses": {
          "200": { "description": "OIDC issuer, JWKS URI, authorization/token/device endpoints" }
        }
      }
    },
    "/auth/device/code": {
      "servers": [{ "url": "https://id.aitherium.com" }],
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "idpDeviceCode",
        "summary": "Start RFC 8628 CLI Device Flow (used by adk login)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_id": { "type": "string" },
                  "scope": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "device_code, user_code, verification_uri, interval, expires_in" }
        }
      }
    },
    "/auth/device/token": {
      "servers": [{ "url": "https://id.aitherium.com" }],
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "idpDeviceToken",
        "summary": "Poll RFC 8628 Device Flow until approved and exchange for access token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["device_code"],
                "properties": {
                  "device_code": { "type": "string" },
                  "grant_type": { "type": "string", "default": "urn:ietf:params:oauth:grant-type:device_code" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Issued OAuth 2.1 access_token and refresh_token" },
          "400": { "description": "authorization_pending, slow_down, or expired_token" }
        }
      }
    },
    "/v1/auth/device/code": {
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "gatewayDeviceCode",
        "summary": "Start gateway-mediated device-flow sign-in",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "client_name": { "type": "string" },
                  "scopes": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "device_code, user_code, verification_uri, interval, expires_in" }
        }
      }
    },
    "/v1/auth/device/poll": {
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "gatewayDevicePoll",
        "summary": "Poll a gateway device code until approved",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["device_code"],
                "properties": {
                  "device_code": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "pending or issued credential" },
          "400": { "description": "expired_token or invalid_request" }
        }
      }
    },
    "/auth/me/api-keys": {
      "servers": [{ "url": "https://id.aitherium.com" }],
      "get": {
        "tags": ["Auth & Device Flow"],
        "operationId": "listPersonalApiKeys",
        "summary": "List personal API keys for the signed-in user",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "Active API key metadata (prefixes and scopes, never raw secrets)" }
        }
      },
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "createPersonalApiKey",
        "summary": "Mint a new scoped personal API key",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string" },
                  "scopes": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Newly minted API key (shown once)" }
        }
      }
    },
    "/v1/auth/me": {
      "get": {
        "tags": ["Auth & Device Flow"],
        "operationId": "gatewayAuthMe",
        "summary": "Inspect caller identity, tenant, tier, and active scopes",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "Caller identity and tier summary" },
          "401": { "description": "Missing or invalid bearer" }
        }
      }
    },
    "/v1/billing/balance": {
      "get": {
        "tags": ["Auth & Device Flow"],
        "operationId": "billingBalance",
        "summary": "Check remaining Aitherium token balance and active plan",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "Current token balance, plan tier, and usage summary" }
        }
      }
    },
    "/v1/billing/x402/quote": {
      "get": {
        "tags": ["Auth & Device Flow"],
        "operationId": "x402Quote",
        "summary": "Get a live x402 credit top-up quote",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "x402 payment requirements and credit conversion quote" }
        }
      }
    },
    "/v1/billing/x402/topup": {
      "post": {
        "tags": ["Auth & Device Flow"],
        "operationId": "x402Topup",
        "summary": "Submit an x402 payment payload to credit account balance",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "Credits applied and updated balance returned" },
          "402": { "description": "x402 PaymentRequired challenge" }
        }
      }
    },
    "/ready": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "get": {
        "tags": ["Retrieval"],
        "operationId": "retrievalReady",
        "summary": "AitherRetrieval readiness probe",
        "responses": {
          "200": { "description": "Retrieval service ready" }
        }
      }
    },
    "/v1/meta": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalMeta",
        "summary": "Discover supported search modalities, pagination contract, and RET-* error codes",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "responses": {
          "200": { "description": "Retrieval capability metadata and RET-* error catalog" }
        }
      }
    },
    "/v1/search": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalSearch",
        "summary": "Unified search across vector, full-text, hybrid, graph, code, and memory modalities",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RetrievalSearchRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Ranked search hits with scores, provenance, and pagination cursor" },
          "403": {
            "description": "Tenant mismatch or missing endpoint:retrieval scope (RET-1003)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RetrievalErrorEnvelope" }
              }
            }
          }
        }
      }
    },
    "/v1/hybrid/search": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalHybridSearch",
        "summary": "Hybrid semantic + keyword retrieval",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RetrievalSearchRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Fused hybrid search results" }
        }
      }
    },
    "/v1/code/search": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalCodeSearch",
        "summary": "Semantic and symbol-aware code search",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RetrievalSearchRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Ranked code snippets and symbol locations" }
        }
      }
    },
    "/v1/recurse/answer": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalRecurseAnswer",
        "summary": "Recursive multi-hop grounded answer synthesis over tenant collections",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RetrievalSearchRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Synthesized answer with source citations" }
        }
      }
    },
    "/v1/ingest": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalIngest",
        "summary": "Ingest a document into tenant-isolated search and knowledge graph indexes",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RetrievalIngestRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "Document indexed with doc_id and chunk/graph counts" },
          "409": {
            "description": "Idempotency conflict (RET-4001)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RetrievalErrorEnvelope" }
              }
            }
          }
        }
      }
    },
    "/v1/documents/{doc_id}": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "get": {
        "tags": ["Retrieval"],
        "operationId": "retrievalGetDocument",
        "summary": "Fetch an indexed document and its metadata",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "parameters": [
          {
            "name": "doc_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "Document record" },
          "404": { "description": "Document not found (RET-3001)" }
        }
      },
      "delete": {
        "tags": ["Retrieval"],
        "operationId": "retrievalDeleteDocument",
        "summary": "Delete an indexed document from tenant collections",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "parameters": [
          {
            "name": "doc_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "Document deleted" }
        }
      }
    },
    "/v1/leases/acquire": {
      "servers": [{ "url": "https://retrieval.aitherium.com" }],
      "post": {
        "tags": ["Retrieval"],
        "operationId": "retrievalAcquireLease",
        "summary": "Acquire a short-lived write/index lease for coordinated ingestion",
        "security": [{ "bearer": [] }, { "oauth2": ["endpoint:retrieval"] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["resource"],
                "properties": {
                  "resource": { "type": "string" },
                  "ttl_seconds": { "type": "integer", "default": 60 }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Lease token and expiry" },
          "409": { "description": "Lease already held (RET-4002)" }
        }
      }
    },
    "/.well-known/agent-card.json": {
      "servers": [{ "url": "https://aitherium.com" }],
      "get": {
        "tags": ["A2A"],
        "operationId": "a2aAgentCard",
        "summary": "Canonical Google A2A v0.3.0 agent card discovery document",
        "responses": {
          "200": { "description": "A2A AgentCard JSON (name, capabilities, skills, auth schemes)" }
        }
      }
    },
    "/a2a": {
      "servers": [{ "url": "https://aitherium.com" }],
      "post": {
        "tags": ["A2A"],
        "operationId": "a2aJsonRpc",
        "summary": "A2A JSON-RPC 2.0 endpoint (message/send, message/stream, tasks/*, agents/list)",
        "security": [{ "bearer": [] }, { "apiKey": [] }, { "oauth2": ["endpoint:a2a"] }],
        "parameters": [
          {
            "name": "X-Signature",
            "in": "header",
            "required": false,
            "schema": { "type": "string" },
            "description": "Optional Ed25519 request signature for mesh agent trust"
          },
          {
            "name": "X-Public-Key",
            "in": "header",
            "required": false,
            "schema": { "type": "string" },
            "description": "Raw 32-byte hex Ed25519 public key"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/JsonRpcRequest" }
            }
          }
        },
        "responses": {
          "200": { "description": "JSON-RPC 2.0 response or SSE stream for message/stream" },
          "400": {
            "description": "JSON-RPC error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/JsonRpcError" }
              }
            }
          }
        }
      }
    },
    "/v1/agents/discover": {
      "get": {
        "tags": ["A2A"],
        "operationId": "discoverAgents",
        "summary": "Discover agents visible to the caller",
        "security": [{ "bearer": [] }, { "oauth2": ["agent:read"] }],
        "parameters": [
          {
            "name": "capability",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "default": 20 }
          }
        ],
        "responses": {
          "200": { "description": "Visible agent catalog" },
          "401": { "description": "Missing or invalid authentication" }
        }
      }
    },
    "/v1/agents/register": {
      "post": {
        "tags": ["A2A"],
        "operationId": "registerAgent",
        "summary": "Register an external or custom agent on the Aitherium network",
        "security": [{ "bearer": [] }, { "apiKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "capabilities"],
                "properties": {
                  "name": { "type": "string" },
                  "description": { "type": "string" },
                  "capabilities": { "type": "array", "items": { "type": "string" } },
                  "tools": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Registered agent record and credentials" }
        }
      }
    },
    "/workflows/": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Workflows"],
        "operationId": "listWorkflows",
        "summary": "List workspace workflows",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "List of workflow definitions" }
        }
      },
      "post": {
        "tags": ["Workflows"],
        "operationId": "createWorkflow",
        "summary": "Create a deterministic multi-stage workflow",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/WorkflowDefinition" }
            }
          }
        },
        "responses": {
          "201": { "description": "Workflow created" }
        }
      }
    },
    "/workflows/{workflow_id}/execute": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Workflows"],
        "operationId": "executeWorkflow",
        "summary": "Start a journaled workflow run with optional token budget",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "workflow_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "inputs": { "type": "object" },
                  "budget_tokens": { "type": "integer" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Run ID, initial status, and lineage link" }
        }
      }
    },
    "/workflows/runs/{run_id}": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Workflows"],
        "operationId": "getWorkflowRun",
        "summary": "Get workflow run status, stage outputs, and token accounting",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "Workflow run state and outputs" }
        }
      }
    },
    "/workflows/runs/{run_id}/gate/{stage_id}": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Workflows"],
        "operationId": "respondWorkflowGate",
        "summary": "Approve or reject a human-in-the-loop workflow gate",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          },
          {
            "name": "stage_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["decision"],
                "properties": {
                  "decision": { "type": "string", "enum": ["approve", "reject"] },
                  "feedback": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Gate decision recorded and workflow resumed or halted" }
        }
      }
    },
    "/notebooks/": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Agent Notebooks"],
        "operationId": "listNotebooks",
        "summary": "List Agent Notebooks (.anb)",
        "security": [{ "bearer": [] }],
        "responses": {
          "200": { "description": "List of Agent Notebooks" }
        }
      },
      "post": {
        "tags": ["Agent Notebooks"],
        "operationId": "createNotebook",
        "summary": "Create a new executable Agent Notebook (.anb)",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/NotebookCreateRequest" }
            }
          }
        },
        "responses": {
          "201": { "description": "Notebook created" }
        }
      }
    },
    "/notebooks/plan": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Agent Notebooks"],
        "operationId": "planNotebook",
        "summary": "Generate an executable multi-cell Agent Notebook DAG from a goal",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["goal"],
                "properties": {
                  "goal": { "type": "string" },
                  "context": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Planned Agent Notebook with typed cells and cost estimate" }
        }
      }
    },
    "/notebooks/{notebook_id}/execute": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Agent Notebooks"],
        "operationId": "executeNotebook",
        "summary": "Execute an Agent Notebook DAG (requires can_execute RBAC)",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "notebook_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "Execution started with run ID and stream URL" }
        }
      }
    },
    "/notebooks/{notebook_id}/stream": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Agent Notebooks"],
        "operationId": "streamNotebook",
        "summary": "Stream live per-cell traces and outputs from an Agent Notebook run (SSE)",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "notebook_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "SSE event stream (text/event-stream)" }
        }
      }
    },
    "/notebooks/{notebook_id}/export": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Agent Notebooks"],
        "operationId": "exportNotebook",
        "summary": "Export an Agent Notebook to .ipynb or portable .anb JSON",
        "security": [{ "bearer": [] }],
        "parameters": [
          {
            "name": "notebook_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["anb", "ipynb"], "default": "anb" }
          }
        ],
        "responses": {
          "200": { "description": "Exported notebook document" }
        }
      }
    },
    "/openaw/projects": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "get": {
        "tags": ["Platform & OpenAW"],
        "operationId": "listOpenAwProjects",
        "summary": "List public OpenAW ecosystem projects",
        "responses": {
          "200": { "description": "Public OpenAW project directory" }
        }
      }
    },
    "/doors/knock": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Platform & OpenAW"],
        "operationId": "doorsKnock",
        "summary": "Inspect capability attestation requirements for a gated door",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["door"],
                "properties": {
                  "door": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Required identity and attestation claims for the door" }
        }
      }
    },
    "/doors/present": {
      "servers": [{ "url": "https://api.aitherium.com" }],
      "post": {
        "tags": ["Platform & OpenAW"],
        "operationId": "doorsPresent",
        "summary": "Present credentials and attestations to obtain a short-lived door capability token",
        "security": [{ "bearer": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["door"],
                "properties": {
                  "door": { "type": "string" },
                  "attestation": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Short-lived capability attestation (awn1.*) bound to the door" }
        }
      }
    },
    "/api/v1": {
      "servers": [{ "url": "https://aitherium.com" }],
      "get": {
        "tags": ["Platform & OpenAW"],
        "operationId": "agentBriefX402",
        "summary": "Aitherium agent brief, paid per call with x402 v2",
        "description": "Without a PAYMENT-SIGNATURE header this answers HTTP 402 with a PAYMENT-REQUIRED header (base64 x402 v2 PaymentRequired, mirrored in the JSON body). Pay the exact amount, retry with PAYMENT-SIGNATURE, and receive the brief plus a PAYMENT-RESPONSE settlement header.",
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": { "type": "string" },
            "description": "base64 x402 v2 PaymentPayload"
          }
        ],
        "responses": {
          "200": {
            "description": "The brief; PAYMENT-RESPONSE carries the settlement receipt"
          },
          "402": {
            "description": "x402 v2 PaymentRequired in the PAYMENT-REQUIRED header"
          }
        }
      }
    }
  },
  "x-service-info": {
    "name": "Aitherium",
    "categories": [
      "ai-models",
      "mcp-gateway",
      "agent-infrastructure",
      "retrieval",
      "developer-tools"
    ],
    "description": "Public developer APIs for Bonsai 2.5 inference, routed MCP tools, hybrid retrieval, A2A agents, workflows, and Agent Notebooks."
  }
}
