{"openapi":"3.1.0","info":{"title":"Coreless Chat API","version":"1.0.0","description":"Text and image chat through Codex. Every key belongs to one isolated application. Only chat is available; tools are disabled. Daily quotas use UTC. Clients cannot override the application model. Only keys with developer mode enabled by the administrator may read and persistently update system_prompt and behavior_rules via GET/PATCH /v1/application/instructions. Ordinary keys receive 403 developer_mode_required. Updates affect subsequent generations throughout the key’s application, including existing sessions. Failed turns are not saved. SSE: start → delta* → done or error; HTTP 200 on an established stream does not guarantee generation success. Images are base64 data URLs or uploaded IDs; remote URLs are rejected. History counts towards input and image limits. List endpoints return the most recent items (limit 1–100)."},"servers":[{"url":"https://chat.coreless.site"}],"paths":{"/v1/application/instructions":{"get":{"operationId":"getApplicationInstructions","summary":"Read application instructions (developer-mode key required)","security":[{"ApplicationKey":[]}],"parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Instructions"}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"updateApplicationInstructions","summary":"Update instructions for this key’s application (developer-mode key required)","security":[{"ApplicationKey":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"minProperties":1,"properties":{"system_prompt":{"type":"string","maxLength":30000,"description":"New system prompt; empty string clears it"},"behavior_rules":{"type":"string","maxLength":10000,"description":"New behavior rules; empty string clears them"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Instructions"}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/models":{"get":{"operationId":"listModels","summary":"Read the model configured for this application","security":[{"ApplicationKey":[]}],"parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object"}}}}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sessions":{"post":{"operationId":"createSession","summary":"Create an isolated chat session","security":[{"ApplicationKey":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"title":{"type":"string","maxLength":200}}}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Session"}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"operationId":"listSessions","summary":"List recent application sessions","security":[{"ApplicationKey":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Session"}}}}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sessions/{sessionId}":{"get":{"operationId":"getSession","summary":"Read session metadata","security":[{"ApplicationKey":[]}],"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Session"}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteSession","summary":"Delete a session and its message history","security":[{"ApplicationKey":[]}],"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Success"},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sessions/{sessionId}/messages":{"get":{"operationId":"listMessages","summary":"Read recent messages in chronological order","security":[{"ApplicationKey":[]}],"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Message"}}}}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"sendMessage","summary":"Send text and/or images; optionally stream SSE","security":[{"ApplicationKey":[]}],"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendMessage"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Reply"}},"text/event-stream":{"schema":{"type":"string"},"example":"event: delta\ndata: {\"text\":\"Hello\"}\n\nevent: done\ndata: {\"text\":\"Hello\"}\n\n"}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/images":{"post":{"operationId":"uploadImage","summary":"Store an image for use in messages (256 MB image storage per application)","security":[{"ApplicationKey":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["data_url"],"additionalProperties":false,"properties":{"data_url":{"type":"string","description":"data:image/png;base64,... (also JPEG, GIF, WebP)"}}}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"mime":{"type":"string"},"bytes":{"type":"integer"}}}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/images/{imageId}":{"get":{"operationId":"getImage","summary":"Download an image belonging to this application","security":[{"ApplicationKey":[]}],"parameters":[{"name":"imageId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Image bytes","content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}},"image/gif":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteImage","summary":"Delete uploaded image; images already saved in message history remain until session deletion","security":[{"ApplicationKey":[]}],"parameters":[{"name":"imageId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"204":{"description":"Success"},"401":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"Retry-After":{"schema":{"type":"integer"}}}},"502":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Error envelope; inspect error.code and X-Request-Id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"ApplicationKey":{"type":"http","scheme":"bearer","description":"Application API key created in admin. Never expose in browser code."}},"schemas":{"Instructions":{"type":"object","required":["system_prompt","behavior_rules"],"properties":{"system_prompt":{"type":"string"},"behavior_rules":{"type":"string"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"request_id":{"type":"string"}}}}},"Session":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"created":{"type":"string","format":"date-time"},"updated":{"type":"string","format":"date-time"}}},"SendMessage":{"type":"object","additionalProperties":false,"properties":{"text":{"type":"string","default":"","description":"At least text or one image required"},"images":{"type":"array","maxItems":10,"default":[],"items":{"type":"string"},"description":"Base64 data URLs or image IDs. At most 10 images in entire conversation; application can set a lower per-message limit."},"stream":{"type":"boolean","default":false}},"example":{"text":"Что изображено на картинке?","images":["data:image/png;base64,..."],"stream":false}},"Message":{"type":"object","properties":{"id":{"type":"string"},"session_id":{"type":"string"},"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"object","properties":{"text":{"type":"string"},"images":{"type":"array","items":{"type":"string"}}}},"created":{"type":"string","format":"date-time"}}},"Reply":{"type":"object","properties":{"id":{"type":"string"},"session_id":{"type":"string"},"role":{"const":"assistant"},"text":{"type":"string"},"usage":{"type":"object","additionalProperties":true},"request_id":{"type":"string"}}}}}}