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': sets DEVELOPMENT_AI_GATEWAY_URL to local AI Gateway (e.g., http://gdk.test:5052), removes CLOUD_CONNECTOR_BASE_URL
  • environment: 'staging': sets CLOUD_CONNECTOR_BASE_URL to https://cloud.staging.gitlab.com, removes DEVELOPMENT_AI_GATEWAY_URL

Closes #3099

How to set up and validate locally

  1. Run gdk rails runner "Ai::Setting.first.update!(ai_gateway_url: 'https://cloud.staging.gitlab.com')"
  2. Run gdk doctor
  3. 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')"
  1. 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:

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 doctor test added.
Edited by Nao Hashizume

Merge request reports

Loading