Skip to content

Add BYOK custom AI provider support for Ask AI#8606

Open
aaronson2012 wants to merge 5 commits into
4ian:masterfrom
aaronson2012:openai-compatible-providers
Open

Add BYOK custom AI provider support for Ask AI#8606
aaronson2012 wants to merge 5 commits into
4ian:masterfrom
aaronson2012:openai-compatible-providers

Conversation

@aaronson2012
Copy link
Copy Markdown

Summary

This PR adds bring-your-own-key support to Ask AI, so users can configure an OpenAI-compatible provider and use whichever model they want instead of being limited to the default GDevelop AI provider.

The feature adds:

  • a new AI Providers section in Preferences, with common presets plus custom OpenAI-compatible provider settings
  • support for saving, updating, testing, selecting, and deleting provider configurations
  • a Custom Model option in the Ask AI model selector when a saved provider is available
  • request plumbing so custom provider requests carry the selected provider configuration and do not consume GDevelop AI credits
  • local/localhost provider support, keeping local provider keys/configuration on the machine and sending compatible requests directly to the provider
  • local Custom Model handling for chat/build flows, including tool-call support and event-generation repair fallbacks where needed

The main goal is BYOK: let people plug in their own provider/API key/model and keep using the Ask AI workflow. The rest of the changes serve that path: preserving configuration across request refreshes, handling provider availability errors, avoiding uploads for local providers, and keeping the UI honest about who may bill the request.

Testing

I ran the focused test set:

npm test -- --runInBand --watchAll=false src/AiGeneration/AiProviderConfigurations.spec.js src/AiGeneration/AiRequestChat/AiConfigurationPresetSelector.spec.js src/MainFrame/Preferences/AiProvidersPreferences.spec.js src/AiGeneration/Utils.spec.js src/Utils/GDevelopServices/Generation.spec.js src/EditorFunctions/EditorFunctions.spec.js

This passed with 6 suites and 101 tests.

I’ve also tested the feature manually, and everything seems to work with no regressions I was able to notice.

@aaronson2012
Copy link
Copy Markdown
Author

AI Preferences Menu
image

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbfb523fd5

ℹ️ 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".

Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js Outdated
Comment thread newIDE/app/src/EditorFunctions/index.js
Comment thread newIDE/app/src/MainFrame/Preferences/AiProvidersPreferences.js Outdated
Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js Outdated
Copy link
Copy Markdown
Author

Implemented the Codex review feedback in ef141c3ac:

  • network/CORS/DNS failures no longer fall back to local provider configuration storage
  • failed local event repair attempts restore the project before retrying
  • the provider field now says “Max output tokens” instead of “Context window”
  • local Build tool schema now requires object_name for put_2d_instances

Verified with:

npm test -- --runInBand --watchAll=false src/Utils/GDevelopServices/Generation.spec.js src/MainFrame/Preferences/AiProvidersPreferences.spec.js src/EditorFunctions/EditorFunctions.spec.js

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef141c3ac9

ℹ️ 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".

Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js
Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js
Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js
Copy link
Copy Markdown
Author

Implemented the remaining Codex review feedback in 079406ee0:

  • local add_scene_events now disables content uploads so local providers receive project, extension, and events context inline
  • local Custom Model Stop now suspends the in-memory request without calling the backend, and late provider responses no longer overwrite the suspended state
  • local restore/fork now creates a trimmed in-memory fork so follow-up context matches the restored project state

Verified with:

npm test -- --runInBand --watchAll=false src/Utils/GDevelopServices/Generation.spec.js
npm test -- --runInBand --watchAll=false src/EditorFunctions/EditorFunctions.spec.js
npx eslint src/AiGeneration/UseGenerateEvents.js src/Utils/GDevelopServices/Generation.js src/Utils/GDevelopServices/Generation.spec.js --max-warnings=0
npm run flow

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 079406ee00

ℹ️ 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".

Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js
Comment thread newIDE/app/src/MainFrame/Preferences/AiProvidersPreferences.js
Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js Outdated
Comment thread newIDE/app/src/AiGeneration/Utils.js
Comment thread newIDE/app/src/Utils/GDevelopServices/Generation.js
Copy link
Copy Markdown
Author

Implemented the latest Codex review feedback in a0645bc1c:

  • strict-JSON tool fallback history now serializes previous tool calls/results as plain text, without tool roles or tool_calls fields
  • saving a saved remote provider as localhost now requires a replacement API key
  • new local Custom Model requests are stored as working requests before the first provider call resolves, so the UI can select and stop them
  • local build chats can now store restore-point project version metadata
  • editing a local provider to a remote URL now creates a backend provider configuration, reusing the locally saved key when needed

Verified with:

npm test -- --runInBand --watchAll=false src/Utils/GDevelopServices/Generation.spec.js src/MainFrame/Preferences/AiProvidersPreferences.spec.js src/AiGeneration/Utils.spec.js
npx eslint src/Utils/GDevelopServices/Generation.js src/Utils/GDevelopServices/Generation.spec.js src/MainFrame/Preferences/AiProvidersPreferences.js src/MainFrame/Preferences/AiProvidersPreferences.spec.js src/AiGeneration/AskAiEditorContainer.js src/AiGeneration/AskAiStandAloneForm.js src/AiGeneration/Utils.js --max-warnings=0
npm run flow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant