Skip to content

Draft: API endpoint for AI Gateway access token + details

Jessie Young requested to merge jy-new-code-suggestions-api-endpoint into master

What does this MR do and why?

API endpoint for AI Gateway access token + details

  • Provides necessary detail for the LSP to make direct requests to the AI Gateway API for Code Suggestions.
  • #433433 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  • Enable the feature flag: echo 'Feature.enable(:code_suggestions_client_direct_to_gateway)' | rails c
  • Generate a personal access token with the api scope at https://gdk.test:3443/-/profile/personal_access_tokens (this request can also be authenticated with an oauth access token but that is harder to generate locally for testing)
  • curl request to endpoint:
    curl --request POST \
     --url https://gdk.test:3443/api/v4/code_suggestions/token_and_usage_details \
     --header 'Content-Type: application/json' \
     --header 'Authorization: Bearer $YOUR_GITLAB_PAT'
  • response looks like this:
    {
      "access_token_expires_in": 3600,
      "created_at": 1701580530,
      "ai_gateway_base_url": "https://codesuggestions.gitlab.com",
      "ai_gateway_code_completion_model_family": "vertex_ai",
      "ai_gateway_code_generation_model_family": "vertex_ai",
      "ai_gateway_request_headers": {
        "X-Gitlab-Instance-Id": [
          "d9c14746-1da5-442b-a8a4-6e9d3ce24c53"
        ],
        "X-Gitlab-Global-User-Id": [
          "nLiw60WLCUJP5m1WNn+2VsWnHrfykMeDGzZcC7q27VQ="
        ],
        "X-Gitlab-Host-Name": [
          "gdk.test"
        ],
        "X-Gitlab-Realm": [
          "saas"
        ],
        "X-Gitlab-Authentication-Type": [
          "oidc"
        ],
        "Authorization": [
          "Bearer eyJ0e..."
        ],
        "Content-Type": [
          "application/json"
        ],
        "User-Agent": [
          "curl/8.1.2"
        ],
        "X-Gitlab-Saas-Namespace-Ids": [
          ""
        ]
      }
    }

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Paul Slaughter

Merge request reports

Loading