{"openapi":"3.1.0","info":{"title":"LLM Consensus API","description":"LLM Consensus orchestrates up to 5 frontier AI models — GPT-5.4, Claude Opus 4.6, Gemini 3.1 Pro, Mistral Large 2, and Llama 3.3 70B — through iterative consensus to produce answers superior to any single model.\n\n## Modes\n\n| Mode | Models | Latency | Credits |\n|------|--------|---------|---------|\n| **fast** | 3 lightweight | ~10s | 1 |\n| **balanced** | 3 mid-tier | ~25s | 3 |\n| **deep** | 5 frontier | ~90s | 20 |\n\n## Payment Methods\n\n### 1. API Key (Developers)\nRegister at [/v1/auth/register](/v1/auth/register), buy credits via Stripe or USDC.\n\n```\nX-API-Key: orch_your_key_here\n```\n\n### 2. x402 Protocol (AI Agents)\nPay per-request with USDC on Base L2. No account needed.\n\n```\nX-Payment: base64({\"txHash\":\"0x...\",\"from\":\"0x...\"})\n```\n\nSend any request without auth to receive a `402` response with payment instructions.\n\n### 3. Crypto Top-up (NOWPayments)\nBuy credits with USDC via [/v1/billing/crypto-checkout](/v1/billing/crypto-checkout).\n\n## Streaming\n\nSend `\"stream\": true` to receive real-time progress via SSE.\n\n---\n*Patent Pending: US 19/215,933 & EU EP25176020.3*","version":"1.0.0"},"paths":{"/v1/orchestrate":{"post":{"tags":["Orchestration"],"summary":"Orquestar consulta multi-modelo","description":"Envía un prompt que será procesado por múltiples LLMs de manera colaborativa. Los modelos generan respuestas con roles especializados, se evalúan mutuamente y se sintetiza una respuesta consensuada superior a cualquier respuesta individual.\n\nUsa `\"stream\": true` para recibir progreso via Server-Sent Events.","operationId":"orchestrate_v1_orchestrate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrchestrationRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrchestrationResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/chat/completions":{"post":{"tags":["OpenAI Compatible"],"summary":"OpenAI-compatible chat completions","description":"Drop-in replacement for OpenAI's /v1/chat/completions. Use model names: consensus-fast, consensus-balanced, consensus-deep. Supports streaming via SSE in OpenAI delta format.","operationId":"chat_completions_v1_chat_completions_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/conversations":{"get":{"tags":["Conversations"],"summary":"List my conversations","operationId":"list_endpoint_v1_conversations_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":30,"title":"Limit"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"updated_at ISO from previous page","title":"Cursor"},"description":"updated_at ISO from previous page"},{"name":"include_archived","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Archived"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationsListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["Conversations"],"summary":"Delete ALL my conversations (requires {confirm: true})","operationId":"delete_all_endpoint_v1_conversations_delete","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteAllRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteAllResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/conversations/{conversation_id}":{"get":{"tags":["Conversations"],"summary":"Load full conversation with messages","operationId":"detail_endpoint_v1_conversations__conversation_id__get","parameters":[{"name":"conversation_id","in":"path","required":true,"schema":{"type":"string","title":"Conversation Id"}},{"name":"message_limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"description":"Latest N messages (ascending)","default":30,"title":"Message Limit"},"description":"Latest N messages (ascending)"},{"name":"before_index","in":"query","required":false,"schema":{"anyOf":[{"type":"integer","minimum":0},{"type":"null"}],"description":"Pagination cursor for 'Load earlier'","title":"Before Index"},"description":"Pagination cursor for 'Load earlier'"},{"name":"include_metadata","in":"query","required":false,"schema":{"type":"boolean","description":"Include peer_review/contributions/etc","default":true,"title":"Include Metadata"},"description":"Include peer_review/contributions/etc"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConversationDetailResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["Conversations"],"summary":"Rename / pin / archive a conversation","operationId":"patch_endpoint_v1_conversations__conversation_id__patch","parameters":[{"name":"conversation_id","in":"path","required":true,"schema":{"type":"string","title":"Conversation Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchConversationRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Patch Endpoint V1 Conversations  Conversation Id  Patch"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["Conversations"],"summary":"Delete a conversation (hard delete, GDPR Art. 17)","operationId":"delete_one_endpoint_v1_conversations__conversation_id__delete","parameters":[{"name":"conversation_id","in":"path","required":true,"schema":{"type":"string","title":"Conversation Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/conversations/export":{"post":{"tags":["Conversations"],"summary":"Request a full data export (GDPR Art. 20)","operationId":"export_create_endpoint_v1_conversations_export_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportRequest"}}},"required":true},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportJobStatus"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/conversations/export/{job_id}":{"get":{"tags":["Conversations"],"summary":"Poll status of a data export job","operationId":"export_status_endpoint_v1_conversations_export__job_id__get","parameters":[{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExportJobStatus"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/conversations/export/{job_id}/download":{"get":{"tags":["Conversations"],"summary":"Download the ZIP archive once the export is completed","operationId":"export_download_endpoint_v1_conversations_export__job_id__download_get","parameters":[{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/account/retention":{"get":{"tags":["Conversations"],"summary":"Get retention setting + history stats","operationId":"retention_get_endpoint_v1_account_retention_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetentionResponse"}}}}}},"put":{"tags":["Conversations"],"summary":"Update retention preference (does not delete now — applies during nightly cleanup)","operationId":"retention_put_endpoint_v1_account_retention_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetentionUpdateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetentionResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/health":{"get":{"tags":["System"],"summary":"Estado del sistema","description":"Verifica la disponibilidad del sistema y modelos configurados.","operationId":"health_v1_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/v1/usage":{"get":{"tags":["System"],"summary":"Estadísticas de uso","description":"Devuelve estadísticas de uso para la API key actual.","operationId":"usage_v1_usage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsageResponse"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/auth/register":{"post":{"tags":["Authentication"],"summary":"Register a new account","description":"Create an account and get an API key with free trial credits.","operationId":"register_v1_auth_register_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/auth/login":{"post":{"tags":["Authentication"],"summary":"Login to your account","description":"Get a JWT token for dashboard access.","operationId":"login_v1_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/auth/api-keys":{"post":{"tags":["Authentication"],"summary":"Generate a new API key","description":"Create an additional API key for your account. Requires Bearer token.","operationId":"create_api_key_v1_auth_api_keys_post","parameters":[{"name":"name","in":"query","required":false,"schema":{"type":"string","default":"default","title":"Name"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/auth/me":{"get":{"tags":["Authentication"],"summary":"Get current user info","description":"Returns your account details. Requires Bearer token.","operationId":"get_me_v1_auth_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/billing/packs":{"get":{"tags":["Billing"],"summary":"List available credit packs","description":"Returns all credit packs (Stripe card + USDC crypto).","operationId":"list_packs_v1_billing_packs_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/billing/checkout":{"post":{"tags":["Billing"],"summary":"Create Stripe checkout session","description":"Initiates a Stripe payment for a credit pack. Returns a URL to redirect the user.","operationId":"checkout_v1_billing_checkout_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/billing/history":{"get":{"tags":["Billing"],"summary":"Credit transaction history","description":"Returns recent credit transactions. Requires Bearer token.","operationId":"credit_history_v1_billing_history_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/billing/discount-tier":{"get":{"tags":["Billing"],"summary":"Get your volume discount tier","description":"Shows your current discount tier and progress to next tier.","operationId":"discount_tier_v1_billing_discount_tier_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/billing/usage":{"get":{"tags":["Billing"],"summary":"Usage history","description":"Returns recent API usage logs with credits spent. Requires Bearer token.","operationId":"usage_history_v1_billing_usage_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","default":50,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/billing/spend-limit":{"get":{"tags":["Billing"],"summary":"Get daily spend limit","description":"Returns current daily spend limit and today's spend. Requires Bearer token.","operationId":"get_spend_limit_v1_billing_spend_limit_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"tags":["Billing"],"summary":"Set daily spend limit","description":"Set or remove a daily credit spend limit. null = no limit. Requires Bearer token.","operationId":"set_spend_limit_v1_billing_spend_limit_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpendLimitRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/billing/auto-topup":{"get":{"tags":["Billing"],"summary":"Get auto top-up config","description":"Returns current auto top-up configuration. Requires Bearer token.","operationId":"get_auto_topup_v1_billing_auto_topup_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"tags":["Billing"],"summary":"Configure auto top-up","description":"Enable/disable auto top-up with a threshold and pack. Requires Bearer token.","operationId":"set_auto_topup_v1_billing_auto_topup_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutoTopupRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/billing/crypto-checkout":{"post":{"tags":["Billing"],"summary":"Create USDC payment invoice","description":"Creates a NOWPayments invoice to pay with USDC on Base L2. Lower fees than card (0.5% vs 2.9%).","operationId":"crypto_checkout_v1_billing_crypto_checkout_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CryptoCheckoutRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/webhooks/config":{"get":{"tags":["Webhooks"],"summary":"Get webhook configuration","operationId":"get_webhook_config_v1_webhooks_config_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"tags":["Webhooks"],"summary":"Configure webhook URL","description":"Set a webhook URL to receive orchestration results. Returns a signing secret.","operationId":"configure_webhook_v1_webhooks_config_put","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookConfigRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookConfigResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["Webhooks"],"summary":"Remove webhook configuration","operationId":"delete_webhook_v1_webhooks_config_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/webhooks/test":{"post":{"tags":["Webhooks"],"summary":"Send a test webhook","operationId":"test_webhook_v1_webhooks_test_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/batch":{"post":{"tags":["Batch"],"summary":"Submit batch of prompts","description":"Submit 1-20 prompts for async processing. Poll status via GET /v1/batch/{batch_id}.","operationId":"create_batch_v1_batch_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/batch/{batch_id}":{"get":{"tags":["Batch"],"summary":"Check batch status","description":"Poll for batch processing results. Requires the same API key used to create the batch.","operationId":"get_batch_status_v1_batch__batch_id__get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"batch_id","in":"path","required":true,"schema":{"type":"string","title":"Batch Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AggregateRanking":{"properties":{"model":{"type":"string","title":"Model","description":"Model whose response was ranked"},"average_rank":{"type":"number","title":"Average Rank","description":"Mean position across peer judges (1 = best)"},"stddev":{"type":"number","title":"Stddev","description":"Standard deviation of peer-rank positions (0 if only one vote)","default":0.0},"votes":{"type":"integer","title":"Votes","description":"Number of valid peer ballots that ranked this response"}},"type":"object","required":["model","average_rank","votes"],"title":"AggregateRanking"},"ApiKeyResponse":{"properties":{"api_key":{"type":"string","title":"Api Key","description":"New API key — save it, shown only once"}},"type":"object","required":["api_key"],"title":"ApiKeyResponse"},"AutoTopupRequest":{"properties":{"enabled":{"type":"boolean","title":"Enabled","description":"Enable or disable auto top-up"},"threshold":{"type":"number","title":"Threshold","description":"Trigger top-up when balance drops below this","default":5.0},"pack_id":{"type":"string","title":"Pack Id","description":"Which credit pack to auto-buy","default":"topup_50"}},"type":"object","required":["enabled"],"title":"AutoTopupRequest"},"BatchItem":{"properties":{"prompt":{"type":"string","maxLength":50000,"minLength":1,"title":"Prompt"},"mode":{"type":"string","pattern":"^(fast|balanced|deep)$","title":"Mode","default":"balanced"},"domain":{"type":"string","title":"Domain","default":"auto"},"language":{"type":"string","title":"Language","default":"auto"},"max_tokens":{"anyOf":[{"type":"integer","minimum":100.0},{"type":"null"}],"title":"Max Tokens"}},"type":"object","required":["prompt"],"title":"BatchItem"},"BatchRequest":{"properties":{"items":{"items":{"$ref":"#/components/schemas/BatchItem"},"type":"array","maxItems":20,"minItems":1,"title":"Items","description":"1-20 prompts to process"}},"type":"object","required":["items"],"title":"BatchRequest"},"BatchResponse":{"properties":{"batch_id":{"type":"string","title":"Batch Id"},"total_items":{"type":"integer","title":"Total Items"},"total_credits_required":{"type":"number","title":"Total Credits Required"},"status":{"type":"string","title":"Status","default":"processing"},"status_url":{"type":"string","title":"Status Url"}},"type":"object","required":["batch_id","total_items","total_credits_required","status_url"],"title":"BatchResponse"},"ChatCompletionChoice":{"properties":{"index":{"type":"integer","title":"Index"},"message":{"$ref":"#/components/schemas/ChatMessage"},"finish_reason":{"type":"string","title":"Finish Reason"}},"type":"object","required":["index","message","finish_reason"],"title":"ChatCompletionChoice"},"ChatCompletionRequest":{"properties":{"model":{"type":"string","title":"Model","description":"Model name (consensus-fast, consensus-balanced, consensus-deep)","default":"consensus-balanced"},"messages":{"items":{"$ref":"#/components/schemas/ChatMessage"},"type":"array","title":"Messages","description":"List of messages in the conversation"},"stream":{"type":"boolean","title":"Stream","description":"Whether to stream the response via SSE","default":false},"max_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Tokens","description":"Maximum tokens in the response"},"temperature":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Temperature","description":"Accepted for compatibility, ignored"},"top_p":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top P","description":"Accepted for compatibility, ignored"},"n":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"N","description":"Accepted for compatibility, only n=1 supported","default":1},"stop":{"anyOf":[{},{"type":"null"}],"title":"Stop","description":"Accepted for compatibility, ignored"},"presence_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Presence Penalty","description":"Accepted for compatibility, ignored"},"frequency_penalty":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Frequency Penalty","description":"Accepted for compatibility, ignored"},"user":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User","description":"Accepted for compatibility, ignored"}},"type":"object","required":["messages"],"title":"ChatCompletionRequest"},"ChatCompletionResponse":{"properties":{"id":{"type":"string","title":"Id"},"object":{"type":"string","title":"Object","default":"chat.completion"},"created":{"type":"integer","title":"Created"},"model":{"type":"string","title":"Model"},"choices":{"items":{"$ref":"#/components/schemas/ChatCompletionChoice"},"type":"array","title":"Choices"},"usage":{"$ref":"#/components/schemas/ChatCompletionUsage"}},"type":"object","required":["id","created","model","choices","usage"],"title":"ChatCompletionResponse"},"ChatCompletionUsage":{"properties":{"prompt_tokens":{"type":"integer","title":"Prompt Tokens"},"completion_tokens":{"type":"integer","title":"Completion Tokens"},"total_tokens":{"type":"integer","title":"Total Tokens"}},"type":"object","required":["prompt_tokens","completion_tokens","total_tokens"],"title":"ChatCompletionUsage"},"ChatMessage":{"properties":{"role":{"type":"string","title":"Role","description":"The role: system, user, or assistant"},"content":{"type":"string","title":"Content","description":"The message content"}},"type":"object","required":["role","content"],"title":"ChatMessage"},"CheckoutRequest":{"properties":{"pack_id":{"type":"string","title":"Pack Id","description":"Credit pack: starter, pro, business, topup_10, topup_50"}},"type":"object","required":["pack_id"],"title":"CheckoutRequest"},"CheckoutResponse":{"properties":{"checkout_url":{"type":"string","title":"Checkout Url"},"session_id":{"type":"string","title":"Session Id"},"pack":{"additionalProperties":true,"type":"object","title":"Pack"}},"type":"object","required":["checkout_url","session_id","pack"],"title":"CheckoutResponse"},"ConversationDetailResponse":{"properties":{"conversation":{"$ref":"#/components/schemas/ConversationSummary"},"messages":{"items":{"$ref":"#/components/schemas/ConversationMessageResponse"},"type":"array","title":"Messages"}},"type":"object","required":["conversation","messages"],"title":"ConversationDetailResponse"},"ConversationMessageResponse":{"properties":{"message_index":{"type":"integer","title":"Message Index"},"turn_index":{"type":"integer","title":"Turn Index"},"role":{"type":"string","title":"Role"},"content":{"type":"string","title":"Content"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata"},"request_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Request Id"},"tokens_total":{"type":"integer","title":"Tokens Total","default":0},"quality_score":{"type":"number","title":"Quality Score","default":0.0},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"}},"type":"object","required":["message_index","turn_index","role","content","created_at"],"title":"ConversationMessageResponse"},"ConversationSummary":{"properties":{"id":{"type":"string","title":"Id"},"title":{"type":"string","title":"Title"},"title_generated":{"type":"boolean","title":"Title Generated"},"mode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Mode"},"domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Domain"},"message_count":{"type":"integer","title":"Message Count"},"total_tokens":{"type":"integer","title":"Total Tokens"},"total_credits":{"type":"number","title":"Total Credits"},"pinned":{"type":"boolean","title":"Pinned"},"archived":{"type":"boolean","title":"Archived"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"}},"type":"object","required":["id","title","title_generated","mode","domain","message_count","total_tokens","total_credits","pinned","archived","created_at","updated_at"],"title":"ConversationSummary"},"ConversationsListResponse":{"properties":{"items":{"items":{"$ref":"#/components/schemas/ConversationSummary"},"type":"array","title":"Items"},"next_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Cursor"}},"type":"object","required":["items"],"title":"ConversationsListResponse"},"CryptoCheckoutRequest":{"properties":{"pack_id":{"type":"string","title":"Pack Id","description":"Crypto pack: crypto_50, crypto_100, crypto_200, crypto_500"}},"type":"object","required":["pack_id"],"title":"CryptoCheckoutRequest"},"DeleteAllRequest":{"properties":{"confirm":{"type":"boolean","title":"Confirm","description":"Must be explicitly true to perform bulk delete"}},"type":"object","required":["confirm"],"title":"DeleteAllRequest"},"DeleteAllResponse":{"properties":{"deleted":{"type":"integer","title":"Deleted"}},"type":"object","required":["deleted"],"title":"DeleteAllResponse"},"Domain":{"type":"string","enum":["auto","general","legal","medical","financial","technical","creative"],"title":"Domain"},"ErrorResponse":{"properties":{"error":{"type":"string","title":"Error"},"code":{"type":"string","title":"Code"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["error","code"],"title":"ErrorResponse"},"ExportJobStatus":{"properties":{"job_id":{"type":"string","title":"Job Id"},"status":{"type":"string","title":"Status"},"format":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Format"},"include_archived":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Include Archived"},"total_conversations":{"type":"integer","title":"Total Conversations","default":0},"processed":{"type":"integer","title":"Processed","default":0},"progress":{"type":"integer","title":"Progress","default":0},"file_size_bytes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"File Size Bytes"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"started_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Started At"},"completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed At"},"expires_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expires At"},"downloaded_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Downloaded At"},"download_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Download Url"}},"type":"object","required":["job_id","status"],"title":"ExportJobStatus"},"ExportRequest":{"properties":{"format":{"type":"string","title":"Format","description":"json | markdown | both","default":"both"},"include_archived":{"type":"boolean","title":"Include Archived","default":true}},"type":"object","title":"ExportRequest"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HealthResponse":{"properties":{"status":{"type":"string","title":"Status","default":"ok"},"version":{"type":"string","title":"Version","default":""},"models":{"items":{"$ref":"#/components/schemas/ModelStatus"},"type":"array","title":"Models","default":[]},"uptime_seconds":{"type":"number","title":"Uptime Seconds","default":0}},"type":"object","title":"HealthResponse"},"LoginRequest":{"properties":{"email":{"type":"string","title":"Email","description":"Email address"},"password":{"type":"string","title":"Password","description":"Password"}},"type":"object","required":["email","password"],"title":"LoginRequest"},"LoginResponse":{"properties":{"user_id":{"type":"integer","title":"User Id"},"email":{"type":"string","title":"Email"},"name":{"type":"string","title":"Name"},"plan":{"type":"string","title":"Plan"},"credit_balance":{"type":"number","title":"Credit Balance"},"token":{"type":"string","title":"Token"}},"type":"object","required":["user_id","email","name","plan","credit_balance","token"],"title":"LoginResponse"},"ModelContribution":{"properties":{"model":{"type":"string","title":"Model"},"role":{"type":"string","title":"Role","default":""},"summary":{"type":"string","title":"Summary","default":""},"full_response":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Response","description":"Full untruncated model response (only when include_full_contributions=true)"}},"type":"object","required":["model"],"title":"ModelContribution"},"ModelStatus":{"properties":{"name":{"type":"string","title":"Name"},"available":{"type":"boolean","title":"Available"},"latency_ms":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Latency Ms"}},"type":"object","required":["name","available"],"title":"ModelStatus"},"OrchestrationMode":{"type":"string","enum":["fast","balanced","deep"],"title":"OrchestrationMode"},"OrchestrationRequest":{"properties":{"prompt":{"type":"string","maxLength":50000,"minLength":1,"title":"Prompt","description":"La consulta o problema a resolver"},"mode":{"$ref":"#/components/schemas/OrchestrationMode","description":"Modo de orquestación: fast (~10s), balanced (~25s), deep (~90s, 5 models)","default":"balanced"},"models":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Models","description":"Modelos específicos a usar. null = selección automática según modo"},"domain":{"$ref":"#/components/schemas/Domain","description":"Dominio del problema. AUTO detecta automáticamente","default":"auto"},"stream":{"type":"boolean","title":"Stream","description":"Respuesta en streaming via SSE (Server-Sent Events)","default":false},"max_tokens":{"anyOf":[{"type":"integer","minimum":100.0},{"type":"null"}],"title":"Max Tokens","description":"Límite de tokens en la respuesta final. Si es null, no se aplica límite y la respuesta será tan larga como necesite. El sistema dejará que los modelos generen respuestas completas."},"language":{"type":"string","title":"Language","description":"Idioma de respuesta preferido (auto, es, en, fr, etc.)","default":"auto"},"context":{"anyOf":[{"type":"string","maxLength":20000},{"type":"null"}],"title":"Context","description":"Contexto adicional para la consulta (documentos, datos previos)"},"conversation_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Conversation Id","description":"ID de conversación para mantener contexto entre mensajes. Si es null, se crea una nueva conversación."},"include_full_contributions":{"type":"boolean","title":"Include Full Contributions","description":"If true, includes the full untruncated response from each model in contributions (useful for benchmarks, audit trails, EU AI Act Art. 13 compliance)","default":false}},"type":"object","required":["prompt"],"title":"OrchestrationRequest","description":"Request para el endpoint principal /v1/orchestrate","examples":[{"domain":"legal","language":"es","mode":"balanced","prompt":"¿Cuáles son las implicaciones legales del uso de IA generativa en contratos?"},{"domain":"technical","mode":"deep","prompt":"Compare microservices vs monolith for a fintech startup with 50k users"}]},"OrchestrationResponse":{"properties":{"id":{"type":"string","title":"Id","description":"ID único de esta orquestación"},"answer":{"type":"string","title":"Answer","description":"Respuesta consensuada final"},"metadata":{"$ref":"#/components/schemas/ProcessMetrics","description":"Métricas del proceso"},"cached":{"type":"boolean","title":"Cached","description":"Si la respuesta viene de cache","default":false},"conversation_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Conversation Id","description":"ID de conversación para seguimiento"}},"type":"object","required":["id","answer","metadata"],"title":"OrchestrationResponse","description":"Response del endpoint principal","examples":[{"answer":"Las implicaciones legales del uso de IA generativa en contratos incluyen...","cached":false,"id":"orch_abc123def456","metadata":{"contributions":[{"model":"gpt-4o","role":"Analyzer","summary":"Análisis del marco regulatorio"},{"model":"claude-sonnet-4.6","role":"Critic","summary":"Evaluación de riesgos y matices"},{"model":"gemini-2.5-pro","role":"Synthesizer","summary":"Integración y síntesis final"}],"domain_detected":"legal","iterations":2,"mode":"balanced","models_used":["gpt-4o","claude-sonnet-4.6","gemini-2.5-pro"],"processing_time_ms":18420,"quality_score":0.87,"token_usage":{"estimated_cost_usd":0.12,"input_tokens":4200,"output_tokens":3100,"total_tokens":7300}}}]},"PatchConversationRequest":{"properties":{"title":{"anyOf":[{"type":"string","maxLength":80},{"type":"null"}],"title":"Title"},"pinned":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Pinned"},"archived":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Archived"}},"type":"object","title":"PatchConversationRequest"},"PeerEvaluation":{"properties":{"judge_model":{"type":"string","title":"Judge Model","description":"Model that produced this peer evaluation"},"raw_evaluation":{"type":"string","title":"Raw Evaluation","description":"Full raw judge output (JSON or legacy FINAL RANKING text). Labels in this text use the per-judge randomized space — decode via judge_label_to_model, NOT the top-level label_to_model."},"parsed_ranking":{"items":{"type":"string"},"type":"array","title":"Parsed Ranking","description":"Ordered global anonymous labels best→worst (empty if ballot rejected). Use top-level label_to_model to decode."},"rationales":{"additionalProperties":{"type":"string"},"type":"object","title":"Rationales","description":"One-sentence rationale per global label, when judge returned the JSON contract"},"parse_error":{"type":"string","title":"Parse Error","description":"Non-empty if the ballot was rejected (incomplete, duplicated, unparseable). Empty = valid.","default":""},"judge_label_to_model":{"additionalProperties":{"type":"string"},"type":"object","title":"Judge Label To Model","description":"Per-judge label → model mapping. Use this (not the top-level mapping) to decode raw_evaluation."}},"type":"object","required":["judge_model","raw_evaluation"],"title":"PeerEvaluation"},"PeerReview":{"properties":{"label_to_model":{"additionalProperties":{"type":"string"},"type":"object","title":"Label To Model","description":"Global label → model mapping for parsed_ranking and rationales. NOT for raw_evaluation (use PeerEvaluation.judge_label_to_model for that)."},"aggregate_rankings":{"items":{"$ref":"#/components/schemas/AggregateRanking"},"type":"array","title":"Aggregate Rankings","description":"Cross-model leaderboard, sorted best to worst"},"evaluations":{"items":{"$ref":"#/components/schemas/PeerEvaluation"},"type":"array","title":"Evaluations","description":"Per-judge raw evaluation with parsed ranking"}},"type":"object","title":"PeerReview"},"ProcessMetrics":{"properties":{"mode":{"type":"string","title":"Mode"},"models_used":{"items":{"type":"string"},"type":"array","title":"Models Used"},"iterations":{"type":"integer","title":"Iterations","default":0},"quality_score":{"type":"number","title":"Quality Score","default":0.0},"domain_detected":{"type":"string","title":"Domain Detected","default":"general"},"processing_time_ms":{"type":"integer","title":"Processing Time Ms","default":0},"token_usage":{"$ref":"#/components/schemas/TokenUsage","default":{"input_tokens":0,"output_tokens":0,"total_tokens":0,"estimated_cost_usd":0.0}},"contributions":{"items":{"$ref":"#/components/schemas/ModelContribution"},"type":"array","title":"Contributions","default":[]},"peer_review":{"anyOf":[{"$ref":"#/components/schemas/PeerReview"},{"type":"null"}],"description":"Anonymous peer-review stage: each model ranks the others' anonymized responses"}},"type":"object","required":["mode","models_used"],"title":"ProcessMetrics"},"RegisterRequest":{"properties":{"email":{"type":"string","maxLength":255,"minLength":5,"title":"Email","description":"Email address"},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password","description":"Password (min 8 chars)"},"name":{"type":"string","maxLength":255,"title":"Name","description":"Display name (optional)","default":""},"promo_code":{"type":"string","maxLength":50,"title":"Promo Code","description":"Optional promo code for bonus credits","default":""}},"type":"object","required":["email","password"],"title":"RegisterRequest"},"RegisterResponse":{"properties":{"user_id":{"type":"integer","title":"User Id"},"email":{"type":"string","title":"Email"},"api_key":{"type":"string","title":"Api Key","description":"Your API key — save it, shown only once"},"plan":{"type":"string","title":"Plan"},"credit_balance":{"type":"number","title":"Credit Balance"},"token":{"type":"string","title":"Token","description":"JWT token for dashboard access"},"promo_applied":{"type":"string","title":"Promo Applied","description":"Promo code applied, if any","default":""}},"type":"object","required":["user_id","email","api_key","plan","credit_balance","token"],"title":"RegisterResponse"},"RetentionResponse":{"properties":{"retention_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Retention Days","description":"None = permanent retention"},"total_conversations":{"type":"integer","title":"Total Conversations","default":0},"total_messages":{"type":"integer","title":"Total Messages","default":0},"total_tokens":{"type":"integer","title":"Total Tokens","default":0},"total_bytes":{"type":"integer","title":"Total Bytes","default":0},"will_delete_count":{"type":"integer","title":"Will Delete Count","default":0}},"type":"object","title":"RetentionResponse"},"RetentionUpdateRequest":{"properties":{"retention_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Retention Days","description":"One of 7, 30, 90 or null"}},"type":"object","title":"RetentionUpdateRequest"},"SpendLimitRequest":{"properties":{"daily_limit":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Daily Limit","description":"Daily spend limit in credits. null = no limit."}},"type":"object","title":"SpendLimitRequest"},"TokenUsage":{"properties":{"input_tokens":{"type":"integer","title":"Input Tokens","default":0},"output_tokens":{"type":"integer","title":"Output Tokens","default":0},"total_tokens":{"type":"integer","title":"Total Tokens","default":0},"estimated_cost_usd":{"type":"number","title":"Estimated Cost Usd","default":0.0}},"type":"object","title":"TokenUsage"},"UsageResponse":{"properties":{"api_key_prefix":{"type":"string","title":"Api Key Prefix"},"plan":{"type":"string","title":"Plan"},"period":{"type":"string","title":"Period"},"requests_used":{"type":"integer","title":"Requests Used","default":0},"requests_limit":{"type":"integer","title":"Requests Limit","default":0},"tokens_used":{"type":"integer","title":"Tokens Used","default":0},"estimated_cost_usd":{"type":"number","title":"Estimated Cost Usd","default":0.0}},"type":"object","required":["api_key_prefix","plan","period"],"title":"UsageResponse"},"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"},"WebhookConfigRequest":{"properties":{"url":{"type":"string","maxLength":500,"title":"Url","description":"HTTPS URL to receive webhooks"}},"type":"object","required":["url"],"title":"WebhookConfigRequest"},"WebhookConfigResponse":{"properties":{"url":{"type":"string","title":"Url"},"secret":{"type":"string","title":"Secret","description":"HMAC secret for signature verification"},"active":{"type":"boolean","title":"Active"}},"type":"object","required":["url","secret","active"],"title":"WebhookConfigResponse"}},"securitySchemes":{"APIKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key"}}}}