{"record":{"id":"02a074d49e101ae2","repo":"langgenius/dify","slug":"provider-quota-exceeded-02a074","errorCode":"provider_quota_exceeded","errorMessage":"Your quota for Dify Hosted Model Provider has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials.","messagePattern":"Your quota for Dify Hosted Model Provider has been exhausted\\. Please go to Settings -> Model Provider to complete your own provider credentials\\.","errorType":"error_code","errorClass":"ProviderQuotaExceededError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/datasets/datasets_document.py","lineNumber":571,"sourceCode":"\n        knowledge_config = KnowledgeConfig.model_validate(console_ns.payload or {})\n\n        if not dataset.indexing_technique and not knowledge_config.indexing_technique:\n            raise ValueError(\"indexing_technique is required.\")\n\n        # validate args\n        DocumentService.document_create_args_validate(knowledge_config)\n\n        try:\n            documents, batch = DocumentService.save_document_with_dataset_id(\n                dataset, knowledge_config, current_user, session=session\n            )\n            dataset = DatasetService.get_dataset(dataset_id_str, session)\n\n        except ProviderTokenNotInitError as ex:\n            raise ProviderNotInitializeError(ex.description)\n        except QuotaExceededError:\n            raise ProviderQuotaExceededError()\n        except ModelCurrentlyNotSupportError:\n            raise ProviderModelCurrentlyNotSupportError()\n\n        return dump_response(\n            DatasetAndDocumentResponse,\n            {\"dataset\": dataset, \"documents\": document_responses(documents, session=session), \"batch\": batch},\n        )\n\n    @setup_required\n    @login_required\n    @account_initialization_required\n    @console_ns.response(204, \"Documents deleted successfully\")\n    @with_current_user\n    @with_current_tenant_id\n    @rbac_permission_required(RBACResourceScope.DATASET, RBACPermission.DATASET_EDIT)\n    @with_session\n    def delete(\n        self,","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/datasets_document.py#L553-L589","documentation":"ProviderQuotaExceededError (HTTP 400, code provider_quota_exceeded) raised in DatasetDocumentListApi.post when the underlying save/indexing call throws QuotaExceededError — the Dify-hosted (trial) model provider's usage quota has been exhausted. The default message instructs the user to supply their own provider credentials.","triggerScenarios":"POST /console/api/datasets/<dataset_id>/documents (typically high_quality indexing) using the Dify-hosted trial OpenAI provider after the tenant's free token quota ran out. The embedding/LLM call during indexing is rejected upstream as over-quota and re-raised here.","commonSituations":"Cloud/SaaS trial tenant relying on Dify's hosted OpenAI hit the free-tier cap; a large document batch consumed the remaining quota mid-index; long-time tenant that never switched to its own API key.","solutions":["Add your own provider credentials in Settings -> Model Provider (OpenAI/Anthropic/etc.) and switch the dataset's embedding model to use them.","Reduce the indexing load (smaller documents, fewer segments) to stay within the hosted quota if you must use it.","Contact Dify sales/support to increase the hosted quota if applicable."],"exampleFix":"// before — hosted trial quota exhausted\nPOST /console/api/datasets/<id>/documents  →  400 provider_quota_exceeded\n\n// after — use own provider\n// Settings → Model Provider → add own OpenAI key, select as embedding model provider\nPOST /console/api/datasets/<id>/documents  →  200","handlingStrategy":"try-catch","validationCode":"# No code-side quota check is authoritative — the provider enforces it.\n# Best pre-check: track local usage against a budget below the hosted cap.\ndef likely_within_quota(estimated_tokens: int, used: int, cap: int) -> bool:\n    return used + estimated_tokens < cap\n\nif not likely_within_quota(est_tokens, tenant_used, hosted_cap):\n    return error(\"Switch to your own provider credentials to avoid quota exhaustion.\")","typeGuard":"def has_own_provider_credentials(tenant_id: str) -> bool:\n    \"\"\"True when the tenant is NOT solely dependent on the hosted trial.\"\"\"\n    # pseudocode: inspect provider rows for a non-hosted, valid-credential provider\n    return any(not p.is_hosted_trial and p.has_credentials for p in list_providers(tenant_id))","tryCatchPattern":"from core.errors.error import QuotaExceededError\nfrom controllers.console.app.error import ProviderQuotaExceededError\n\ntry:\n    documents, batch = DocumentService.save_document_with_dataset_id(...)\nexcept QuotaExceededError:\n    raise ProviderQuotaExceededError()","preventionTips":["Move production tenants off the Dify-hosted trial onto their own provider credentials before quota matters.","Show remaining hosted quota in the UI so users see exhaustion coming.","Split very large batches into smaller chunks to reduce the blast radius of a mid-index quota failure."],"tags":["quota","model-provider","datasets","rag","billing"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}