Can you request additional log information?

I’m running an experiment on translation and for one particular translation pair, the API fails me to provide an output under the condition I provide. To be specific, if I use streaming, I will not get a response (the connection is closed) and there will be no response logged on OpenAI’s logs.

If I use request-response, I get a Gateway Timeout 504 error and no response but a response is logged in the OpenAI logs. So I just copied the response from those logs for my project. However, I noticed that it only logs the creation date of the log, not the timestamp when the response was generated. Is it possible to request this information from OpenAI somehow?

Is perhaps your translation too long or too complex to justify the timeout?

You can have a look at your responses object “raw” taking a look at its json:

print(response.to_json())

Or taking the response id in the logs, and calling the API to retrieve more details like error (stop reason) and incomplete details:

Example
from openai import OpenAI
client = OpenAI()

response = client.responses.retrieve("resp_123")
print(response)
{
  "id": "resp_67cb71b351908190a308f3859487620d06981a8637e6bc44",
  "object": "response",
  "created_at": 1741386163,
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "gpt-4o-2024-08-06",
  "output": [
    {
      "type": "message",
      "id": "msg_67cb71b3c2b0819084d481baaaf148f206981a8637e6bc44",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Silent circuits hum,  \nThoughts emerge in data streams—  \nDigital dawn breaks.",
          "annotations": []
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 32,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 18,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 50
  },
  "user": null,
  "metadata": {}
}

I don’t get a response object. It’s an error, there is no response. The last thing that is logged is HTML code, if you open it in browser, you get a page that tells you to visit Cloudflare, explains it was a Gateway 504 timeout and that you can try again in few minutes. However, a response DOES exist because I can see it in full length logged on OpenAI Platform logs. I just never got it in time.

Note: The reason why this error was triggered was because it probably took too long for it send the response back in time. If you use streaming, the error can still occur but you will not get charged but there won’t be a response logged on their platform either, so the failure is total without any gain or loss. If you use request-response, you will not get a response back but for some reason OpenAI manages to log it in time before the Gateway Timeout occurs, meaning you still have access to the response through their platform.

EDIT:
I apologize, I misread the second part. Thank you for pointing out that it is possible to call the API using the response id, will try that out.

There isn’t much more than what is already in the logs.

Usually this sort of error seems to be related to the prompt or a temporary error, which is why I asked if your prompt might be too long or too complex.

You could also increase the timeout, but I’m not sure it matches the 504 error:

from openai import OpenAI
client = OpenAI(
    # increase default timeout to 15 minutes (from 10 minutes)
    timeout=900.0
)

And if possible, you can also make a http request instead of using the API, in which case you would receive http response headers with extra details.

Here are a few other cases for reference:

1 Like

Update
Thank you for your suggestion of using the API. It gives me a structured way to obtain data that was generated but I was unable to obtain prior with my API call.

However, I think the creation date it logs is not after the response has been fully generated but when the request was made. The creation date is only 2 seconds after the logged request timestamp in my logs and I do not believe it took 2 seconds to generate that response, as it took around 20k output tokens.