Skip to content

Not able to add image to generate content #142213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Focke84 opened this issue Apr 3, 2025 · 14 comments · May be fixed by #143878
Open

Not able to add image to generate content #142213

Focke84 opened this issue Apr 3, 2025 · 14 comments · May be fixed by #143878

Comments

@Focke84
Copy link

Focke84 commented Apr 3, 2025

The problem

The new function to generate content, doesn’t allow me to add an image. It always says it has no access to the folder, but the same file with the path is working for google ai.

What version of Home Assistant Core has the issue?

core-2025.4.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OpenAI Conversation

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

action: openai_conversation.generate_content
data:
  config_entry: ….
  prompt: Was siehst du?
  filenames: 
    - /config/www/Eingang/screenshot_3.jpg

Anything in the logs that might be useful for us?

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Apr 3, 2025

Hey there @balloob, mind taking a look at this issue as it has been labeled with an integration (openai_conversation) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of openai_conversation can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign openai_conversation Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


openai_conversation documentation
openai_conversation source
(message by IssueLinks)

@Melantrix
Copy link
Contributor

I have the same problem. When i remove the '-' before the list it does upload but it says the following:

Error generating content: Error code: 400 - {'error': {'message': "Invalid 'input[0].content[1].file_id': '/config/images/voordeur.png'. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters.", 'type': 'invalid_request_error', 'param': 'input[0].content[1].file_id', 'code': 'invalid_value'}}

If i understand correctly, openai expects you to upload the file first and then use the fileid that it returns when uploaded?

@AdamCavaliere
Copy link

I am running into the same thing. Also the documentation needs to be updated. It is no longer image_filename:

@alex-deutsch
Copy link

+1 please update the documentation

@gitrich13
Copy link

gitrich13 commented Apr 5, 2025

Thanks for a great integration.

I am having the same issue with filename error code: 400. I tried different variations on the file name without success.

Upon further research this might be caused by the OpenAI API requiring a filename rather than a path. The use of a path with the "/" symbols may be what is causing an error.

@tommyjlong
Copy link
Contributor

Seeing the same error as Melantrix above.

action: openai_conversation.generate_content
data:
  filenames: /config/snapshots/snapshot_camera.jpg
  config_entry: blah
  prompt: |2-
        Very briefly describe what you see in this image from my doorbell camera.
        Your message needs to be short to fit in a phone notification. Don't
        describe stationary objects or buildings.

@cl0ud6uru
Copy link

Just popping in to say I'm having this exact issues as well.

action: openai_conversation.generate_content
data:
config_entry: 01JS0P7YARPTKGD9KXKQEA7D3A
prompt: You see trash can?
filenames: /config/www/snapshots/trashsnapshot.jpg

Error:
Failed to perform the action openai_conversation.generate_content. Error generating content: Error code: 400 - {'error': {'message': "Invalid 'input[0].content[1].file_id': '/config/www/snapshots/trashsnapshot.jpg'. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters.", 'type': 'invalid_request_error', 'param': 'input[0].content[1].file_id', 'code': 'invalid_value'}}

@R0bin83
Copy link

R0bin83 commented Apr 17, 2025

I'm having the exact same issue.

@wespe11
Copy link

wespe11 commented Apr 20, 2025

Same here!

@ph0nebooth
Copy link

I'm also impacted.

@gvwirth
Copy link

gvwirth commented Apr 25, 2025

Exact same issue here. Can't use images.

@xupaosso
Copy link

+1 for a fix, running into the same problem

@cadavre
Copy link
Contributor

cadavre commented Apr 29, 2025

Wow @balloob himself an integration owner. :) Hi!

I hope this can be fixed soon, as this is one of the main LLM integrations.

@cadavre
Copy link
Contributor

cadavre commented Apr 29, 2025

The problem is:
https://github.com/home-assistant/core/blob/dev/homeassistant/components/openai_conversation/__init__.py#L140

The file_id provided in service is a path and it may contain chars that are not allowed by OpenAI.

I think we can simply generate random file id or just put 1 into that field.


This field actually seems to be optional:
https://github.com/openai/openai-python/blob/main/src/openai/types/responses/response_input_image_param.py#L21

@cadavre cadavre linked a pull request Apr 29, 2025 that will close this issue
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.