{"openapi":"3.1.0","info":{"title":"LLMApi Gateway","version":"1.0.0","description":"OpenAI-compatible gateway in front of local Codex and Claude engines. Point any OpenAI SDK at the server URL and authenticate with a gateway API key (`Authorization: Bearer sk-...`). Chat completions support streaming and image input; image generation supports reference images."},"servers":[{"url":"https://llmapi.kaktusyazilim.com/v1","description":"Gateway base URL (OpenAI base_url)."}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Chat","description":"Chat completions."},{"name":"Images","description":"Image generation."},{"name":"Models","description":"Model discovery."},{"name":"Key","description":"API-key status (gateway extension)."}],"paths":{"/chat/completions":{"post":{"tags":["Chat"],"operationId":"createChatCompletion","summary":"Create a chat completion","description":"Requires the `chat` scope. Set `stream: true` for an SSE token stream (`text/event-stream`, terminated by `data: [DONE]`).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"A chat completion, or an SSE stream of chat.completion.chunk events when streaming.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletion"}},"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope or adapter not allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Daily quota or concurrency limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Gateway at capacity — retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/images/generations":{"post":{"tags":["Images"],"operationId":"createImage","summary":"Generate images","description":"Requires the `image` scope. Backed by the Codex image tool. Pass `image` for reference-guided generation.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageRequest"}}}},"responses":{"200":{"description":"Generated images.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope or adapter not allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Daily quota or concurrency limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Gateway at capacity — retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/models":{"get":{"tags":["Models"],"operationId":"listModels","summary":"List available models","description":"Returns only models the calling key is allowed to use (filtered by its adapter access).","responses":{"200":{"description":"The model list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelList"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope or adapter not allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Daily quota or concurrency limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Gateway at capacity — retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/key":{"get":{"tags":["Key"],"operationId":"getKeyStatus","summary":"Get the calling key's status","description":"Gateway extension (not part of the OpenAI spec). Returns scopes, quota, concurrency and recent usage.","responses":{"200":{"description":"Key status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyStatus"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient scope or adapter not allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Daily quota or concurrency limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Gateway at capacity — retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"A gateway API key, e.g. `sk-...`."}},"schemas":{"TextContentPart":{"type":"object","required":["type","text"],"properties":{"type":{"const":"text"},"text":{"type":"string"}}},"ImageContentPart":{"type":"object","required":["type","image_url"],"properties":{"type":{"const":"image_url"},"image_url":{"type":"object","required":["url"],"properties":{"url":{"type":"string","description":"A data: URL (base64) or an http(s) URL. Max 8 per request, 25 MB each (PNG/JPEG/WebP/GIF)."},"detail":{"type":"string"}}}}},"ChatMessage":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system","developer","user","assistant","tool"]},"content":{"description":"Plain text, or an array of parts (text + image_url) for image input.","oneOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/TextContentPart"},{"$ref":"#/components/schemas/ImageContentPart"}]}}],"nullable":true},"name":{"type":"string"}}},"ChatCompletionRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"A model id from GET /models."},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"},"minItems":1},"stream":{"type":"boolean","default":false},"temperature":{"type":"number","minimum":0,"maximum":2},"max_tokens":{"type":"integer","minimum":1},"reasoning_effort":{"type":"string","enum":["minimal","low","medium","high","xhigh"]},"web_search":{"type":"boolean","description":"Allow the model to search the web for this call."},"response_format":{"type":"object","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"]},"json_schema":{}}},"user":{"type":"string"}}},"ChatCompletion":{"type":"object","properties":{"id":{"type":"string"},"object":{"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"}}},"finish_reason":{"type":"string"}}}},"usage":{"$ref":"#/components/schemas/Usage"}}},"Usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}},"ImageRequest":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string"},"model":{"type":"string"},"n":{"type":"integer","minimum":1,"maximum":4,"default":1},"ratio":{"type":"string","enum":["1:1","16:9","9:16","4:3","3:4","3:2","2:3"]},"purpose":{"type":"string","enum":["hero","logo","icon","texture","illustration","background","product","portrait","abstract","other"]},"size":{"type":"string","description":"OpenAI-compatible size, e.g. \"1024x1024\" — mapped to the nearest ratio."},"response_format":{"type":"string","enum":["url","b64_json"],"default":"b64_json"},"background":{"type":"string","enum":["transparent","opaque","auto"]},"image":{"description":"Reference image(s) — a data: or http(s) URL, or an array of them.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}},"ImageResponse":{"type":"object","properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","properties":{"b64_json":{"type":"string"},"url":{"type":"string"}}}}}},"ModelList":{"type":"object","properties":{"object":{"const":"list"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"model"},"created":{"type":"integer"},"owned_by":{"type":"string"}}}}}},"KeyStatus":{"type":"object","properties":{"object":{"const":"api_key"},"prefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string","enum":["chat","image"]}},"enabled":{"type":"boolean"},"expires_at":{"type":"string","nullable":true},"limits":{"type":"object","properties":{"daily_quota":{"type":"integer","nullable":true},"used_today":{"type":"integer"},"remaining_today":{"type":"integer","nullable":true},"resets_at":{"type":"string","nullable":true},"max_concurrency":{"type":"integer","nullable":true},"in_flight":{"type":"integer"}}},"totals":{"type":"object","properties":{"requests":{"type":"integer"},"errors":{"type":"integer"}}},"usage_30d":{"type":"object","properties":{"requests":{"type":"integer"},"total_tokens":{"type":"integer"},"cost_usd":{"type":"number"}}}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"}}}}}}}}