Add AI Gateway development mode configuration
What does this merge request do and why?
This MR extends the existing gitlab_ai_gateway config to automatically manage AI Gateway environment variables and adds a diagnostic check to detect configuration mismatches. Engineers no longer need to manually update multiple env vars when switching between local and staging AI Gateway.
How it works:
-
environment: 'local': setsDEVELOPMENT_AI_GATEWAY_URLto local AI Gateway (e.g.,http://gdk.test:5052), removesCLOUD_CONNECTOR_BASE_URL -
environment: 'staging': setsCLOUD_CONNECTOR_BASE_URLtohttps://cloud.staging.gitlab.com, removesDEVELOPMENT_AI_GATEWAY_URL
Closes #3099
How to set up and validate locally
- Run
gdk rails runner "Ai::Setting.first.update!(ai_gateway_url: 'https://cloud.staging.gitlab.com')" - Run
gdk doctor - You should see:
[Correctable] AI Gateway
================================================================================
Self-Hosted AI Gateway URL is set to staging (https://cloud.staging.gitlab.com) in the database. This is not the correct way to configure the staging AI Gateway URL.
If you want to connect to staging AI Gateway:
1. Clear out the Self-hosted AI Gateway URL: gdk rails runner "::Ai::Setting.instance.update!(ai_gateway_url: nil)"
2. Set environment: gdk config set gitlab_ai_gateway.environment staging
3. Run: gdk reconfigure
If you want to use self-hosted models:
Change the URL: gdk rails runner "::Ai::Setting.instance.update!(ai_gateway_url: 'http://localhost:5052')"
- Test GitLab Duo Chat to make sure you get a response. You shouldn't see any logs in AI Gateway (since you're connected to staging).
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This MR references an issue describing the change. -
This change is backward compatible. If not, include steps to communicate to users. -
Tests added for new functionality. If not, raise an issue to follow-up. -
Observability added/updated (logging, metrics, tracing). -
Documentation added/updated. -
Announcement added for notable changes. -
gdk doctortest added.
Edited by Nao Hashizume