{
    "openapi": "3.1.0",
    "info": {
        "title": "Kitano AI Developer API",
        "version": "2026-07-25",
        "description": "Build production AI applications with KTN text, tools, images, audio, embeddings, safety, streaming, durable background work, and cost-aware usage controls."
    },
    "servers": [
        {
            "url": "https://kitanoai.com/api/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "Platform"
        },
        {
            "name": "Responses"
        },
        {
            "name": "Images"
        },
        {
            "name": "Audio"
        },
        {
            "name": "Embeddings"
        },
        {
            "name": "Safety"
        }
    ],
    "paths": {
        "/capabilities": {
            "get": {
                "tags": [
                    "Platform"
                ],
                "summary": "Discover enabled capabilities and limits",
                "responses": {
                    "200": {
                        "description": "Capability list"
                    }
                }
            }
        },
        "/models": {
            "get": {
                "tags": [
                    "Platform"
                ],
                "summary": "List models available to this account",
                "responses": {
                    "200": {
                        "description": "Model list"
                    }
                }
            }
        },
        "/models/{model}": {
            "get": {
                "tags": [
                    "Platform"
                ],
                "summary": "Retrieve a model",
                "parameters": [
                    {
                        "name": "model",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Model"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/usage": {
            "get": {
                "tags": [
                    "Platform"
                ],
                "summary": "Retrieve usage and recent requests",
                "parameters": [
                    {
                        "name": "days",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 90,
                            "default": 30
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Usage summary"
                    }
                }
            }
        },
        "/responses": {
            "post": {
                "tags": [
                    "Responses"
                ],
                "summary": "Create a response",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ResponseRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Completed response"
                    },
                    "202": {
                        "description": "Background response accepted"
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/responses/{response_id}": {
            "get": {
                "tags": [
                    "Responses"
                ],
                "summary": "Retrieve a stored or background response",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ResponseId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Response"
                    },
                    "202": {
                        "description": "Still processing"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "delete": {
                "tags": [
                    "Responses"
                ],
                "summary": "Delete a stored response",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ResponseId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Deleted"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/responses/{response_id}/cancel": {
            "post": {
                "tags": [
                    "Responses"
                ],
                "summary": "Cancel a background response",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/ResponseId"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Cancelled or already terminal"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/chat/completions": {
            "post": {
                "tags": [
                    "Responses"
                ],
                "summary": "Create a Kitano chat completion",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Completion or SSE stream"
                    }
                }
            }
        },
        "/images/generations": {
            "post": {
                "tags": [
                    "Images"
                ],
                "summary": "Generate images",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "prompt"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Image 2"
                                    },
                                    "prompt": {
                                        "type": "string"
                                    },
                                    "n": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 2
                                    },
                                    "size": {
                                        "enum": [
                                            "1024x1024",
                                            "1024x1536",
                                            "1536x1024",
                                            "auto"
                                        ]
                                    },
                                    "quality": {
                                        "enum": [
                                            "low",
                                            "medium",
                                            "high",
                                            "auto"
                                        ]
                                    },
                                    "response_format": {
                                        "enum": [
                                            "url",
                                            "b64_json"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Generated images"
                    }
                }
            }
        },
        "/images/edits": {
            "post": {
                "tags": [
                    "Images"
                ],
                "summary": "Edit an uploaded image",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/IdempotencyKey"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "image",
                                    "prompt"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Image 2"
                                    },
                                    "image": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "mask": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "prompt": {
                                        "type": "string"
                                    },
                                    "size": {
                                        "type": "string"
                                    },
                                    "quality": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Edited images"
                    }
                }
            }
        },
        "/audio/speech": {
            "post": {
                "tags": [
                    "Audio"
                ],
                "summary": "Create natural speech",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "input",
                                    "voice"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Voice"
                                    },
                                    "input": {
                                        "type": "string"
                                    },
                                    "voice": {
                                        "type": "string",
                                        "example": "coral"
                                    },
                                    "response_format": {
                                        "enum": [
                                            "mp3",
                                            "opus",
                                            "aac",
                                            "flac",
                                            "wav",
                                            "pcm"
                                        ]
                                    },
                                    "speed": {
                                        "type": "number",
                                        "minimum": 0.25,
                                        "maximum": 4
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Audio bytes",
                        "content": {
                            "audio/mpeg": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/audio/transcriptions": {
            "post": {
                "tags": [
                    "Audio"
                ],
                "summary": "Transcribe audio",
                "requestBody": {
                    "required": true,
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "file"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Transcribe"
                                    },
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    },
                                    "language": {
                                        "type": "string"
                                    },
                                    "prompt": {
                                        "type": "string"
                                    },
                                    "response_format": {
                                        "enum": [
                                            "json",
                                            "text",
                                            "verbose_json"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Transcription"
                    }
                }
            }
        },
        "/embeddings": {
            "post": {
                "tags": [
                    "Embeddings"
                ],
                "summary": "Create semantic vector embeddings",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "model",
                                    "input"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Embed"
                                    },
                                    "input": {
                                        "oneOf": [
                                            {
                                                "type": "string"
                                            },
                                            {
                                                "type": "array",
                                                "items": {
                                                    "type": "string"
                                                },
                                                "maxItems": 128
                                            }
                                        ]
                                    },
                                    "dimensions": {
                                        "type": "integer",
                                        "minimum": 1,
                                        "maximum": 3072
                                    },
                                    "encoding_format": {
                                        "enum": [
                                            "float",
                                            "base64"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Embedding list"
                    }
                }
            }
        },
        "/moderations": {
            "post": {
                "tags": [
                    "Safety"
                ],
                "summary": "Classify text or image safety",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "input"
                                ],
                                "properties": {
                                    "model": {
                                        "type": "string",
                                        "example": "KTN Safety"
                                    },
                                    "input": []
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Safety classification"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "KTN API key"
            }
        },
        "parameters": {
            "IdempotencyKey": {
                "name": "Idempotency-Key",
                "in": "header",
                "required": false,
                "description": "Use the same 8-128 character value when safely retrying a mutation.",
                "schema": {
                    "type": "string"
                }
            },
            "ResponseId": {
                "name": "response_id",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "string",
                    "pattern": "^resp_ktn_"
                }
            }
        },
        "schemas": {
            "ResponseRequest": {
                "type": "object",
                "required": [
                    "model",
                    "input"
                ],
                "properties": {
                    "model": {
                        "type": "string",
                        "example": "KTN-5.6 Terra"
                    },
                    "input": {
                        "oneOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "array",
                                "items": {
                                    "type": "object"
                                }
                            }
                        ]
                    },
                    "instructions": {
                        "type": "string"
                    },
                    "stream": {
                        "type": "boolean"
                    },
                    "background": {
                        "type": "boolean"
                    },
                    "store": {
                        "type": "boolean",
                        "default": true
                    },
                    "previous_response_id": {
                        "type": "string"
                    },
                    "max_output_tokens": {
                        "type": "integer"
                    },
                    "reasoning": {
                        "type": "object",
                        "properties": {
                            "effort": {
                                "enum": [
                                    "low",
                                    "medium",
                                    "high"
                                ]
                            }
                        }
                    },
                    "tools": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "type": {
                                    "enum": [
                                        "web_search",
                                        "code_interpreter"
                                    ]
                                }
                            }
                        }
                    },
                    "text": {
                        "type": "object",
                        "properties": {
                            "format": {
                                "type": "object"
                            }
                        }
                    }
                }
            },
            "ChatRequest": {
                "type": "object",
                "required": [
                    "model",
                    "messages"
                ],
                "properties": {
                    "model": {
                        "type": "string",
                        "example": "KTN-5.6 Terra"
                    },
                    "messages": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "role",
                                "content"
                            ],
                            "properties": {
                                "role": {
                                    "enum": [
                                        "system",
                                        "developer",
                                        "user",
                                        "assistant"
                                    ]
                                },
                                "content": []
                            }
                        }
                    },
                    "stream": {
                        "type": "boolean"
                    },
                    "max_completion_tokens": {
                        "type": "integer"
                    },
                    "reasoning_effort": {
                        "enum": [
                            "low",
                            "medium",
                            "high"
                        ]
                    },
                    "tools": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "message": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "param": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "code": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "responses": {
            "Error": {
                "description": "API error",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        }
    }
}