Skip to content

Self-generate JWT for SaaS completions

What does this MR do and why?

  • Calls to POST /api/v4/code_suggestions/completions on SaaS installations no longer require a prior call to /tokens to retrieve a JWT to authenticate to the model gateway.
  • If the user is authenticated correctly to the API, then a JWT is generated as part of the call to /completions and forwarded to the model gateway in a single call.
  • The /tokens endpoint remains intact to preserve backwards compatibility with older clients, however the token itself will just be thrown away.
  • Self-managed behaviour is unchanged.

How to set up and validate locally

  • Make a call to /completions with a request such as this - it should return a standard suggestion from Vertex.
POST /api/v4/code_suggestions/completions HTTP/1.1
Authorization: Bearer ACCESS TOKEN
Content-Type: application/json; charset=utf-8

{"prompt_version":"1","current_file":{"file_name":"dog.js","content_above_cursor":"class Car:\n    def __init__(self, make, model, year, color):\n        self.make = make\n        self.model = model\n        self.year = year\n        self.color = color\n        self.is_running = False\n        self.speed = 0\n    \n    def start(self):\n        if not self.is_running:\n            self.is_running = True\n            print(\"The car is now running.\")\n        else:\n            print(\"The car is already running.\")\n    \n    def stop(self):\n        if self.is_running:\n            self.is_running = False\n            self.speed = 0\n            print(\"The car has stopped.\")\n        else:\n            print(\"The car is already stopped.\")\n    \n    def accelerate(self, increment):","content_below_cursor":""},"project_id":"23"}

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 Max Woolf

Merge request reports