Fun with GPTel: gptel-litellm for tracking sessions with LiteLLM

The gptel-litellm module, which depends on the uuidgen library, adds tracking of “"sessions"” for users with a LiteLLM proxy backend — where each GPTel Chat buffer constitutes its own session.

What this means is that all requests from the same buffer are grouped under the same session-id in LiteLLM’s interface, for accounting and cost tracking purposes. An example of what this looks like can be seen in the documentation.

I also recommend setting a tag for GPTel, so LiteLLM can see all requests that orginated from GPTel no matter which buffer was used:

(gptel-make-openai ""LiteLLM""
  :key gptel-api-key
  :host ...
  :models ...
  :header
  (lambda () (when-let* ((key (gptel--get-api-key)))
          `((""x-api-key""      . ,key)
            (""x-litellm-tags"" . ""gptel"")))))