{"openapi":"3.1.0","info":{"title":"Payjingo AI API","version":"1.0.0","description":"API سازگار با OpenAI برای دسترسی به مدل های هوش مصنوعی با پرداخت تومانی. در حال حاضر فقط chat/completions در دسترس است. Base URL: https://payjingo.com/api/v1","contact":{"url":"https://payjingo.com/ai-api","email":"support@payjingo.com"}},"servers":[{"url":"https://payjingo.com/api/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer sk-payjingo-..."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"x-api-key","description":"برای سازگاری با Anthropic SDK"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["PJ_UNAUTHORIZED","PJ_KEY_REVOKED","PJ_KEY_EXPIRED","PJ_INSUFFICIENT_BALANCE","PJ_BUDGET_EXCEEDED","PJ_MODEL_NOT_ALLOWED","PJ_MODEL_NOT_FOUND","PJ_INVALID_REQUEST","PJ_CONTEXT_TOO_LARGE","PJ_RATE_LIMITED","PJ_UPSTREAM_RATE_LIMITED","PJ_UPSTREAM_TIMEOUT","PJ_UPSTREAM_UNAVAILABLE","PJ_UPSTREAM_ERROR","PJ_INTERNAL_ERROR"]},"message":{"type":"string"},"type":{"type":"string"},"request_id":{"type":"string"}}}}},"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"]},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}]},"name":{"type":"string"},"tool_calls":{"type":"array","items":{"type":"object"}},"tool_call_id":{"type":"string"}}},"Usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"},"prompt_tokens_details":{"type":"object","properties":{"cached_tokens":{"type":"integer"}}},"completion_tokens_details":{"type":"object","properties":{"reasoning_tokens":{"type":"integer"}}}}},"Model":{"type":"object","properties":{"id":{"type":"string","example":"A/claude-sonnet-5"},"object":{"type":"string","enum":["model"]},"created":{"type":"integer"},"owned_by":{"type":"string"},"name":{"type":"string"},"vendor":{"type":"string"},"context_window":{"type":"integer"},"max_output_tokens":{"type":"integer"},"modalities":{"type":"object","properties":{"input":{"type":"array","items":{"type":"string"}},"output":{"type":"array","items":{"type":"string"}}}},"capabilities":{"type":"array","items":{"type":"string"}},"endpoints":{"type":"array","items":{"type":"string"}},"pricing":{"type":"object","description":"قیمت به تومان (IRT). برای مدل های متنی به ازای یک میلیون توکن.","properties":{"unit":{"type":"string"},"currency":{"type":"string"},"input":{"type":"integer"},"output":{"type":"integer"},"cache_read":{"type":"integer"},"cache_write":{"type":"integer","nullable":true}}}}}},"responses":{"Error":{"description":"خطا","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/chat/completions":{"post":{"summary":"Chat Completions (سازگار با OpenAI)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","example":"A/claude-sonnet-5"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/Message"}},"stream":{"type":"boolean","default":false},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}}},"temperature":{"type":"number"},"top_p":{"type":"number"},"max_tokens":{"type":"integer"},"max_completion_tokens":{"type":"integer"},"tools":{"type":"array","items":{"type":"object"}},"tool_choice":{},"response_format":{"type":"object"},"reasoning_effort":{"type":"string","enum":["low","medium","high"]},"user":{"type":"string"}}}}}},"responses":{"200":{"description":"پاسخ (JSON یا SSE در حالت stream). usage در chunk آخر برمی گردد."},"400":{"$ref":"#/components/responses/Error"},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"403":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}}},"x-error-codes":[{"code":"PJ_UNAUTHORIZED","status":401,"description":"کلید API نامعتبر یا ارسال نشده"},{"code":"PJ_KEY_REVOKED","status":401,"description":"کلید لغو شده است"},{"code":"PJ_KEY_EXPIRED","status":401,"description":"کلید منقضی شده است"},{"code":"PJ_INSUFFICIENT_BALANCE","status":402,"description":"موجودی کیف پول کافی نیست"},{"code":"PJ_BUDGET_EXCEEDED","status":402,"description":"بودجه ماهانه کلید تمام شده"},{"code":"PJ_MODEL_NOT_ALLOWED","status":403,"description":"این کلید به مدل درخواستی دسترسی ندارد"},{"code":"PJ_MODEL_NOT_FOUND","status":404,"description":"مدل وجود ندارد یا غیرفعال است"},{"code":"PJ_INVALID_REQUEST","status":400,"description":"بدنه درخواست نامعتبر است"},{"code":"PJ_CONTEXT_TOO_LARGE","status":400,"description":"طول ورودی از پنجره مدل بیشتر است"},{"code":"PJ_RATE_LIMITED","status":429,"description":"محدودیت درخواست/توکن در دقیقه"},{"code":"PJ_UPSTREAM_RATE_LIMITED","status":429,"description":"سرویس دهنده بالادستی موقتاً محدود شده است"},{"code":"PJ_UPSTREAM_TIMEOUT","status":504,"description":"مدل در زمان مجاز پاسخ نداد (قابل تلاش مجدد)"},{"code":"PJ_UPSTREAM_UNAVAILABLE","status":503,"description":"مدل موقتاً در دسترس نیست (قابل تلاش مجدد)"},{"code":"PJ_UPSTREAM_ERROR","status":502,"description":"خطای بالادست"},{"code":"PJ_INTERNAL_ERROR","status":500,"description":"خطای داخلی"}]}