Repository: langchain
Issue: Dall-E Image Generator DallEAPIWrapper Error: openai.AuthenticationError"
Labels: 🤖:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.
- [X] I am sure that this is a bug in LangChain rather than my code.
- [X] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

### Example Code

The following Langchain code failed to generate image: 
```python
from langchain_community.utilities.dalle_image_generator import DallEAPIWrapper
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI

import os

os.environ["OPENAI_API_KEY"] = "********"

from langchain.chains import LLMChain

llm = OpenAI(temperature=0.9)
prompt = PromptTemplate(
    input_variables=["image_desc"],
    template="Generate a detailed prompt to generate an image based on the following description: {image_desc}",
)
chain = LLMChain(llm=llm, prompt=prompt)

image_url = DallEAPIWrapper().run(chain.run("halloween night at a haunted museum"))
print(image_url)
```
The following OpenAI code generated image successfully:
``` python
from openai import OpenAI
import os
os.environ["OPENAI_API_KEY"] = "****"

client = OpenAI()

response = client.images.generate(
  model="dall-e-3",
  prompt="a white siamese cat",
  size="1024x1024",
  quality="standard",
  n=1,
)

image_url = response.data[0].url
print(image_url)
```

### Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "D:\software\JetBrains\PyCharm Community Edition 2024.2.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\JetBrains\PyCharm Community Edition 2024.2.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\workspace\python-projects\AI-Development\agents\dalle_image.py", line 21, in <module>
    image_url = DallEAPIWrapper().run(chain.run("halloween night at a haunted museum"))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\workspace\python-projects\AI-Development\.venv\Lib\site-packages\langchain_community\utilities\dalle_image_generator.py", line 143, in run
    response = self.client.generate(
               ^^^^^^^^^^^^^^^^^^^^^
  File "E:\workspace\python-projects\AI-Development\.venv\Lib\site-packages\openai\resources\images.py", line 264, in generate
    return self._post(
           ^^^^^^^^^^^
  File "E:\workspace\python-projects\AI-Development\.venv\Lib\site-packages\openai\_base_client.py", line 1270, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\workspace\python-projects\AI-Development\.venv\Lib\site-packages\openai\_base_client.py", line 947, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "E:\workspace\python-projects\AI-Development\.venv\Lib\site-packages\openai\_base_client.py", line 1051, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: **********. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}



### Description

I write a demo following up guideline https://python.langchain.com/docs/integrations/tools/dalle_image_generator/#run-as-a-chain, but it always failed with error :"openai.AuthenticationError: Error code: 401 - {'error': {'code': 'invalid_api_key', 'message': 'Incorrect API key provided: **********. You can find your API key at https://platform.openai.com/account/api-keys.', 'param': None, 'type': 'invalid_request_error'}}".
I debug the program into _base_client.py found the open AI images generations API url is wrong as the screen capture as below.
The same OPENAI_API_KEY can success in the OpenAI sample as above.
![image](https://github.com/user-attachments/assets/0698da6b-5346-48b0-bcc1-68e285e9b993)


### System Info

System Information
------------------
> OS:  Windows
> OS Version:  10.0.19045
> Python Version:  3.12.6 (tags/v3.12.6:a4a2d2b, Sep  6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)]

Package Information
-------------------
> langchain_core: 0.3.10
> langchain: 0.3.3
> langchain_community: 0.3.2
> langsmith: 0.1.131
> langchain_anthropic: 0.2.3
> langchain_chroma: 0.1.4
> langchain_openai: 0.2.2
> langchain_text_splitters: 0.3.0
> langgraph: 0.2.34

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.10.9
> anthropic: 0.35.0
> async-timeout: Installed. No version info available.
> chromadb: 0.5.11
> dataclasses-json: 0.6.7
> defusedxml: 0.7.1
> fastapi: 0.115.0
> httpx: 0.27.2
> jsonpatch: 1.33
> langgraph-checkpoint: 2.0.0
> numpy: 1.26.4
> openai: 1.51.0
> orjson: 3.10.7
> packaging: 24.1
> pydantic: 2.9.2
> pydantic-settings: 2.5.2
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.35
> tenacity: 8.5.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2