#Empty response body in some request

10 messages · Page 1 of 1 (latest)

calm hollow
#

I am using deepseek/deepseek-chat-v3.1 but I have been having issues, not on all calls, but I get a decent amount of errors where the response status is 200, content-type= application/json but the content is only empty lines, probably live check?

Is there any reason why I would get such behaviour? Am I requesting too much the api ? I am using an async semaphore with 10 concurrent calls.

I notice an earlier discussion with a similar issue: https://discord.com/channels/1091220969173028894/1388364774521307217

But in my case it is not on every request, so I am not sure if I actually pay in cases I don't get any output.

If some has any idea, I would gladly have some help or guidance in solving this.

real sunBOT
#

I'm an AI assistant - my answers may be incorrect and I cannot see screenshots. Please verify information with the OpenRouter docs.

To help debug your issue with deepseek/deepseek-chat-v3.1, I need a bit more information:

  1. Can you share the exact response body (even if it's empty) and headers you receive when this happens?
  2. Are you setting any custom request parameters (like streaming, timeout, or filters for provider routing)?
  3. Is your code using retries or handling rate limits, and if so, how?

These details will help determine if your concurrency or request pattern is related, or if this is an upstream provider issue. OpenRouter routes requests to multiple providers and will "recover by routing to another healthy provider, if your request filters allow it" (Provider Routing Docs). Knowing your setup will help mods or support pinpoint the cause.

Also, for billing concerns (whether you are charged for empty responses), it's best to ask mods directly or check the OpenRouter billing FAQ, as I don't have specific documentation for that scenario.

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding.

The author you are looking for could not be found.

The author you are looking for could not be found.

calm hollow
#
                    rr = await self._client.with_raw_response.chat.completions.create(
                            messages=messages,
                            **kwargs,
                        )
                    h = {k.lower(): v for k, v in rr.http_response.headers.items()}
                    ct = rr.http_response.headers.get("content-type")
                    body = await rr.http_response.aread()
                    head = body[:500]
                    try:
                        head_txt = head.decode("utf-8", "replace")
                    except Exception:
                        head_txt = repr(head)

                    cls = "ok"
                    if is_ws_only(body):
                        cls = "whitespace_only"
                    elif body.lstrip()[:1] not in (b"{", b"["):
                        cls = "non_json"
                    meta = dict(
                        http_version=getattr(rr.http_response, "http_version", None),
                        status=rr.http_response.status_code,
                        transfer_encoding=h.get("transfer-encoding"),
                        content_length=h.get("content-length"),
                        connection=h.get("connection"),
                        content_encoding=h.get("content-encoding"),
                        request_id=h.get("openrouter-request-id") or h.get("x-request-id"),
                        provider=h.get("openrouter-provider"),
                        body_len=len(body),
                        prefix=head,
                        cls=cls,
                    )
                    logger.error(
                        f"Non-JSON/network error (retry {attempt + 1}/{self.max_retries}). meta={meta} body[:500]={head_txt}"
                    )
#

Will get me:

[2025-09-07 06:47:33,957][aclm.utils.openai_client][ERROR] Non-JSON/network error (retry 1/10000000). meta={'http_version': 'HTTP/1.1', 'status': 200, 'transfer_encoding': 'chunked', 'content_length': None, 'connection': 'keep-alive', 'content_encoding': 'gzip', 'request_id': None, 'provider': None, 'body_len': 5368, 'prefix': b'\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n         \n\n    ', 'cls': 'whitespace_only'} body[:500]=

real sunBOT
#

Thank you for sharing your code and detailed context. Here’s a breakdown of what’s happening and some guidance on debugging:

What your code is doing:

  • You make async calls to the OpenRouter API using the OpenAI-compatible client.
  • You check the HTTP response status and headers, read the body, and classify the response as "ok", "whitespace_only", or "non_json" based on its content.

Issue:
You sometimes receive a 200 OK response with content-type: application/json, but the body is only whitespace or empty lines.


Insights & Next Steps

  1. Provider Failover Handling:
    OpenRouter "routes requests to the best providers" and “can recover by routing to another healthy provider, if your request filters allow it” (Provider Routing). However, if all eligible providers fail or respond with invalid data, you may get a 200 with no usable JSON content due to upstream issues.

  2. API Response Format:
    OpenRouter "normalizes requests and responses across providers for you," but there can still be occasional upstream anomalies (API Reference).

  3. Concurrency & Rate Limiting:
    You mention using up to 10 concurrent requests. OpenRouter does not document a hard concurrency limit, but excessive concurrent requests could cause rate limiting or inconsistent results from some providers, especially under heavy load (API Reference). You might want to experiment with lowering concurrency or adding retry logic with exponential backoff.

  4. Billing for Empty Responses:
    There is no specific documentation stating whether you are billed for empty/invalid outputs. For billing issues, it's best to contac...

#

...t the mods or support directly, or check the OpenRouter FAQ.


Recommended Debug Steps

  • Log and collect the request IDs (openrouter-request-id or x-request-id) for the empty responses. Share these with mods if you escalate.
  • Try reducing your concurrency to see if the issue frequency changes.
  • Ensure you have retry logic for network or invalid response errors.
  • Check if you are using any custom filters in your requests that could restrict provider fallback.

If you continue experiencing these issues, especially with specific request IDs or patterns, contact the mods through the Discord server with the details for further investigation.

References:

  • "When an error occurs in an upstream provider, we can recover by routing to another healthy provider, if your request filters allow it." Provider Routing
  • "OpenRouter normalizes requests and responses across providers for you." API Reference
  • Billing: OpenRouter FAQ

Let me know if you have additional headers or error samples—these are helpful for deeper debugging.

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding.

The author you are looking for could not be found.

The author you are looking for could not be found.

#

Thanks for sharing the error details. Based on your log, you are receiving a status 200 with a body that contains only whitespace or empty lines ('cls': 'whitespace_only'). This sometimes indicates an upstream provider issue or a transient network/proxy problem, especially since the response is not valid JSON and contains only empty chunks.

A few key points:

  • OpenRouter will attempt to "recover by routing to another healthy provider, if your request filters allow it" when an upstream provider fails, but this depends on your routing configuration. If your filters are strict or the issue is transient, some requests may still return incomplete or malformed responses. See: "When an error occurs in an upstream provider, we can recover by routing to another healthy provider, if your request filters allow it." Provider Routing Docs
  • If you are making many concurrent requests (10 at a time), you may be hitting upstream provider reliability issues or temporary bottlenecks. However, this log does not indicate classic rate limiting (which would usually show a 429 error).
  • OpenRouter normalizes responses across providers, but if an upstream provider returns an invalid body, you may still see these empty responses despite a 200 code. See: "OpenRouter normalizes requests and responses across providers for you." GLM 4.5 Air (free) API

Next steps:

  1. Try reducing concurrency (e.g., 3-5 requests at a time) to see if the error rate drops.
  2. Make sure your code is retrying requests that return non-JSON/invalid responses.
  3. If you have custom provider routing or filters, try removing them to allow fallback to other providers.
  4. If the problem persists, collect sample request ID...

GLM-4.5-Air is the lightweight variant of our latest flagship model family, also purpose-built for agent-centric applications. Run GLM 4.5 Air (free) with API

#

...s and contact the mods through the Discord server for deeper investigation.

For billing questions (whether you are charged for these responses), please check the OpenRouter FAQ or ask mods directly, as there is no public documentation for this specific scenario.

If you need more help, please provide:

  • The full raw response body and headers for a failed request (after decompressing if gzip)
  • Your provider routing/filter settings, if any
  • How frequently this occurs vs. successful calls

This will help mods or support trace the root cause.

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding.

The author you are looking for could not be found.

calm hollow
#

Are you setting any custom request parameters (like streaming, timeout, or filters for provider routing)?

I use reasoning as a extra_body argument:
"reasoning": {
"effort": "high",
"exclude": False,
"enabled": True,
}

calm hollow
#

The full header:

[2025-09-07 07:12:10,151][aclm.utils.openai_client][ERROR] Non-JSON/network error (retry 1/10000000). meta={'http_version': 'HTTP/1.1', 'headers': {'date': 'Sun, 07 Sep 2025 07:10:49 GMT', 'content-type': 'application/json', 'transfer-encoding': 'chunked', 'connection': 'keep-alive', 'content-encoding': 'gzip', 'access-control-allow-origin': '', 'vary': 'Accept-Encoding', 'permissions-policy': 'payment=(self "https://checkout.stripe.com" "https://connect-js.stripe.com" "https://js.stripe.com" "https://.js.stripe.com" "https://hooks.stripe.com")', 'referrer-policy': 'no-referrer, strict-origin-when-cross-origin', 'x-content-type-options': 'nosniff', 'server': 'cloudflare', 'cf-ray': '97b463716d27b932-AMS'}, 'status': 200, 'body_len': 2123, 'prefix': b'\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n ', 'cls': 'whitespace_only'} body[:500]=