{"components":{"schemas":{"AccountChatRequest":{"additionalProperties":false,"description":"POST /api/chat: desktop session or browser session with same-origin CSRF. Always SSE. Success ends with late usage, redrouter.billing, then [DONE]. Failed streams end with redrouter.billing, then an error event. End with a nonempty user message or all matching tool results. Each round is independently reserved and billed; no server tool execution.","properties":{"max_tokens":{"anyOf":[{"maximum":4294967295,"minimum":1,"type":"integer"},{"type":"null"}],"description":"Output upper bound, capped to the model maximum. Mutually exclusive with max_completion_tokens."},"messages":{"items":{"additionalProperties":false,"properties":{"annotations":{"description":"Accepted on replayed assistant messages and ignored.","type":["array","null"]},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"additionalProperties":false,"properties":{"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"properties":{"image_url":{"additionalProperties":false,"properties":{"detail":{"enum":["auto","low","high"],"type":"string"},"url":{"type":"string"}},"required":["url"],"type":"object"},"type":{"const":"image_url"}},"required":["type","image_url"],"type":"object"}]},"type":"array"},{"type":"null"}],"description":"Text or text/image_url parts. Images are allowed on user and tool messages only; other roles receive the omission notice. Null or omitted content is allowed on assistant messages."},"name":{"pattern":"^[a-zA-Z0-9_-]{1,64}$","type":"string"},"reasoning":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Alternative replay field. Used when reasoning_content is absent."},"reasoning_content":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Replayed reasoning text on assistant messages is forwarded and included in the input budget. Ignored on other roles."},"reasoning_details":{"anyOf":[{"items":{"type":"object"},"type":"array"},{"type":"null"}],"description":"Alternative replay field. Text and summary entries are used when reasoning_content and reasoning are absent; encrypted entries are dropped."},"refusal":{"description":"Accepted on replayed assistant messages and ignored.","type":["string","null"]},"role":{"enum":["system","developer","user","assistant","tool"],"type":"string"},"tool_call_id":{"description":"Required for a tool message; must match an unanswered assistant call.","type":"string"},"tool_calls":{"description":"Assistant only. Reply to every call with a matching tool message before the next turn.","items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"arguments":{"type":"string"},"name":{"type":"string"}},"required":["name","arguments"],"type":"object"},"id":{"type":"string"},"type":{"const":"function"}},"required":["id","type","function"],"type":"object"},"type":"array"}},"required":["role"],"type":"object"},"maxItems":4096,"minItems":1,"type":"array"},"model":{"description":"Use an exact catalog model ID.","minLength":1,"type":"string"},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"reasoning_effort":{"description":"Forwarded for GLM 5.3 models on deployments that support reasoning effort; accepted and ignored on other deployments. Does not set a token budget.","enum":["low","medium","high","max"],"type":"string"},"temperature":{"maximum":2,"minimum":0,"type":["number","null"]},"tool_choice":{"anyOf":[{"enum":["auto","none","required"],"type":"string"},{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"name":{"type":"string"}},"required":["name"],"type":"object"},"type":{"const":"function"}},"required":["type","function"],"type":"object"},{"type":"null"}]},"tools":{"description":"Up to 256 KiB of function definitions. Check model tool_calling capability.","items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"name":{"pattern":"^[a-zA-Z0-9_-]{1,64}$","type":"string"},"parameters":{"anyOf":[{"type":"object"},{"type":"null"}]},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Schema enforcement depends on the model."}},"required":["name"],"type":"object"},"type":{"const":"function"}},"required":["type","function"],"type":"object"},"maxItems":128,"type":["array","null"]}},"required":["model","messages"],"type":"object"},"AccountSubscription":{"additionalProperties":false,"properties":{"granted_plans":{"items":{"$ref":"#/components/schemas/Plan"},"type":"array"},"purchased_balance_usd":{"type":"string"},"subscription":{"anyOf":[{"$ref":"#/components/schemas/Subscription"},{"type":"null"}]}},"required":["subscription","purchased_balance_usd","granted_plans"],"type":"object"},"Catalog":{"additionalProperties":false,"properties":{"anthropic_base_url":{"type":"string"},"api_base_url":{"type":"string"},"environment":{"enum":["local","production"],"type":"string"},"limits":{"additionalProperties":false,"properties":{"daily_spend_usd":{"description":"Decimal USD string.","type":"string"},"max_concurrency":{"minimum":0,"type":"integer"},"requests_per_minute":{"minimum":0,"type":"integer"}},"required":["requests_per_minute","max_concurrency","daily_spend_usd"],"type":"object"},"max_request_bytes":{"minimum":0,"type":"integer"},"messages_supported_fields":{"items":{"type":"string"},"type":"array"},"models":{"items":{"additionalProperties":false,"properties":{"available":{"type":"boolean"},"capabilities":{"anyOf":[{"additionalProperties":false,"properties":{"image_input":{"description":"True only when primary and all fallback deployments support images.","type":"boolean"},"response_format":{"type":"boolean"},"tool_calling":{"type":"boolean"}},"required":["tool_calling","response_format","image_input"],"type":"object"},{"type":"null"}]},"checkpoint":{"additionalProperties":false,"properties":{"chat_template":{"anyOf":[{"type":"string"},{"type":"null"}]},"license":{"anyOf":[{"type":"string"},{"type":"null"}]},"quantization":{"anyOf":[{"type":"string"},{"type":"null"}]},"revision":{"anyOf":[{"type":"string"},{"type":"null"}]},"source":{"type":"string"},"tokenizer":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["source","revision","license","quantization","tokenizer","chat_template"],"type":"object"},"context_tokens":{"minimum":0,"type":"integer"},"default_output_tokens":{"minimum":0,"type":"integer"},"description":{"type":"string"},"display_name":{"type":"string"},"early_access":{"description":"Requires current paid plan coverage; otherwise dispatch returns 403 plan_required with a link to /credits.","type":"boolean"},"featured":{"type":"boolean"},"id":{"type":"string"},"max_output_tokens":{"minimum":0,"type":"integer"},"opaque":{"description":"Underlying model and hosting details are not disclosed; checkpoint fields are redacted.","type":"boolean"},"pricing":{"anyOf":[{"additionalProperties":false,"properties":{"cached_input_usd_per_mtok":{"description":"Decimal USD string.","type":"string"},"input_usd_per_mtok":{"description":"Decimal USD string.","type":"string"},"output_usd_per_mtok":{"description":"Decimal USD string.","type":"string"},"source":{"enum":["fixture","retail"],"type":"string"}},"required":["source","input_usd_per_mtok","cached_input_usd_per_mtok","output_usd_per_mtok"],"type":"object"},{"type":"null"}]},"reduced_refusals":{"type":"boolean"}},"required":["id","display_name","available","description","reduced_refusals","opaque","featured","early_access","context_tokens","max_output_tokens","default_output_tokens","capabilities","pricing","checkpoint"],"type":"object"},"type":"array"},"responses_supported_fields":{"items":{"type":"string"},"type":"array"},"revision":{"type":"string"},"supported_fields":{"items":{"type":"string"},"type":"array"}},"required":["revision","environment","api_base_url","anthropic_base_url","models","limits","supported_fields","messages_supported_fields","responses_supported_fields","max_request_bytes"],"type":"object"},"ChatChunk":{"additionalProperties":false,"properties":{"choices":{"items":{"additionalProperties":false,"properties":{"delta":{"additionalProperties":false,"properties":{"content":{"type":"string"},"role":{"const":"assistant"},"tool_calls":{"items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"arguments":{"type":"string"},"name":{"type":"string"}},"required":[],"type":"object"},"id":{"type":"string"},"index":{"minimum":0,"type":"integer"},"type":{"const":"function"}},"required":["index","function"],"type":"object"},"type":"array"}},"required":[],"type":"object"},"finish_reason":{"anyOf":[{"enum":["stop","length","content_filter","tool_calls"],"type":"string"},{"type":"null"}]},"index":{"minimum":0,"type":"integer"}},"required":["index","delta","finish_reason"],"type":"object"},"type":"array"},"created":{"minimum":0,"type":"integer"},"id":{"type":"string"},"model":{"type":"string"},"object":{"const":"chat.completion.chunk"},"usage":{"additionalProperties":false,"properties":{"completion_tokens":{"minimum":0,"type":"integer"},"prompt_tokens":{"minimum":0,"type":"integer"},"prompt_tokens_details":{"additionalProperties":false,"properties":{"cached_tokens":{"minimum":0,"type":"integer"}},"required":["cached_tokens"],"type":"object"},"total_tokens":{"minimum":0,"type":"integer"}},"required":["prompt_tokens","completion_tokens","total_tokens"],"type":"object"}},"required":["id","object","created","model","choices"],"type":"object"},"ChatRequest":{"additionalProperties":false,"properties":{"chat_template_kwargs":{"description":"Accepted for compatibility; ignored on current deployments."},"enable_thinking":{"description":"Accepted for compatibility; ignored on current deployments."},"frequency_penalty":{"maximum":2,"minimum":-2,"type":["number","null"]},"max_completion_tokens":{"anyOf":[{"maximum":4294967295,"minimum":1,"type":"integer"},{"type":"null"}],"description":"Alias for max_tokens; send only one."},"max_tokens":{"anyOf":[{"maximum":4294967295,"minimum":1,"type":"integer"},{"type":"null"}],"description":"Output upper bound, capped to the model maximum. Mutually exclusive with max_completion_tokens."},"messages":{"items":{"additionalProperties":false,"properties":{"annotations":{"description":"Accepted on replayed assistant messages and ignored.","type":["array","null"]},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"additionalProperties":false,"properties":{"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"properties":{"image_url":{"additionalProperties":false,"properties":{"detail":{"enum":["auto","low","high"],"type":"string"},"url":{"type":"string"}},"required":["url"],"type":"object"},"type":{"const":"image_url"}},"required":["type","image_url"],"type":"object"}]},"type":"array"},{"type":"null"}],"description":"Text or text/image_url parts. Images are allowed on user and tool messages only; other roles receive the omission notice. Null or omitted content is allowed on assistant messages."},"name":{"pattern":"^[a-zA-Z0-9_-]{1,64}$","type":"string"},"reasoning":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Alternative replay field. Used when reasoning_content is absent."},"reasoning_content":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Replayed reasoning text on assistant messages is forwarded and included in the input budget. Ignored on other roles."},"reasoning_details":{"anyOf":[{"items":{"type":"object"},"type":"array"},{"type":"null"}],"description":"Alternative replay field. Text and summary entries are used when reasoning_content and reasoning are absent; encrypted entries are dropped."},"refusal":{"description":"Accepted on replayed assistant messages and ignored.","type":["string","null"]},"role":{"enum":["system","developer","user","assistant","tool"],"type":"string"},"tool_call_id":{"description":"Required for a tool message; must match an unanswered assistant call.","type":"string"},"tool_calls":{"description":"Assistant only. Reply to every call with a matching tool message before the next turn.","items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"arguments":{"type":"string"},"name":{"type":"string"}},"required":["name","arguments"],"type":"object"},"id":{"type":"string"},"type":{"const":"function"}},"required":["id","type","function"],"type":"object"},"type":"array"}},"required":["role"],"type":"object"},"maxItems":4096,"minItems":1,"type":"array"},"model":{"description":"Use an exact catalog model ID.","minLength":1,"type":"string"},"output_config":{"description":"Accepted for compatibility; ignored on current deployments."},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"presence_penalty":{"maximum":2,"minimum":-2,"type":["number","null"]},"reasoning":{"description":"Accepted for compatibility; ignored on current deployments."},"reasoning_effort":{"description":"Forwarded for GLM 5.3 models on deployments that support reasoning effort; accepted and ignored on other deployments. Does not set a token budget.","enum":["low","medium","high","max"],"type":"string"},"response_format":{"anyOf":[{"additionalProperties":false,"properties":{"type":{"enum":["text","json_object"],"type":"string"}},"required":["type"],"type":"object"},{"additionalProperties":false,"properties":{"json_schema":{"additionalProperties":false,"properties":{"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"name":{"type":"string"},"schema":{"type":"object"},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}]}},"required":["name","schema"],"type":"object"},"type":{"const":"json_schema"}},"required":["type","json_schema"],"type":"object"},{"type":"null"}],"description":"Check model response_format capability."},"seed":{"format":"int64","type":["integer","null"]},"stop":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"maxItems":4,"type":"array"},{"type":"null"}]},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Default false. True returns server-sent events."},"stream_options":{"anyOf":[{"additionalProperties":false,"properties":{"include_usage":{"type":"boolean"}},"required":[],"type":"object"},{"type":"null"}]},"temperature":{"maximum":2,"minimum":0,"type":["number","null"]},"thinking":{"description":"Accepted for compatibility; ignored on current deployments."},"thinking_budget":{"description":"Accepted for compatibility; ignored on current deployments."},"tool_choice":{"anyOf":[{"enum":["auto","none","required"],"type":"string"},{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"name":{"type":"string"}},"required":["name"],"type":"object"},"type":{"const":"function"}},"required":["type","function"],"type":"object"},{"type":"null"}]},"tools":{"description":"Up to 256 KiB of function definitions. Check model tool_calling capability.","items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"name":{"pattern":"^[a-zA-Z0-9_-]{1,64}$","type":"string"},"parameters":{"anyOf":[{"type":"object"},{"type":"null"}]},"strict":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Schema enforcement depends on the model."}},"required":["name"],"type":"object"},"type":{"const":"function"}},"required":["type","function"],"type":"object"},"maxItems":128,"type":["array","null"]},"top_p":{"maximum":1,"minimum":0,"type":["number","null"]},"user":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Accepted for client compatibility; ignored."}},"required":["model","messages"],"type":"object"},"ChatResponse":{"additionalProperties":false,"properties":{"choices":{"items":{"additionalProperties":false,"properties":{"finish_reason":{"enum":["stop","length","content_filter","tool_calls"],"type":"string"},"index":{"minimum":0,"type":"integer"},"message":{"additionalProperties":false,"properties":{"content":{"anyOf":[{"type":"string"},{"type":"null"}]},"role":{"const":"assistant"},"tool_calls":{"items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"arguments":{"type":"string"},"name":{"type":"string"}},"required":["name","arguments"],"type":"object"},"id":{"type":"string"},"type":{"const":"function"}},"required":["id","type","function"],"type":"object"},"type":"array"}},"required":["role","content"],"type":"object"}},"required":["index","message","finish_reason"],"type":"object"},"type":"array"},"created":{"minimum":0,"type":"integer"},"id":{"type":"string"},"model":{"type":"string"},"object":{"const":"chat.completion"},"usage":{"anyOf":[{"additionalProperties":false,"properties":{"completion_tokens":{"minimum":0,"type":"integer"},"prompt_tokens":{"minimum":0,"type":"integer"},"prompt_tokens_details":{"additionalProperties":false,"properties":{"cached_tokens":{"minimum":0,"type":"integer"}},"required":["cached_tokens"],"type":"object"},"total_tokens":{"minimum":0,"type":"integer"}},"required":["prompt_tokens","completion_tokens","total_tokens"],"type":"object"},{"type":"null"}],"description":"Null when usage has not been confirmed. Check account usage for reconciliation."}},"required":["id","object","created","model","choices","usage"],"type":"object"},"Error":{"additionalProperties":false,"properties":{"error":{"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"param":{"anyOf":[{"type":"string"},{"type":"null"}]},"type":{"type":"string"}},"required":["message","type","code","param"],"type":"object"}},"required":["error"],"type":"object"},"Key":{"additionalProperties":false,"properties":{"data":{"additionalProperties":false,"properties":{"allowed_models":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}]},"created_at":{"type":"string"},"expires_at":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}]},"label":{"type":"string"},"limit":{"anyOf":[{"description":"Decimal USD string.","type":"string"},{"type":"null"}]},"limit_remaining":{"anyOf":[{"description":"Decimal USD string.","type":"string"},{"type":"null"}]},"limit_reset":{"anyOf":[{"enum":["daily","weekly","monthly"],"type":"string"},{"type":"null"}]},"name":{"type":"string"},"store_content":{"description":"Key content storage preference. New keys default false; account Zero Data Retention overrides capture.","type":"boolean"},"usage":{"description":"Decimal USD string.","type":"string"},"usage_daily":{"description":"Decimal USD string.","type":"string"},"usage_monthly":{"description":"Decimal USD string.","type":"string"},"usage_weekly":{"description":"Decimal USD string.","type":"string"},"verification":{"additionalProperties":false,"properties":{"expires_at":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}]},"tier":{"enum":[0,1,2],"type":"integer"}},"required":["tier","expires_at"],"type":"object"}},"required":["allowed_models","created_at","expires_at","label","limit","limit_remaining","limit_reset","name","store_content","usage","usage_daily","usage_monthly","usage_weekly","verification"],"type":"object"}},"required":["data"],"type":"object"},"MessageResponse":{"additionalProperties":false,"properties":{"content":{"items":{"oneOf":[{"additionalProperties":false,"properties":{"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"properties":{"id":{"type":"string"},"input":{"type":"object"},"name":{"type":"string"},"type":{"const":"tool_use"}},"required":["type","id","name","input"],"type":"object"}]},"type":"array"},"id":{"type":"string"},"model":{"type":"string"},"role":{"const":"assistant"},"stop_reason":{"enum":["end_turn","max_tokens","tool_use"],"type":"string"},"stop_sequence":{"type":"null"},"type":{"const":"message"},"usage":{"additionalProperties":false,"description":"Counts are omitted when unreported. input_tokens excludes reported cached input.","properties":{"cache_read_input_tokens":{"minimum":0,"type":"integer"},"input_tokens":{"minimum":0,"type":"integer"},"output_tokens":{"minimum":0,"type":"integer"}},"required":[],"type":"object"}},"required":["id","type","role","model","content","stop_reason","stop_sequence","usage"],"type":"object"},"MessagesCountRequest":{"additionalProperties":false,"description":"Messages-shaped input for a conservative token estimate. max_tokens is optional. The estimate is capped at the model context limit and is not tokenizer-exact or a guarantee of admission. No generation or credit hold.","properties":{"context_management":{"additionalProperties":false,"description":"Only clear_thinking edits with keep=all; accepted and ignored.","properties":{"edits":{"items":{"additionalProperties":false,"properties":{"keep":{"const":"all"},"type":{"const":"clear_thinking_20251015"}},"required":["type","keep"],"type":"object"},"type":"array"}},"required":["edits"],"type":"object"},"max_tokens":{"description":"Required output upper bound, capped to the model maximum.","minimum":1,"type":"integer"},"messages":{"items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"oneOf":[{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","properties":{"source":{"additionalProperties":false,"properties":{"data":{"type":"string"},"media_type":{"enum":["image/png","image/jpeg","image/webp"],"type":"string"},"type":{"const":"base64"}},"required":["type","media_type","data"],"type":"object"},"type":{"const":"image"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"description":"Documents are omitted with a text notice; document-only requests are refused.","properties":{"source":{"type":"object"},"type":{"const":"document"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"properties":{"tool_name":{"type":"string"},"type":{"const":"tool_reference"}},"required":["type","tool_name"],"type":"object"}]},{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"caller":{"additionalProperties":false,"properties":{"type":{"const":"direct"}},"required":["type"],"type":"object"},"id":{"type":"string"},"input":{"type":"object"},"name":{"type":"string"},"type":{"const":"tool_use"}},"required":["type","id","name","input"],"type":"object"},{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","properties":{"source":{"additionalProperties":false,"properties":{"data":{"type":"string"},"media_type":{"enum":["image/png","image/jpeg","image/webp"],"type":"string"},"type":{"const":"base64"}},"required":["type","media_type","data"],"type":"object"},"type":{"const":"image"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"description":"Documents are omitted with a text notice; document-only requests are refused.","properties":{"source":{"type":"object"},"type":{"const":"document"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"properties":{"tool_name":{"type":"string"},"type":{"const":"tool_reference"}},"required":["type","tool_name"],"type":"object"}]},"type":"array"}]},"is_error":{"type":"boolean"},"tool_use_id":{"type":"string"},"type":{"const":"tool_result"}},"required":["type","tool_use_id"],"type":"object"},{"description":"Replay compatibility: visible compaction/server-result text is preserved; opaque reasoning and signatures are omitted.","properties":{"type":{"enum":["thinking","redacted_thinking","compaction","server_tool_use","web_search_tool_result","web_fetch_tool_result","tool_search_tool_result","tool_addition","tool_removal"],"type":"string"}},"required":["type"],"type":"object"}]},"type":"array"}]},"role":{"enum":["user","assistant","system"],"type":"string"}},"required":["role","content"],"type":"object"},"maxItems":4096,"minItems":1,"type":"array"},"metadata":{"description":"Accepted; ignored."},"model":{"description":"Use an exact catalog model ID.","minLength":1,"type":"string"},"output_config":{"additionalProperties":false,"properties":{"effort":{"description":"Accepted; ignored.","enum":["low","medium","high","xhigh","max"],"type":"string"},"format":{"additionalProperties":false,"properties":{"schema":{"type":"object"},"type":{"const":"json_schema"}},"required":["type","schema"],"type":"object"}},"required":[],"type":"object"},"stop_sequences":{"items":{"type":"string"},"maxItems":4,"type":"array"},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Default false. True returns server-sent events."},"system":{"anyOf":[{"type":"string"},{"items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},"type":"array"}]},"temperature":{"maximum":1,"minimum":0,"type":["number","null"]},"thinking":{"additionalProperties":false,"description":"Accepted; ignored.","properties":{"budget_tokens":{},"display":{},"type":{"enum":["adaptive","enabled","disabled"],"type":"string"}},"required":["type"],"type":"object"},"thread":{"description":"Stateless compatibility: create uses full history; continue returns 404 with error.details.error_code=thread_not_found so clients replay full history.","oneOf":[{"additionalProperties":false,"properties":{"type":{"const":"create"}},"required":["type"],"type":"object"},{"additionalProperties":false,"properties":{"previous_message_id":{"maxLength":256,"minLength":1,"type":"string"},"type":{"const":"continue"}},"required":["type","previous_message_id"],"type":"object"}]},"tool_choice":{"additionalProperties":false,"properties":{"disable_parallel_tool_use":{"type":"boolean"},"name":{"description":"Required when type is tool.","type":"string"},"type":{"enum":["auto","any","tool","none"],"type":"string"}},"required":["type"],"type":"object"},"tools":{"description":"Up to 4096 declared tools; at most 128 active tools totaling 256 KiB reach inference.","items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"defer_loading":{"description":"Withheld until activated by a tool addition, tool-result reference, or explicit named tool choice.","type":"boolean"},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"input_schema":{"type":"object"},"name":{"type":"string"}},"required":["name","input_schema"],"type":"object"},"maxItems":4096,"type":"array"},"top_p":{"maximum":1,"minimum":0,"type":["number","null"]}},"required":["model","messages"],"type":"object"},"MessagesError":{"additionalProperties":false,"properties":{"error":{"additionalProperties":false,"properties":{"details":{"additionalProperties":false,"properties":{"error_code":{"type":"string"}},"required":["error_code"],"type":"object"},"message":{"type":"string"},"type":{"type":"string"}},"required":["type","message"],"type":"object"},"type":{"const":"error"}},"required":["type","error"],"type":"object"},"MessagesEvent":{"oneOf":[{"additionalProperties":false,"properties":{"message":{"additionalProperties":false,"properties":{"content":{"items":{},"type":"array"},"id":{"type":"string"},"model":{"type":"string"},"role":{"const":"assistant"},"stop_reason":{"type":"null"},"stop_sequence":{"type":"null"},"type":{"const":"message"},"usage":{"additionalProperties":false,"properties":{},"required":[],"type":"object"}},"required":["id","type","role","model","content","stop_reason","stop_sequence","usage"],"type":"object"},"type":{"const":"message_start"}},"required":["type","message"],"type":"object"},{"additionalProperties":false,"properties":{"type":{"const":"ping"}},"required":["type"],"type":"object"},{"additionalProperties":false,"properties":{"content_block":{"oneOf":[{"additionalProperties":false,"properties":{"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"properties":{"id":{"type":"string"},"input":{"type":"object"},"name":{"type":"string"},"type":{"const":"tool_use"}},"required":["type","id","name","input"],"type":"object"}]},"index":{"minimum":0,"type":"integer"},"type":{"const":"content_block_start"}},"required":["type","index","content_block"],"type":"object"},{"additionalProperties":false,"properties":{"delta":{"oneOf":[{"additionalProperties":false,"properties":{"text":{"type":"string"},"type":{"const":"text_delta"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"properties":{"partial_json":{"type":"string"},"type":{"const":"input_json_delta"}},"required":["type","partial_json"],"type":"object"}]},"index":{"minimum":0,"type":"integer"},"type":{"const":"content_block_delta"}},"required":["type","index","delta"],"type":"object"},{"additionalProperties":false,"properties":{"index":{"minimum":0,"type":"integer"},"type":{"const":"content_block_stop"}},"required":["type","index"],"type":"object"},{"additionalProperties":false,"properties":{"delta":{"additionalProperties":false,"properties":{"stop_reason":{"enum":["end_turn","max_tokens","tool_use"],"type":"string"},"stop_sequence":{"type":"null"}},"required":["stop_reason","stop_sequence"],"type":"object"},"type":{"const":"message_delta"},"usage":{"additionalProperties":false,"description":"Counts are omitted when unreported. input_tokens excludes reported cached input.","properties":{"cache_read_input_tokens":{"minimum":0,"type":"integer"},"input_tokens":{"minimum":0,"type":"integer"},"output_tokens":{"minimum":0,"type":"integer"}},"required":[],"type":"object"}},"required":["type","delta","usage"],"type":"object"},{"additionalProperties":false,"properties":{"type":{"const":"message_stop"}},"required":["type"],"type":"object"},{"$ref":"#/components/schemas/MessagesError"}]},"MessagesRequest":{"additionalProperties":false,"properties":{"context_management":{"additionalProperties":false,"description":"Only clear_thinking edits with keep=all; accepted and ignored.","properties":{"edits":{"items":{"additionalProperties":false,"properties":{"keep":{"const":"all"},"type":{"const":"clear_thinking_20251015"}},"required":["type","keep"],"type":"object"},"type":"array"}},"required":["edits"],"type":"object"},"max_tokens":{"description":"Required output upper bound, capped to the model maximum.","minimum":1,"type":"integer"},"messages":{"items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"oneOf":[{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","properties":{"source":{"additionalProperties":false,"properties":{"data":{"type":"string"},"media_type":{"enum":["image/png","image/jpeg","image/webp"],"type":"string"},"type":{"const":"base64"}},"required":["type","media_type","data"],"type":"object"},"type":{"const":"image"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"description":"Documents are omitted with a text notice; document-only requests are refused.","properties":{"source":{"type":"object"},"type":{"const":"document"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"properties":{"tool_name":{"type":"string"},"type":{"const":"tool_reference"}},"required":["type","tool_name"],"type":"object"}]},{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"caller":{"additionalProperties":false,"properties":{"type":{"const":"direct"}},"required":["type"],"type":"object"},"id":{"type":"string"},"input":{"type":"object"},"name":{"type":"string"},"type":{"const":"tool_use"}},"required":["type","id","name","input"],"type":"object"},{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"content":{"anyOf":[{"type":"string"},{"items":{"oneOf":[{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},{"additionalProperties":false,"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","properties":{"source":{"additionalProperties":false,"properties":{"data":{"type":"string"},"media_type":{"enum":["image/png","image/jpeg","image/webp"],"type":"string"},"type":{"const":"base64"}},"required":["type","media_type","data"],"type":"object"},"type":{"const":"image"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"description":"Documents are omitted with a text notice; document-only requests are refused.","properties":{"source":{"type":"object"},"type":{"const":"document"}},"required":["type","source"],"type":"object"},{"additionalProperties":false,"properties":{"tool_name":{"type":"string"},"type":{"const":"tool_reference"}},"required":["type","tool_name"],"type":"object"}]},"type":"array"}]},"is_error":{"type":"boolean"},"tool_use_id":{"type":"string"},"type":{"const":"tool_result"}},"required":["type","tool_use_id"],"type":"object"},{"description":"Replay compatibility: visible compaction/server-result text is preserved; opaque reasoning and signatures are omitted.","properties":{"type":{"enum":["thinking","redacted_thinking","compaction","server_tool_use","web_search_tool_result","web_fetch_tool_result","tool_search_tool_result","tool_addition","tool_removal"],"type":"string"}},"required":["type"],"type":"object"}]},"type":"array"}]},"role":{"enum":["user","assistant","system"],"type":"string"}},"required":["role","content"],"type":"object"},"maxItems":4096,"minItems":1,"type":"array"},"metadata":{"description":"Accepted; ignored."},"model":{"description":"Use an exact catalog model ID.","minLength":1,"type":"string"},"output_config":{"additionalProperties":false,"properties":{"effort":{"description":"Accepted; ignored.","enum":["low","medium","high","xhigh","max"],"type":"string"},"format":{"additionalProperties":false,"properties":{"schema":{"type":"object"},"type":{"const":"json_schema"}},"required":["type","schema"],"type":"object"}},"required":[],"type":"object"},"stop_sequences":{"items":{"type":"string"},"maxItems":4,"type":"array"},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Default false. True returns server-sent events."},"system":{"anyOf":[{"type":"string"},{"items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"citations":{"description":"Citation metadata is omitted; accompanying text is retained.","items":{},"type":"array"},"text":{"type":"string"},"type":{"const":"text"}},"required":["type","text"],"type":"object"},"type":"array"}]},"temperature":{"maximum":1,"minimum":0,"type":["number","null"]},"thinking":{"additionalProperties":false,"description":"Accepted; ignored.","properties":{"budget_tokens":{},"display":{},"type":{"enum":["adaptive","enabled","disabled"],"type":"string"}},"required":["type"],"type":"object"},"thread":{"description":"Stateless compatibility: create uses full history; continue returns 404 with error.details.error_code=thread_not_found so clients replay full history.","oneOf":[{"additionalProperties":false,"properties":{"type":{"const":"create"}},"required":["type"],"type":"object"},{"additionalProperties":false,"properties":{"previous_message_id":{"maxLength":256,"minLength":1,"type":"string"},"type":{"const":"continue"}},"required":["type","previous_message_id"],"type":"object"}]},"tool_choice":{"additionalProperties":false,"properties":{"disable_parallel_tool_use":{"type":"boolean"},"name":{"description":"Required when type is tool.","type":"string"},"type":{"enum":["auto","any","tool","none"],"type":"string"}},"required":["type"],"type":"object"},"tools":{"description":"Up to 4096 declared tools; at most 128 active tools totaling 256 KiB reach inference.","items":{"additionalProperties":false,"properties":{"cache_control":{"description":"Accepted for compatibility; ignored. Reported cache reads are discounted automatically."},"defer_loading":{"description":"Withheld until activated by a tool addition, tool-result reference, or explicit named tool choice.","type":"boolean"},"description":{"anyOf":[{"type":"string"},{"type":"null"}]},"input_schema":{"type":"object"},"name":{"type":"string"}},"required":["name","input_schema"],"type":"object"},"maxItems":4096,"type":"array"},"top_p":{"maximum":1,"minimum":0,"type":["number","null"]}},"required":["model","max_tokens","messages"],"type":"object"},"Models":{"additionalProperties":false,"properties":{"data":{"items":{"additionalProperties":false,"properties":{"capabilities":{"additionalProperties":false,"properties":{"image_input":{"type":"boolean"},"response_format":{"type":"boolean"},"tool_calling":{"type":"boolean"}},"required":["tool_calling","response_format","image_input"],"type":"object"},"created":{"const":0},"id":{"type":"string"},"object":{"const":"model"},"owned_by":{"const":"redrouter"}},"required":["id","object","created","owned_by","capabilities"],"type":"object"},"type":"array"},"object":{"const":"list"}},"required":["object","data"],"type":"object"},"Plan":{"additionalProperties":false,"properties":{"annual_monthly_usd":{"anyOf":[{"type":"string"},{"type":"null"}]},"annual_price_usd":{"anyOf":[{"type":"string"},{"type":"null"}]},"daily_spend_usd":{"type":"string"},"id":{"enum":["developer","growth","scale","business","enterprise"],"type":"string"},"max_concurrency":{"minimum":0,"type":"integer"},"name":{"type":"string"},"price_usd":{"type":"string"},"requests_per_minute":{"minimum":0,"type":"integer"},"usage_multiple":{"anyOf":[{"minimum":0,"type":"integer"},{"type":"null"}]},"zero_retention_included":{"type":"boolean"}},"required":["id","name","price_usd","annual_price_usd","annual_monthly_usd","usage_multiple","requests_per_minute","max_concurrency","daily_spend_usd","zero_retention_included"],"type":"object"},"PlanSelection":{"additionalProperties":false,"properties":{"billing_country":{"anyOf":[{"type":"string"},{"type":"null"}]},"interval":{"default":"month","enum":["month","year"],"type":"string"},"plan":{"type":"string"},"ref":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["plan"],"type":"object"},"PlanUsage":{"additionalProperties":false,"description":"Monthly plan usage, including holds, rounded to the nearest percentage. Any use is at least 1%; 100% means nothing remains. Usage is metered at standard token rates; heavier models use it faster.","properties":{"exhausted":{"type":"boolean"},"resets_at":{"format":"date-time","type":"string"},"used_percent":{"maximum":100,"minimum":0,"type":"integer"}},"required":["used_percent","resets_at","exhausted"],"type":"object"},"Response":{"additionalProperties":false,"properties":{"created_at":{"minimum":0,"type":"integer"},"error":{"anyOf":[{"type":"object"},{"type":"null"}]},"id":{"type":"string"},"incomplete_details":{"anyOf":[{"additionalProperties":false,"properties":{"reason":{"enum":["max_output_tokens","content_filter"],"type":"string"}},"required":["reason"],"type":"object"},{"type":"null"}]},"model":{"type":"string"},"object":{"const":"response"},"output":{"items":{"description":"message with output_text content, reasoning with reasoning_text content, function_call with arguments, or custom_tool_call with input. RedRouter item and call IDs.","type":"object"},"type":"array"},"status":{"enum":["in_progress","completed","incomplete","failed"],"type":"string"},"store":{"const":false},"usage":{"anyOf":[{"additionalProperties":false,"properties":{"input_tokens":{"minimum":0,"type":"integer"},"input_tokens_details":{"additionalProperties":false,"properties":{"cached_tokens":{"minimum":0,"type":"integer"}},"required":["cached_tokens"],"type":"object"},"output_tokens":{"minimum":0,"type":"integer"},"output_tokens_details":{"additionalProperties":false,"properties":{"reasoning_tokens":{"minimum":0,"type":"integer"}},"required":["reasoning_tokens"],"type":"object"},"total_tokens":{"minimum":0,"type":"integer"}},"required":["input_tokens","output_tokens","total_tokens"],"type":"object"},{"type":"null"}]}},"required":["id","object","created_at","status","model","store","output","usage","incomplete_details","error"],"type":"object"},"ResponsesEvent":{"properties":{"sequence_number":{"minimum":0,"type":"integer"},"type":{"type":"string"}},"required":["type","sequence_number"],"type":"object"},"ResponsesRequest":{"additionalProperties":false,"description":"Message content accepts input_text, output_text and input_image parts (image_url is a base64 data URL), including function/custom tool outputs. Stateless translation through Chat Completions admission, billing, capture, and transport. Unknown fields fail. reasoning, metadata, client_metadata, user, prompt_cache_key, include, service_tier, truncation, text.verbosity, function strict, and custom grammar hints are accepted but ignored. No server truncation or hosted execution.","properties":{"client_metadata":{"anyOf":[{"type":"object"},{"type":"null"}]},"conversation":{"description":"Unsupported; always returns 400.","not":{}},"include":{"items":{"type":"string"},"type":"array"},"input":{"anyOf":[{"type":"string"},{"items":{"description":"Text/image messages (system/developer/user/assistant), function_call/function_call_output, custom_tool_call/custom_tool_call_output, or ignored reasoning. Send complete history; every call needs its result.","type":"object"},"maxItems":512,"minItems":1,"type":"array"}]},"instructions":{"anyOf":[{"type":"string"},{"type":"null"}]},"max_output_tokens":{"anyOf":[{"maximum":4294967295,"minimum":1,"type":"integer"},{"type":"null"}],"description":"Output upper bound, capped to the model maximum."},"metadata":{"anyOf":[{"type":"object"},{"type":"null"}]},"model":{"description":"Use an exact catalog model ID.","minLength":1,"type":"string"},"parallel_tool_calls":{"anyOf":[{"type":"boolean"},{"type":"null"}]},"previous_response_id":{"description":"Unsupported; always returns 400.","not":{}},"prompt_cache_key":{"anyOf":[{"type":"string"},{"type":"null"}]},"reasoning":{"anyOf":[{"additionalProperties":false,"properties":{"effort":{"anyOf":[{"enum":["none","minimal","low","medium","high","xhigh","max"],"type":"string"},{"type":"null"}]},"summary":{"anyOf":[{"enum":["auto","concise","detailed"],"type":"string"},{"type":"null"}]}},"required":[],"type":"object"},{"type":"null"}]},"service_tier":{"anyOf":[{"type":"string"},{"type":"null"}]},"store":{"description":"Accepted; responses are never persisted. Always false in output. Request-log retention is independent.","type":"boolean"},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"description":"Default false. True returns server-sent events."},"temperature":{"maximum":2,"minimum":0,"type":["number","null"]},"text":{"anyOf":[{"additionalProperties":false,"properties":{"format":{"description":"text, json_object, or flat json_schema with name/schema/strict/description.","type":"object"},"verbosity":{"enum":["low","medium","high"],"type":"string"}},"required":[],"type":"object"},{"type":"null"}]},"tool_choice":{"anyOf":[{"enum":["auto","none","required"],"type":"string"},{"additionalProperties":false,"properties":{"name":{"type":"string"},"namespace":{"type":"string"},"type":{"enum":["function","custom"],"type":"string"}},"required":["type","name"],"type":"object"},{"type":"null"}]},"tools":{"items":{"description":"Flat or namespaced function definitions and custom freeform tools. Custom maps to a single string input. Only the exact cached web_search declaration is ignored; other hosted tools fail.","type":"object"},"maxItems":128,"type":["array","null"]},"top_p":{"maximum":1,"minimum":0,"type":["number","null"]},"truncation":{"enum":["auto","disabled"],"type":"string"},"user":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Accepted for client compatibility; ignored."}},"required":["model","input"],"type":"object"},"SavedConversation":{"additionalProperties":false,"description":"Encrypted account-scoped saved history, 1 MiB serialized limit. Omitted version is legacy v1. Grants/bookmarks are forbidden. Zero Data Retention refuses writes.","properties":{"settings":{"additionalProperties":false,"properties":{"maxTokens":{"type":"string"},"system":{"type":"string"},"temperature":{"type":"string"}},"required":["system","maxTokens","temperature"],"type":"object"},"slots":{"items":{"type":"string"},"maxItems":2,"minItems":1,"type":"array"},"title":{"type":"string"},"turns":{"items":{"additionalProperties":false,"properties":{"attachments":{"description":"v2 only. Confirmed text snapshots; relative names only. 64 KiB UTF-8 per file, 128 KiB aggregate. Attachment-only turns are valid.","items":{"additionalProperties":false,"properties":{"name":{"type":"string"},"text":{"type":"string"}},"required":["name","text"],"type":"object"},"maxItems":20,"type":"array"},"replies":{"items":{"additionalProperties":false,"properties":{"error":{"anyOf":[{"additionalProperties":false,"properties":{"code":{"anyOf":[{"type":"string"},{"type":"null"}]},"message":{"type":"string"}},"required":["message"],"type":"object"},{"type":"null"}]},"exchanges":{"description":"v2 only. Full ordered assistant/tool transcript, including the final assistant reply. At most eight rounds/sixteen calls. Incomplete calls allowed only for stopped/error replies; insert cancelled results before continuation. Never replay effects.","items":{"oneOf":[{"additionalProperties":false,"properties":{"content":{"anyOf":[{"type":"string"},{"type":"null"}]},"role":{"const":"assistant"},"tool_calls":{"items":{"additionalProperties":false,"properties":{"function":{"additionalProperties":false,"properties":{"arguments":{"type":"string"},"name":{"type":"string"}},"required":["name","arguments"],"type":"object"},"id":{"type":"string"},"type":{"const":"function"}},"required":["id","type","function"],"type":"object"},"maxItems":4,"type":"array"}},"required":["role"],"type":"object"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"role":{"const":"tool"},"tool_call_id":{"type":"string"}},"required":["role","tool_call_id","content"],"type":"object"}]},"maxItems":24,"type":"array"},"finish_reason":{"anyOf":[{"type":"string"},{"type":"null"}]},"meta":{"items":{"additionalProperties":false,"properties":{"error":{"type":"boolean"},"text":{"type":"string"}},"required":["text","error"],"type":"object"},"type":"array"},"model":{"type":"string"},"slot":{"maximum":1,"minimum":0,"type":"integer"},"state":{"enum":["complete","error","stopped"],"type":"string"},"text":{"type":"string"}},"required":["slot","model","text","state","meta"],"type":"object"},"maxItems":2,"minItems":1,"type":"array"},"user":{"type":"string"}},"required":["user","replies"],"type":"object"},"minItems":1,"type":"array"},"version":{"enum":[1,2],"type":"integer"}},"required":["slots","settings","turns"],"type":"object"},"Subscription":{"additionalProperties":false,"properties":{"action_required":{"anyOf":[{"additionalProperties":false,"properties":{"invoice_id":{"type":"string"},"kind":{"type":"string"},"next_attempt_at":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}]}},"required":["invoice_id","kind","next_attempt_at"],"type":"object"},{"type":"null"}]},"cancel_at_period_end":{"type":"boolean"},"current_period_end":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}],"description":"End of the paid term; annual plan usage resets monthly."},"current_period_start":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}]},"interval":{"enum":["month","year"],"type":"string"},"next_charge_at":{"anyOf":[{"format":"date-time","type":"string"},{"type":"null"}]},"next_charge_usd":{"anyOf":[{"type":"string"},{"type":"null"}]},"next_interval":{"anyOf":[{"enum":["month","year"],"type":"string"},{"type":"null"}]},"next_plan":{"anyOf":[{"type":"string"},{"type":"null"}]},"payment_method":{"anyOf":[{"additionalProperties":false,"properties":{"brand":{"type":"string"},"last4":{"type":"string"}},"required":["brand","last4"],"type":"object"},{"type":"null"}]},"plan":{"type":"string"},"status":{"type":"string"},"usage":{"anyOf":[{"$ref":"#/components/schemas/PlanUsage"},{"type":"null"}]}},"required":["plan","interval","next_interval","usage","status","current_period_start","current_period_end","cancel_at_period_end","next_plan","next_charge_usd","next_charge_at","payment_method","action_required"],"type":"object"},"SubscriptionCheckout":{"additionalProperties":false,"properties":{"client_secret":{"anyOf":[{"type":"string"},{"type":"null"}]},"id":{"format":"uuid","type":"string"},"publishable_key":{"anyOf":[{"type":"string"},{"type":"null"}]}},"required":["id","client_secret","publishable_key"],"type":"object"}},"securitySchemes":{"accountSession":{"in":"cookie","name":"__Host-rr_session","type":"apiKey"},"apiKey":{"in":"header","name":"x-api-key","type":"apiKey"},"bearerAuth":{"scheme":"bearer","type":"http"}}},"info":{"title":"RedRouter API","version":"0.1.0"},"openapi":"3.1.0","paths":{"/api/catalog":{"get":{"operationId":"get-catalog","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Catalog"}}},"description":"Successful response"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Internal error"}},"security":[],"summary":"Get model catalog","x-order":6}},"/api/plans":{"get":{"description":"Annual plans cost ten monthly payments for twelve months: 2 months free. Developer has no annual option. Enterprise is unlisted.","operationId":"list-plans","responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"plans":{"items":{"$ref":"#/components/schemas/Plan"},"type":"array"}},"required":["plans"],"type":"object"}}},"description":"Public plans"}},"summary":"List public plans"}},"/api/subscription":{"get":{"description":"Requires an authenticated account session. Optional plan query reveals an unlisted plan. Account dollar fields credits_balance_usd, credits_held_usd and credits_available_usd exclude plan usage; legacy aggregate balance fields remain for released desktop clients.","operationId":"get-subscription","parameters":[{"in":"query","name":"plan","schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountSubscription"}}},"description":"Subscription and account plan views"}},"security":[{"accountSession":[]}],"summary":"Get the account subscription","x-account-session":true}},"/api/subscription/change":{"post":{"description":"Requires an authenticated account session and browser CSRF header. Omitted interval defaults to month. Changes take effect at renewal, without proration.","operationId":"subscription-change","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanSelection"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"purchased_balance_usd":{"type":"string"},"subscription":{"anyOf":[{"$ref":"#/components/schemas/Subscription"},{"type":"null"}]}},"required":["subscription","purchased_balance_usd"],"type":"object"}}},"description":"Successful subscription operation"}},"security":[{"accountSession":[]}],"summary":"Subscription change","x-account-session":true}},"/api/subscription/checkout":{"post":{"description":"Requires an authenticated account session and browser CSRF header. Omitted interval defaults to month. Changes take effect at renewal, without proration.","operationId":"subscription-checkout","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanSelection"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionCheckout"}}},"description":"Successful subscription operation"}},"security":[{"accountSession":[]}],"summary":"Subscription checkout","x-account-session":true}},"/v1/chat/completions":{"post":{"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","operationId":"chat-completions","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}},"text/event-stream":{"schema":{"description":"Each data field is ChatChunk JSON. The terminal data field is [DONE]. Usage may follow finish_reason when stream_options.include_usage is true.","type":"string"},"x-event-schema":{"$ref":"#/components/schemas/ChatChunk"}}},"description":"Completed response or event stream"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid key"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Insufficient credit"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Key permissions or spend limit"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Unknown model"},"413":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Request too large"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Rate, concurrency or daily spend limit"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Internal error"},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Model response failed"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Model unavailable"}},"security":[{"bearerAuth":[]}],"summary":"Create a chat completion","x-max-request-bytes":12000000,"x-order":1}},"/v1/key":{"get":{"operationId":"current-key","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Key"}}},"description":"Successful response"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid key"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Expired or paused key"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Internal error"}},"security":[{"bearerAuth":[]}],"summary":"Get key usage","x-order":5}},"/v1/messages":{"post":{"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","operationId":"create-message","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}},"text/event-stream":{"schema":{"description":"Named events: ping, message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop. Failures emit error. Read through message_stop.","type":"string"},"x-event-schema":{"$ref":"#/components/schemas/MessagesEvent"}}},"description":"Completed response or event stream"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Invalid request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Invalid key"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Permissions, spend limit or insufficient credit"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Unknown model"},"413":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request too large"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Rate, concurrency or daily spend limit"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Internal error"},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Model response failed"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Model unavailable"}},"security":[{"bearerAuth":[]},{"apiKey":[]}],"summary":"Create a message","x-max-request-bytes":12000000,"x-order":3}},"/v1/messages/count_tokens":{"post":{"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs. Conservative input-token estimate, capped at the model context limit; not tokenizer-exact or a guarantee that generation will fit. No inference call or credit reservation.","operationId":"count-tokens","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesCountRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":false,"properties":{"input_tokens":{"minimum":0,"type":"integer"}},"required":["input_tokens"],"type":"object"}}},"description":"Estimated input tokens"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"},"413":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessagesError"}}},"description":"Request refused"}},"security":[{"bearerAuth":[]},{"apiKey":[]}],"summary":"Estimate input tokens","x-max-request-bytes":12000000,"x-order":4}},"/v1/models":{"get":{"operationId":"list-models","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Models"}}},"description":"Successful response"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Internal error"}},"security":[],"summary":"List models","x-order":0}},"/v1/responses":{"post":{"description":"Image input is enabled on deepseek-v4.1-flash-1017, deepseek-v4.1-flash-0910, glm-5.3-flash and qwen3.8-27b. User and tool messages accept base64 data URLs with PNG, JPEG or WebP headers. Model API requests allow 12,000,000 bytes (12 MB). Images bill as ordinary input tokens at existing rates, with no surcharge. Other models (including every -red model and glm-5.3), remote URLs and invalid/unsupported images receive [Image omitted: this text-only model cannot inspect it. Ask for a text description.] in place. Images are never fetched from URLs.","operationId":"create-response","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponsesRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}},"text/event-stream":{"schema":{"description":"Named Responses events carry sequence_number. Read through response.completed or response.incomplete; midstream errors emit response.failed. Usage is null when unknown. Stateless: store is always false.","type":"string"},"x-event-schema":{"$ref":"#/components/schemas/ResponsesEvent"}}},"description":"Completed response or event stream"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid key"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Insufficient credit"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Key permissions or spend limit"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Unknown model"},"413":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Request too large"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Rate, concurrency or daily spend limit"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Internal error"},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Model response failed"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Model unavailable"}},"security":[{"bearerAuth":[]}],"summary":"Create a response","x-max-request-bytes":12000000,"x-order":2}}},"servers":[{"url":"https://redrouter.org"}]}