Fosowl/agenticSeek · error · CloudflareError

Cloudflare protection encountered

Error message

Cloudflare protection encountered: {str(e)}

What it means

dsk_deepseek wraps the unofficial dsk (deepseek4free) API's CloudflareError and re-raises it with a uniform message. The free DeepSeek endpoint sits behind Cloudflare bot protection, and when the challenge/solve fails the library raises CloudflareError, which this wrapper re-throws verbatim with its original message. It signals that the request never reached the model because Cloudflare blocked or challenged the client.

Solutions

  1. Update the dsk package to the latest version (pip install -U dsk) since Cloudflare bypass logic breaks frequently
  2. Retry later or from a different/residential network — the block is often IP-based
  3. Switch to an official provider (e.g. litellm_fn or another backend in config.ini) instead of the free unofficial API
  4. Check your DSK_DEEPSEEK_API_KEY setup; re-authenticate if the token session expired

Example fix

// before
thought = provider.dsk_deepseek(history)
// after
try:
    thought = provider.dsk_deepseek(history)
except CloudflareError:
    thought = provider.litellm_fn(history)  # fallback to official gateway
Defensive patterns

Strategy: fallback

Validate before calling

import dsk  # ensure installed and reasonably current
assert provider.provider_key == 'dsk_deepseek' or True  # unofficial provider — expect instability

Type guard

def is_cloudflare_error(e: BaseException) -> bool:
    return isinstance(e, CloudflareError) or 'Cloudflare' in str(e)

Try / catch

try:
    thought = provider.dsk_deepseek(history)
except CloudflareError as e:
    logger.warning('Cloudflare block: %s', e)
    thought = fallback_provider(history)  # e.g. litellm_fn

Prevention

When it happens

Trigger: Calling LLMProvider.dsk_deepseek(history) when the dsk library's Cloudflare bypass (token solving / user-agent handling) fails during DeepSeekAPI init, create_chat_session, or chat_completion — e.g. Cloudflare rotated its challenge or flagged the client IP.

Common situations: Running from datacenter/VPN IPs that Cloudflare distrusts; outdated dsk package after Cloudflare changed its challenge; heavy request volume triggering bot scoring; missing or stale cf_clearance cookies.

Related errors


AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30). Data as JSON: /api/errors/6eaa050d41b8cc99. Report an issue: GitHub.

Appendix: source

Thrown at sources/llm_provider.py:502

            CloudflareError,
            APIError
        )
        thought = ""
        message = '\n---\n'.join([f"{msg['role']}: {msg['content']}" for msg in history])

        try:
            api = DeepSeekAPI(self.api_key)
            chat_id = api.create_chat_session()
            for chunk in api.chat_completion(chat_id, message):
                if chunk['type'] == 'text':
                    thought += chunk['content']
            return thought
        except AuthenticationError as e:
            raise AuthenticationError("Authentication failed. Please check your token.") from e
        except RateLimitError as e:
            raise RateLimitError("Rate limit exceeded. Please wait before making more requests.") from e
        except CloudflareError as e:
            raise CloudflareError(f"Cloudflare protection encountered: {str(e)}") from e
        except NetworkError as e:
            raise NetworkError("Network error occurred. Check your internet connection.") from e
        except APIError as e:
            raise APIError(f"API error occurred: {str(e)}") from e
        return None

    def litellm_fn(self, history, verbose=False):
        """
        Use LiteLLM AI gateway for completion.
        Routes to 100+ providers (OpenAI, Anthropic, Azure, Bedrock,
        Vertex AI, Groq, Together, Ollama, etc.) based on model prefix.
        See https://docs.litellm.ai/docs/providers
        """
        try:
            import litellm
        except ImportError as e:
            raise ImportError("litellm is not installed. Install with: pip install litellm") from e

View on GitHub (pinned to ae57a23577)