Integrate OpenAI Responses API for image-based solving with gpt-5-nano#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e87d117dfc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const getOpenAiApiKey = () => { | ||
| let apiKey = localStorage.getItem(OPENAI_API_KEY_STORAGE_KEY) || ""; | ||
| if (apiKey) return apiKey; |
There was a problem hiding this comment.
Re-prompt for API key after auth failures
getOpenAiApiKey always returns the cached key once it exists, so if a user initially enters a mistyped/revoked key, every future solve attempt keeps reusing that invalid credential and fails (typically 401) without ever prompting for a replacement. Since this flow has no in-app reset for OPENAI_API_KEY_STORAGE_KEY, users can be stuck in a permanent failure loop until they manually clear local storage.
Useful? React with 👍 / 👎.
Motivation
problem+steps) so the UI can render reliable results.Description
OPENAI_API_KEY_STORAGE_KEYandOPENAI_MODELconstants and agetOpenAiApiKeyhelper that prompts once and caches the key inlocalStorage.generateSolutionWithOpenAI(imageDataUrl, apiKey)which callshttps://api.openai.com/v1/responsesusingfetch, sends the image asinput_image, and parsesdata.output_textas JSON containingproblemandsteps.asynchandler for thesolvebutton and replaced the hard-coded demo solution with a call togenerateSolutionWithOpenAIusing the configured modelgpt-5-nano-2025-08-07.Testing
node --check script.jsto validate there are no syntax errors, and it completed successfully.Codex Task