{"openapi":"3.1.0","info":{"title":"LLM Proxy API","description":"Multi-provider AI gateway. 23 providers, 340+ models, automatic fallback.","version":"2.0.0"},"paths":{"/v1/chat/completions":{"post":{"summary":"Chat Completions","description":"OpenAI-compatible chat with high availability and automatic failover.\n\nSupports: streaming (SSE), tool calls, reasoning/thinking, vision.","operationId":"chatCompletions","tags":["Chat"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}},"text/event-stream":{"description":"SSE stream (when stream=true)"}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"All providers exhausted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/messages/count_tokens":{"post":{"summary":"Count Tokens Endpoint","description":"Anthropic context-preflight token count. Auth-gated like /v1/messages.\n\nDeclared BEFORE the ``/v1/messages`` route so the more specific subpath is\nmatched first. The sync handler runs in the threadpool via ``run_handler``\n(the native-pool checkout is sync); it never streams and never bills.","operationId":"count_tokens_endpoint_v1_messages_count_tokens_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/messages":{"post":{"summary":"Messages (Anthropic)","description":"Native Anthropic Messages API with extended thinking, cache control, streaming.","operationId":"messages","tags":["Messages"],"parameters":[{"name":"anthropic-version","in":"header","required":true,"schema":{"type":"string","default":"2023-06-01"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"},"502":{"description":"Exhausted"}}}},"/v1/responses":{"post":{"summary":"Responses (OpenAI)","description":"OpenAI Responses API (Codex CLI compatible).","operationId":"responses","tags":["Responses"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Response"}}}},"/v1beta/models/{rest}":{"post":{"summary":"Gemini Generate Endpoint","operationId":"gemini_generate_endpoint_v1beta_models__rest__post","parameters":[{"name":"rest","in":"path","required":true,"schema":{"type":"string","title":"Rest"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/embeddings":{"post":{"summary":"Embeddings","description":"Generate text embeddings (OpenAI-compatible).","operationId":"embeddings","tags":["Embeddings"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","default":"text-embedding-3-small"},"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}}}}},"responses":{"200":{"description":"Embedding vectors"}}}},"/v1/images/generations":{"post":{"summary":"Image Generation","description":"Generate images from a text prompt.","operationId":"imageGeneration","tags":["Images"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","default":"grok-image"},"prompt":{"type":"string"},"n":{"type":"integer","default":1}}}}}},"responses":{"200":{"description":"Generated images"}}}},"/v1/audio/transcriptions":{"post":{"summary":"Audio Transcription","description":"Transcribe audio (Whisper-compatible).","operationId":"audioTranscription","tags":["Audio"],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"},"model":{"type":"string","default":"whisper-large-v3"}}}}}},"responses":{"200":{"description":"Transcription text"}}}},"/v1":{"get":{"tags":["System"],"summary":"Root","description":"Status / capability summary (no auth).","operationId":"root_v1_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/":{"get":{"tags":["System"],"summary":"Root","description":"Status / capability summary (no auth).","operationId":"root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/health":{"get":{"tags":["System"],"summary":"Health","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/metrics":{"get":{"tags":["System"],"summary":"Metrics","description":"Lightweight process metrics for memory-leak monitoring.","operationId":"metrics_metrics_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/metrics/history":{"get":{"tags":["System"],"summary":"Metrics History","description":"Process metrics time-series for dashboard memory graph.","operationId":"metrics_history_metrics_history_get","parameters":[{"name":"hours","in":"query","required":false,"schema":{"type":"integer","default":24,"title":"Hours"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/models":{"get":{"tags":["Models"],"summary":"List available models","description":"Returns models available for your API key with full properties.\n\nVisibility is role-aware: admins see all enabled models; non-admin/anonymous\ncallers see the public set, unless the key has an explicit `allowed_models`\nfilter (then only those, an admin-granted override).\n\nEach model includes: context_window, max_output_tokens, reasoning, supports_vision, supports_tools, pricing, description.","operationId":"list_models_v1_models_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/models/recommend":{"get":{"tags":["Models"],"summary":"Recommend models","description":"Suggest best models for a use case. Query params: `use_case`, `budget`.","operationId":"recommend_models_v1_models_recommend_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v2/videos":{"post":{"summary":"Create Video","description":"Create an asynchronous video-generation job. Poll the returned job id via `GET /v2/videos/{video_id}`.","operationId":"createVideo","tags":["Video"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoCreateRequest"}}}},"responses":{"200":{"description":"Job created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}},"400":{"description":"Missing/invalid model or body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"No video generation keys available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v2/videos/{video_id}":{"get":{"summary":"Get Video Job","description":"Poll a video-generation job by id; returns status and, when ready, the result URL.","operationId":"getVideoJob","tags":["Video"],"parameters":[{"name":"video_id","in":"path","required":true,"schema":{"type":"string"},"description":"Job id from Create Video"}],"responses":{"200":{"description":"Job status / result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}},"404":{"description":"Unknown job","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/key":{"get":{"tags":["System"],"summary":"Key Self Info","description":"Read-only self-info for the presented app key. Makes NO inference call.","operationId":"key_self_info_v1_key_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/key/info":{"get":{"tags":["System"],"summary":"Key Self Info Alias","description":"Alias of :func:`key_self_info`.","operationId":"key_self_info_alias_key_info_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/{rest}":{"options":{"summary":"Cors Preflight","operationId":"cors_preflight__rest__options","parameters":[{"name":"rest","in":"path","required":true,"schema":{"type":"string","title":"Rest"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/exa/search":{"post":{"summary":"Web Search (Exa)","description":"Exa.ai web search. Proxies to Exa `/search` (no personal Exa key needed).","operationId":"exaSearch","tags":["Search"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExaSearchRequest"}}}},"responses":{"200":{"description":"Exa search results"},"503":{"description":"No Exa keys available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/exa/{path}":{"post":{"summary":"Exa Passthrough","description":"Forward a JSON body to any Exa endpoint (`/{path}`).","operationId":"exaPassthrough","tags":["Search"],"parameters":[{"name":"path","in":"path","required":true,"schema":{"type":"string"},"description":"Exa endpoint path (e.g. `contents`, `findSimilar`)"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Exa response (passed through)"}}}},"/v1/perplexity/search":{"post":{"summary":"Web Search (Perplexity)","description":"Perplexity web search. Proxies to Perplexity `/search` (no personal Perplexity key needed).","operationId":"perplexitySearch","tags":["Search"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerplexitySearchRequest"}}}},"responses":{"200":{"description":"Perplexity search results"},"503":{"description":"No Perplexity keys available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/brave/search":{"get":{"summary":"Web Search (Brave)","description":"Brave web search. Proxies to Brave Search `/res/v1/web/search` (no personal Brave key needed).","operationId":"braveSearch","tags":["Search"],"parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string"},"description":"Search query"},{"name":"count","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":20,"default":10},"description":"Number of results to return"},{"name":"freshness","in":"query","required":false,"schema":{"type":"string","enum":["pd","pw","pm","py"]},"description":"Freshness filter: `pd` (day), `pw` (week), `pm` (month), `py` (year)"}],"responses":{"200":{"description":"Brave search results"},"503":{"description":"No Brave keys available","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"]},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}]},"tool_calls":{"type":"array","items":{"type":"object"}},"tool_call_id":{"type":"string"},"reasoning_content":{"type":"string","description":"Chain-of-thought (DeepSeek, OpenAI)"}}},"ChatRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Model ID (e.g. claude-opus-4-8, gpt-5.5, deepseek-v4-pro)"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"max_tokens":{"type":"integer","default":4096},"temperature":{"type":"number","minimum":0,"maximum":2},"stream":{"type":"boolean","default":false},"tools":{"type":"array","items":{"type":"object"}},"tool_choice":{"oneOf":[{"type":"string"},{"type":"object"}]},"response_format":{"type":"object"},"reasoning_effort":{"type":"string","enum":["low","medium","high","max"]},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}},"ChatResponse":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string","const":"chat.completion"},"model":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"$ref":"#/components/schemas/Message"},"finish_reason":{"type":"string"}}}},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}}}},"Model":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string","const":"model"},"owned_by":{"type":"string"},"display_name":{"type":"string"},"description":{"type":"string"},"context_window":{"type":"integer"},"max_output_tokens":{"type":"integer"},"reasoning":{"type":"boolean"},"supports_vision":{"type":"boolean"},"supports_tools":{"type":"boolean"},"is_free":{"type":"boolean"},"pricing":{"type":"object","properties":{"input":{"type":"number","description":"$/1M input tokens"},"output":{"type":"number","description":"$/1M output tokens"}}},"providers":{"type":"array","items":{"type":"string"},"description":"Model availability"}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"integer"}}}}},"ExaSearchRequest":{"type":"object","required":["query"],"additionalProperties":true,"properties":{"query":{"type":"string","description":"Search query"},"numResults":{"type":"integer","description":"Max results to return"},"type":{"type":"string","description":"Search type (e.g. auto, keyword, neural)"}},"description":"Exa /search request. Any other Exa search field is forwarded as-is."},"PerplexitySearchRequest":{"type":"object","required":["query"],"additionalProperties":true,"properties":{"query":{"type":"string","description":"The search query"},"max_results":{"type":"integer","minimum":1,"maximum":20,"default":10,"description":"Max results to return"},"search_recency_filter":{"type":"string","enum":["hour","day","week","month","year"],"description":"Restrict results by recency"},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"Limit or exclude specific domains"},"country":{"type":"string","description":"ISO 3166-1 alpha-2 country code"}},"description":"Perplexity /search request. Any other Perplexity search field is forwarded as-is."},"VideoCreateRequest":{"type":"object","required":["model"],"additionalProperties":true,"properties":{"model":{"type":"string","description":"Video model ID (e.g. veo-3.1)"},"prompt":{"type":"string","description":"Text prompt for the video"}}},"VideoJob":{"type":"object","properties":{"id":{"type":"string","description":"Job id — poll GET /v2/videos/{video_id} with this"},"status":{"type":"string","description":"Job status (e.g. pending, processing, completed)"},"model":{"type":"string"}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key: `Authorization: Bearer sk-proxy-...`"},"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Anthropic-compatible: `x-api-key: sk-proxy-...`"}}},"servers":[{"url":"https://airpx.cc","description":"Production"}],"tags":[{"name":"Chat","description":"OpenAI-compatible chat completions with streaming, tools, reasoning and vision. High availability with automatic failover."},{"name":"Messages","description":"Native Anthropic Messages API (extended thinking, cache control, streaming)."},{"name":"Responses","description":"OpenAI Responses API (Codex CLI compatible)."},{"name":"Models","description":"List and recommend available models. Visibility is role-aware (public set vs admin)."},{"name":"Embeddings","description":"Text embedding vectors."},{"name":"Images","description":"Image generation."},{"name":"Audio","description":"Audio transcription (speech-to-text)."},{"name":"Search","description":"Exa.ai web search proxy (no personal Exa key needed)."},{"name":"Video","description":"Asynchronous video generation: create a job, then poll it."},{"name":"System","description":"Service health and meta endpoints."}],"security":[{"BearerAuth":[]},{"ApiKeyAuth":[]}]}