Getting sporadic invalid URLs using structured outputs API

Sporadically I am getting this error when using the structured outputs API (snippet below of what’s actually run). Most of the time it works, but then every one in twenty it doesn’t work…

       ': Error code: 404 - {'error': {'message': 'Invalid URL (POST /v1/engines/o4-mini-2025-04-16/completions)', 'type': 'invalid_request_error', 'param': None, 'code': None}}
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
<ipython-input-15-6ae7a927b30c> in <cell line: 0>()
     39 
     40 spell_check_search = SpellingCorrectedSearch(products, corrector)
---> 41 corrected_results = run_strategy(spell_check_search)
     42 corrected_results

9 frames
/usr/local/lib/python3.11/dist-packages/openai/_base_client.py in request(self, cast_to, options, stream, stream_cls)
   1032 
   1033                 log.debug("Re-raising status error")
-> 1034                 raise self._make_status_error_from_response(err.response) from None
   1035 
   1036             break

NotFoundError: Error code: 404 - {'error': {'message': 'Invalid URL (POST /v1/engines/o4-mini-2025-04-16/completions)', 'type': 'invalid_request_error', 'param': None, 'code': None}}

I’m calling using the structure API with a pydantic class as output:

            response = self.client.responses.parse(
                model=self.model,
                input=prompts,
                text_format=self.cls     #< pydantic class
            )

I see this locally and in colab with 1.82.0. Going to try with 1.84.x

4 Likes

This is not a valid endpoint URL any more and should be nowhere in any code:

POST /v1/engines/

It is the kind of thing an AI with a knowledge cutoff like GPT-4-0314 (released 2023) would write:

There should be no scenario where you are having an AI dynamically write the URL for an API call that you then use trustingly.

The string “engines” appears nowhere in the entire SDK.

Thanks. Yes i realize all that.

I’m not calling the URL directly I’m using the code snippet mentioned above from the Python structured output API from client version 1.84. Generating a URL is not in my prompt.

Your code is dumping out from in a function, one that may only be called occasionally, and you don’t show the setup of the client, which can be passed a different URL.

Ensure that there is not a single occurrence of “engines” anywhere in your code.

Then we’d have to assume that somebody at OpenAI did some “vibe coding” on the Responses endpoint internal calls to chat completions itself.

I also started getting the same error since 24 hrs from now. It was more frequent in the start but still getting this sometimes. We have not made any changes to our pipelines and do not have engines anywhere in our code neither do we use have our AI dynamically write URLs!

Exact error:

{'error': {'message': 'Invalid URL (POST /v1/engines/gpt-4.1-mini-2025-04-14/completions)', 'type': 'invalid_request_error', 'param': None, 'code': None}}
1 Like

Maybe there is a bad redirect on the OpenAI side or something?

1 Like

I´m getting it as well from yesterday evening. I´m using the openai Agent SDK

I’m also encountering this. We’re using v1.84.0 of the client and the responses API

1 Like

Also getting the same error recently

1 Like

Also getting the same error recently

Hi there—thanks for flagging this.

When the issue reproduces, could you please capture and share both IDs so we can trace it?

print(resp.id) # response ID 
print(resp._request_id) # request ID
4 Likes

resp_684392161c70819bb8c774d92b04443709f8584d77b77e38

I am also getting the same error makes no sense

@Bui_Thanh_Tinh Could you provide the precise 1 hour time range for the response ID?

1 Like


GMT : Saturday, June 7, 2025 1:13:06 AM
My time zone : Saturday, June 7, 2025 8:13:06 AM GMT+07:00
I hope I understood you correctly, and that this helps you fix the issue soon.

2 Likes

Hello! Can other users post the response_id as well, so we can look for any commonalities in the logs?

1 Like

Maybe I am misunderstanding your request, but based on the error, the response never completes. Would this still result in a response_id if the call is routed to the wrong endpoint (whether the error stems via DNS or within the OpenAI Python package)? I can pull up many instances of this occurring in our logs, but we never get to the returned response data.

@rick.getz one of the user provided a response ID here so I'm assuming it does provide a response ID before it errors out.

@softwaredoug, deepank-atlas do you have a response ID?

1 Like

I haven’t had this happen since the first time I reported it, but if it does, I’ll try to get a response id