OpenAI: Add gpt-5.5, gpt-5.4-mini/nano, gpt-image-2 (#5529) * feat: gpt-image-2 for OpenAI image generation * gpt-5.5 Co-authored-by: Copilot <copilot@github.com> * fix: adjust reasoning effort mapping Co-authored-by: Copilot <copilot@github.com> * fix: html format --------- Co-authored-by: Copilot <copilot@github.com>
Signed| @@ -3046,8 +3046,17 @@ | |||
| 3046 | <div> | 3046 | <div> |
| 3047 | <h4 data-i18n="OpenAI Model">OpenAI Model</h4> | 3047 | <h4 data-i18n="OpenAI Model">OpenAI Model</h4> |
| 3048 | <select id="model_openai_select"> | 3048 | <select id="model_openai_select"> |
| 3049 | <optgroup label="GPT-5.5"> | ||
| 3050 | <option value="gpt-5.5">gpt-5.5</option> | ||
| 3051 | <option value="gpt-5.5-2026-04-23">gpt-5.5-2026-04-23</option> | ||
| 3052 | </optgroup> | ||
| 3049 | <optgroup label="GPT-5.4"> | 3053 | <optgroup label="GPT-5.4"> |
| 3050 | <option value="gpt-5.4">gpt-5.4</option> | 3054 | <option value="gpt-5.4">gpt-5.4</option> |
| 3055 | <option value="gpt-5.4-2026-03-05">gpt-5.4-2026-03-05</option> | ||
| 3056 | <option value="gpt-5.4-mini">gpt-5.4-mini</option> | ||
| 3057 | <option value="gpt-5.4-mini-2026-03-17">gpt-5.4-mini-2026-03-17</option> | ||
| 3058 | <option value="gpt-5.4-nano">gpt-5.4-nano</option> | ||
| 3059 | <option value="gpt-5.4-nano-2026-03-17">gpt-5.4-nano-2026-03-17</option> | ||
| 3051 | </optgroup> | 3060 | </optgroup> |
| 3052 | <optgroup label="GPT-5.3"> | 3061 | <optgroup label="GPT-5.3"> |
| 3053 | <option value="gpt-5.3-chat-latest">gpt-5.3-chat-latest</option> | 3062 | <option value="gpt-5.3-chat-latest">gpt-5.3-chat-latest</option> |
| @@ -54,7 +54,14 @@ | |||
| 54 | <option data-type="cohere" value="c4ai-aya-vision-8b">c4ai-aya-vision-8b</option> | 54 | <option data-type="cohere" value="c4ai-aya-vision-8b">c4ai-aya-vision-8b</option> |
| 55 | <option data-type="cohere" value="c4ai-aya-vision-32b">c4ai-aya-vision-32b</option> | 55 | <option data-type="cohere" value="c4ai-aya-vision-32b">c4ai-aya-vision-32b</option> |
| 56 | <option data-type="cohere" value="command-a-vision-07-2025">command-a-vision-07-2025</option> | 56 | <option data-type="cohere" value="command-a-vision-07-2025">command-a-vision-07-2025</option> |
| 57 | <option data-type="openai" value="gpt-5.5">gpt-5.5</option> | ||
| 58 | <option data-type="openai" value="gpt-5.5-2026-04-23">gpt-5.5-2026-04-23</option> | ||
| 57 | <option data-type="openai" value="gpt-5.4">gpt-5.4</option> | 59 | <option data-type="openai" value="gpt-5.4">gpt-5.4</option> |
| 60 | <option data-type="openai" value="gpt-5.4-2026-03-05">gpt-5.4-2026-03-05</option> | ||
| 61 | <option data-type="openai" value="gpt-5.4-mini">gpt-5.4-mini</option> | ||
| 62 | <option data-type="openai" value="gpt-5.4-mini-2026-03-17">gpt-5.4-mini-2026-03-17</option> | ||
| 63 | <option data-type="openai" value="gpt-5.4-nano">gpt-5.4-nano</option> | ||
| 64 | <option data-type="openai" value="gpt-5.4-nano-2026-03-17">gpt-5.4-nano-2026-03-17</option> | ||
| 58 | <option data-type="openai" value="gpt-5.3-chat-latest">gpt-5.3-chat-latest</option> | 65 | <option data-type="openai" value="gpt-5.3-chat-latest">gpt-5.3-chat-latest</option> |
| 59 | <option data-type="openai" value="gpt-5.2">gpt-5.2</option> | 66 | <option data-type="openai" value="gpt-5.2">gpt-5.2</option> |
| 60 | <option data-type="openai" value="gpt-5.2-2025-12-11">gpt-5.2-2025-12-11</option> | 67 | <option data-type="openai" value="gpt-5.2-2025-12-11">gpt-5.2-2025-12-11</option> |
| @@ -2382,6 +2382,8 @@ async function loadDrawthingsModels() { | |||
| 2382 | 2382 | ||
| 2383 | async function loadOpenAiModels() { | 2383 | async function loadOpenAiModels() { |
| 2384 | return [ | 2384 | return [ |
| 2385 | { value: 'gpt-image-2', text: 'gpt-image-2' }, | ||
| 2386 | { value: 'gpt-image-2-2026-04-21', text: 'gpt-image-2-2026-04-21' }, | ||
| 2385 | { value: 'gpt-image-1.5', text: 'gpt-image-1.5' }, | 2387 | { value: 'gpt-image-1.5', text: 'gpt-image-1.5' }, |
| 2386 | { value: 'gpt-image-1-mini', text: 'gpt-image-1-mini' }, | 2388 | { value: 'gpt-image-1-mini', text: 'gpt-image-1-mini' }, |
| 2387 | { value: 'gpt-image-1', text: 'gpt-image-1' }, | 2389 | { value: 'gpt-image-1', text: 'gpt-image-1' }, |
| @@ -4075,7 +4077,7 @@ async function generateOpenAiImage(prompt, signal) { | |||
| 4075 | 4077 | ||
| 4076 | const isDalle2 = /dall-e-2/.test(extension_settings.sd.model); | 4078 | const isDalle2 = /dall-e-2/.test(extension_settings.sd.model); |
| 4077 | const isDalle3 = /dall-e-3/.test(extension_settings.sd.model); | 4079 | const isDalle3 = /dall-e-3/.test(extension_settings.sd.model); |
| 4078 | const isGptImg = /gpt-image-(1|latest)/.test(extension_settings.sd.model); | 4080 | const isGptImg = /gpt-image-(1|2|latest)/.test(extension_settings.sd.model); |
| 4079 | const isSora2 = /sora-2/.test(extension_settings.sd.model); | 4081 | const isSora2 = /sora-2/.test(extension_settings.sd.model); |
| 4080 | 4082 | ||
| 4081 | if (isDalle2 && prompt.length > dalle2PromptLimit) { | 4083 | if (isDalle2 && prompt.length > dalle2PromptLimit) { |
| @@ -2530,9 +2530,16 @@ function getReasoningEffort(settings = null, model = null) { | |||
| 2530 | return 'none'; | 2530 | return 'none'; |
| 2531 | } | 2531 | } |
| 2532 | 2532 | ||
| 2533 | return [chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(settings.chat_completion_source) && /^gpt-5/.test(model) | 2533 | if ([chat_completion_sources.OPENAI, chat_completion_sources.AZURE_OPENAI].includes(settings.chat_completion_source)) { |
| 2534 | ? reasoning_effort_types.min | 2534 | if (/^gpt-5\.(4|5)/.test(model)) { |
| 2535 | : reasoning_effort_types.low; | 2535 | return 'none'; |
| 2536 | } | ||
| 2537 | if (/^gpt-5/.test(model)) { | ||
| 2538 | return reasoning_effort_types.min; | ||
| 2539 | } | ||
| 2540 | } | ||
| 2541 | |||
| 2542 | return reasoning_effort_types.low; | ||
| 2536 | case reasoning_effort_types.max: | 2543 | case reasoning_effort_types.max: |
| 2537 | return reasoning_effort_types.high; | 2544 | return reasoning_effort_types.high; |
| 2538 | default: | 2545 | default: |
| @@ -2945,7 +2952,7 @@ export async function createGenerationParameters(settings, model, type, messages | |||
| 2945 | if (/gpt-5-chat-latest/.test(model)) { | 2952 | if (/gpt-5-chat-latest/.test(model)) { |
| 2946 | delete generate_data.tools; | 2953 | delete generate_data.tools; |
| 2947 | delete generate_data.tool_choice; | 2954 | delete generate_data.tool_choice; |
| 2948 | } else if (/gpt-5\.(1|2|3|4)/.test(model) && !/chat-latest/.test(model)) { | 2955 | } else if (/gpt-5\.(1|2|3|4)/.test(model) && !/chat-latest/.test(model) && !generate_data.reasoning_effort) { |
| 2949 | delete generate_data.frequency_penalty; | 2956 | delete generate_data.frequency_penalty; |
| 2950 | delete generate_data.presence_penalty; | 2957 | delete generate_data.presence_penalty; |
| 2951 | delete generate_data.logit_bias; | 2958 | delete generate_data.logit_bias; |
| @@ -4887,41 +4894,43 @@ function onSettingsPresetChange() { | |||
| 4887 | }); | 4894 | }); |
| 4888 | } | 4895 | } |
| 4889 | 4896 | ||
| 4897 | /** | ||
| 4898 | * Get the maximum context size for the OpenAI model | ||
| 4899 | * @param {string} value Model identifier | ||
| 4900 | * @returns {number} Maximum context size in tokens | ||
| 4901 | */ | ||
| 4890 | function getMaxContextOpenAI(value) { | 4902 | function getMaxContextOpenAI(value) { |
| 4891 | if (oai_settings.max_context_unlocked) { | 4903 | if (oai_settings.max_context_unlocked) { |
| 4892 | return unlocked_max; | 4904 | return unlocked_max; |
| 4893 | } else if (value.startsWith('gpt-5.4')) { | ||
| 4894 | return max_1mil; | ||
| 4895 | } else if (value.startsWith('gpt-5')) { | ||
| 4896 | return max_400k; | ||
| 4897 | } else if (value.includes('gpt-4.1')) { | ||
| 4898 | return max_1mil; | ||
| 4899 | } else if (value.includes('gpt-audio')) { | ||
| 4900 | return max_128k; | ||
| 4901 | } else if (value.startsWith('o1')) { | ||
| 4902 | return max_128k; | ||
| 4903 | } else if (value.startsWith('o4') || value.startsWith('o3')) { | ||
| 4904 | return max_200k; | ||
| 4905 | } else if (value.includes('chatgpt-4o-latest') || value.includes('gpt-4-turbo') || value.includes('gpt-4o') || value.includes('gpt-4-1106') || value.includes('gpt-4-0125') || value.includes('gpt-4-vision')) { | ||
| 4906 | return max_128k; | ||
| 4907 | } else if (value.includes('gpt-3.5-turbo-1106')) { | ||
| 4908 | return max_16k; | ||
| 4909 | } else if (['gpt-4', 'gpt-4-0314', 'gpt-4-0613'].includes(value)) { | ||
| 4910 | return max_8k; | ||
| 4911 | } else if (['gpt-4-32k', 'gpt-4-32k-0314', 'gpt-4-32k-0613'].includes(value)) { | ||
| 4912 | return max_32k; | ||
| 4913 | } else if (value.includes('gpt-realtime')) { | ||
| 4914 | return max_32k; | ||
| 4915 | } else if (['gpt-3.5-turbo-16k', 'gpt-3.5-turbo-16k-0613'].includes(value)) { | ||
| 4916 | return max_16k; | ||
| 4917 | } else if (value == 'code-davinci-002') { | ||
| 4918 | return max_8k; | ||
| 4919 | } else if (['text-curie-001', 'text-babbage-001', 'text-ada-001'].includes(value)) { | ||
| 4920 | return max_2k; | ||
| 4921 | } else { | ||
| 4922 | // default to gpt-3 (4095 tokens) | ||
| 4923 | return max_4k; | ||
| 4924 | } | 4905 | } |
| 4906 | |||
| 4907 | /** @type {[RegExp, number][]} */ | ||
| 4908 | const contextMap = [ | ||
| 4909 | [/^gpt-5\.[45]/, max_1mil], | ||
| 4910 | [/^gpt-5/, max_400k], | ||
| 4911 | [/gpt-4\.1/, max_1mil], | ||
| 4912 | [/gpt-audio/, max_128k], | ||
| 4913 | [/^o1/, max_128k], | ||
| 4914 | [/^o[34]/, max_200k], | ||
| 4915 | [/chatgpt-4o-latest|gpt-4-turbo|gpt-4o|gpt-4-1106|gpt-4-0125|gpt-4-vision/, max_128k], | ||
| 4916 | [/gpt-3\.5-turbo-1106/, max_16k], | ||
| 4917 | [/^(gpt-4|gpt-4-0314|gpt-4-0613)$/, max_8k], | ||
| 4918 | [/^(gpt-4-32k|gpt-4-32k-0314|gpt-4-32k-0613)$/, max_32k], | ||
| 4919 | [/gpt-realtime/, max_32k], | ||
| 4920 | [/^(gpt-3\.5-turbo-16k|gpt-3\.5-turbo-16k-0613)$/, max_16k], | ||
| 4921 | [/^code-davinci-002$/, max_8k], | ||
| 4922 | [/^(text-curie-001|text-babbage-001|text-ada-001)$/, max_2k], | ||
| 4923 | [/gpt-3/, max_4k], | ||
| 4924 | ]; | ||
| 4925 | |||
| 4926 | for (const [regex, max] of contextMap) { | ||
| 4927 | if (regex.test(value)) { | ||
| 4928 | return max; | ||
| 4929 | } | ||
| 4930 | } | ||
| 4931 | |||
| 4932 | // Safe default for most modern models | ||
| 4933 | return max_128k; | ||
| 4925 | } | 4934 | } |
| 4926 | 4935 | ||
| 4927 | /** | 4936 | /** |
| @@ -480,6 +480,13 @@ export const OPENAI_REASONING_EFFORT_MODELS = [ | |||
| 480 | 'gpt-5.2-chat-latest', | 480 | 'gpt-5.2-chat-latest', |
| 481 | 'gpt-5.3-chat-latest', | 481 | 'gpt-5.3-chat-latest', |
| 482 | 'gpt-5.4', | 482 | 'gpt-5.4', |
| 483 | 'gpt-5.4-2026-03-05', | ||
| 484 | 'gpt-5.4-mini', | ||
| 485 | 'gpt-5.4-mini-2026-03-17', | ||
| 486 | 'gpt-5.4-nano', | ||
| 487 | 'gpt-5.4-nano-2026-03-17', | ||
| 488 | 'gpt-5.5', | ||
| 489 | 'gpt-5.5-2026-04-23', | ||
| 483 | ]; | 490 | ]; |
| 484 | 491 | ||
| 485 | export const OPENAI_REASONING_EFFORT_MAP = { | 492 | export const OPENAI_REASONING_EFFORT_MAP = { |