{"openapi":"3.1.0","info":{"title":"Cogni API","description":"A minimal FastAPI that directly passes user queries to OpenAI, augmented with Cogni memory.","version":"0.1.0"},"paths":{"/healthz":{"get":{"summary":"Health Check","description":"Health check endpoint for monitoring.","operationId":"health_check_healthz_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/chat":{"post":{"tags":["v1/Chat"],"summary":"Stream Chat","operationId":"stream_chat_api_v1_chat_post","parameters":[{"name":"authorization","in":"header","required":true,"schema":{"type":"string","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompleteQueryRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/blocks":{"get":{"tags":["v1/Blocks"],"summary":"Get all memory blocks","description":"Retrieves memory blocks currently stored in the system. Can be filtered by block type.","operationId":"get_all_blocks_api_v1_blocks_get","parameters":[{"name":"type","in":"query","required":false,"schema":{"type":"string","title":"Type"}},{"name":"case_insensitive","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Case Insensitive"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/MemoryBlock"},"title":"Response Get All Blocks Api V1 Blocks Get"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["v1/Blocks"],"summary":"Create a new memory block","description":"Adds a new memory block to the system using the core creation tool.","operationId":"create_block_api_v1_blocks_post","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateMemoryBlockInput"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryBlock"}}}},"422":{"description":"Validation Error (invalid input data or metadata)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error (failed to save or fetch)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/blocks/{block_id}":{"get":{"tags":["v1/Blocks"],"summary":"Get a specific memory block by ID","description":"Retrieves a specific memory block by its unique identifier.","operationId":"get_block_api_v1_blocks__block_id__get","parameters":[{"name":"block_id","in":"path","required":true,"schema":{"type":"string","title":"Block Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemoryBlock"}}}},"404":{"description":"Memory block not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/schemas/{block_type}/{version}":{"get":{"tags":["v1/Schemas"],"summary":"Get JSON schema for a block type and version","description":"Returns the JSON schema for the given block type and version.\nIf version is 'latest', resolves to the latest version for the type.\nUses application/schema+json media type.","operationId":"get_schema_api_v1_schemas__block_type___version__get","parameters":[{"name":"block_type","in":"path","required":true,"schema":{"type":"string","title":"Block Type"}},{"name":"version","in":"path","required":true,"schema":{"type":"string","title":"Version"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/schemas/index.json":{"get":{"tags":["v1/Schemas"],"summary":"Get index of all available block schemas","description":"Returns a list of all available block schemas with their type, version, and URL.","operationId":"get_schema_index_api_v1_schemas_index_json_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"BlockLink":{"properties":{"to_id":{"type":"string","title":"To Id","description":"ID of the target block in the link"},"relation":{"type":"string","enum":["related_to","subtask_of","depends_on","child_of","mentions","parent_of","belongs_to_epic","epic_contains","blocks","is_blocked_by","bug_affects","has_bug"],"title":"Relation","description":"The type of relationship between the blocks"},"priority":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Priority","description":"Priority of the link (higher numbers = higher priority)","default":0},"link_metadata":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Link Metadata","description":"Additional metadata about the link"},"created_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created By","description":"ID of the agent/user who created the link"},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"When the link was created"}},"type":"object","required":["to_id","relation"],"title":"BlockLink","description":"Defines a directed link between two MemoryBlocks."},"CompleteQueryRequest":{"properties":{"message":{"type":"string","title":"Message","description":"The message content to send to the AI","examples":["What is CogniDAO?"]},"model":{"type":"string","title":"Model","description":"The AI model to use for generation","default":"gpt-3.5-turbo"},"temperature":{"type":"number","maximum":1.0,"minimum":0.0,"title":"Temperature","description":"Controls randomness in the response. Lower is more deterministic.","default":0.7},"system_message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"System Message","description":"Instructions for the AI assistant's behavior","default":"You are a helpful AI assistant."},"message_history":{"anyOf":[{"items":{"$ref":"#/components/schemas/HistoryMessage"},"type":"array"},{"type":"null"}],"title":"Message History","description":"Optional list of previous messages in the conversation"}},"type":"object","required":["message"],"title":"CompleteQueryRequest","description":"Extended schema for a chat request with additional parameters.\nThis can be used for more advanced chat endpoints."},"ConfidenceScore":{"properties":{"human":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Human","description":"Optional human confidence score (0.0 to 1.0)"},"ai":{"anyOf":[{"type":"number","maximum":1.0,"minimum":0.0},{"type":"null"}],"title":"Ai","description":"Optional AI-generated confidence score (0.0 to 1.0)"}},"type":"object","title":"ConfidenceScore","description":"Represents confidence scores, potentially from human or AI sources."},"CreateMemoryBlockInput":{"properties":{"type":{"type":"string","title":"Type","description":"Type of memory block to create (must be registered in schema registry)"},"text":{"type":"string","title":"Text","description":"Primary content of the memory block"},"state":{"anyOf":[{"type":"string","enum":["draft","published","archived"]},{"type":"null"}],"title":"State","description":"Initial state of the block","default":"draft"},"visibility":{"anyOf":[{"type":"string","enum":["internal","public","restricted"]},{"type":"null"}],"title":"Visibility","description":"Visibility level of the block","default":"internal"},"tags":{"items":{"type":"string"},"type":"array","maxItems":20,"title":"Tags","description":"Optional tags for filtering and metadata"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","description":"Type-specific metadata for the block"},"source_file":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source File","description":"Optional source file or markdown name"},"confidence":{"anyOf":[{"$ref":"#/components/schemas/ConfidenceScore"},{"type":"null"}],"description":"Optional confidence scores for the block"},"created_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created By","description":"Optional identifier for creator (agent name or user ID)","default":"agent"},"links":{"anyOf":[{"items":{"$ref":"#/components/schemas/BlockLink"},"type":"array"},{"type":"null"}],"title":"Links","description":"Optional list of links to other blocks"}},"type":"object","required":["type","text"],"title":"CreateMemoryBlockInput","description":"Input model for creating a new memory block."},"ErrorResponse":{"properties":{"detail":{"type":"string","title":"Detail","description":"A human-readable error message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code","description":"An optional error code for programmatic handling"}},"type":"object","required":["detail"],"title":"ErrorResponse","description":"Schema for error responses."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HistoryMessage":{"properties":{"role":{"type":"string","enum":["user","assistant","system"],"title":"Role","description":"The role of the message sender."},"content":{"type":"string","title":"Content","description":"The content of the message."}},"type":"object","required":["role","content"],"title":"HistoryMessage","description":"Schema for a single message in the chat history."},"MemoryBlock":{"properties":{"id":{"type":"string","title":"Id","description":"Globally unique ID for this memory block"},"type":{"type":"string","enum":["knowledge","task","project","doc","interaction","log","epic","bug"],"title":"Type","description":"Block type used to determine structure and relationships"},"schema_version":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Schema Version","description":"Version of the schema this block adheres to (links to node_schemas table)"},"text":{"type":"string","title":"Text","description":"Primary content or description of the block"},"state":{"anyOf":[{"type":"string","enum":["draft","published","archived"]},{"type":"null"}],"title":"State","description":"Current state of the block"},"visibility":{"anyOf":[{"type":"string","enum":["internal","public","restricted"]},{"type":"null"}],"title":"Visibility","description":"Visibility level of the block"},"block_version":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Block Version","description":"Version number of this block"},"tags":{"items":{"type":"string"},"type":"array","maxItems":20,"title":"Tags","description":"Optional tags for filtering, theming, or metadata"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","description":"Custom metadata based on block type"},"links":{"items":{"$ref":"#/components/schemas/BlockLink"},"type":"array","title":"Links","description":"Directed outgoing edges connecting this block to others"},"source_file":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source File","description":"Optional source markdown or file name"},"source_uri":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source Uri","description":"Optional source link or Logseq block URI"},"confidence":{"anyOf":[{"$ref":"#/components/schemas/ConfidenceScore"},{"type":"null"}],"description":"Confidence scores for this memory block"},"created_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created By","description":"Optional identifier for creator (agent name or user ID)"},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"ISO timestamp of block creation"},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"ISO timestamp of last update"},"embedding":{"anyOf":[{"items":{"type":"number"},"type":"array"},{"type":"null"}],"title":"Embedding","description":"Optional vector embedding of the block's content"}},"type":"object","required":["type","text"],"title":"MemoryBlock","description":"The primary data structure for representing a unit of memory in the Cogni system experiment.\nAligns with the design specified in project-CogniMemorySystem-POC.json.\nIncludes schema versioning support (Task 2.0)."},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}