← Catalog

pi-gitlab-provider

GitLab AI gateway model proxy provider for pi (Anthropic and OpenAI models via GitLab Duo)

Package

Install

Install with PiG

pig install npm:pi-gitlab-provider

Install with Pi

pi install npm:pi-gitlab-provider
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.2 (README.md). PiG does not review it.

pi-gitlab-provider

A pi provider for the Anthropic and OpenAI models that GitLab exposes through its AI gateway model provider proxy (GitLab Duo).

This provider only proxies requests. It does not use Duo Chat or the Duo Agent Platform. Requests go through pi's built-in Anthropic Messages and OpenAI Responses code, so tool calls, thinking, usage and cancellation work the same as with the direct providers.

Install

pi install npm:pi-gitlab-provider
# or
pi install git:gitlab.com/reprazent/pi-gitlab-provider

Authenticate

Use either:

  • A personal access token with the api or ai_features scope:

    export GITLAB_TOKEN=glpat-...
    
  • OAuth: run /login gitlab in pi and authorize in your browser. pi listens on http://127.0.0.1:31853/callback to receive the redirect. If that port is busy, or the browser runs on another machine, paste the callback URL from the browser's address bar into pi instead. Stored OAuth credentials take precedence over the environment variable.

    For a self-managed instance, create an OAuth application (user, group or instance level) with:

    • redirect URI http://127.0.0.1:31853/callback
    • Confidential unchecked
    • scope api

    and set GITLAB_OAUTH_CLIENT_ID to its application ID.

GitLab Duo must be enabled for your account.

Models

The provider loads the model list from GitLab's AI gateway catalog, ai_gateway/model_selection/models.yml. It keeps every entry with a proxy_provider and uses its params.model as the model ID. The file is fetched through the GitLab files API with your token.

Context window and output limits come from the catalog. Pricing, reasoning support, input types and API compatibility settings come from pi's built-in anthropic and openai models with the same ID.

The list is fetched when pi starts and saved in pi's model store, so it's still available offline.

pi --list-models gitlab
pi --model gitlab/claude-sonnet-4-6

Configuration

VariableDefaultPurpose
GITLAB_TOKENPersonal access token
GITLAB_URLhttps://gitlab.comGitLab instance for login and direct access tokens
GITLAB_OAUTH_CLIENT_IDbundled gitlab.com appOAuth application for a self-managed instance
GITLAB_AI_GATEWAY_URLhttps://cloud.gitlab.comAI gateway hosting the proxies
GITLAB_MODELS_REFmainai-assist ref to read models.yml from

The catalog is always read from gitlab.com. With a self-managed GITLAB_URL, it's fetched without authentication, because that token isn't valid on gitlab.com.

How it works

  1. Exchange the GitLab token for a short-lived AI gateway token via POST /api/v4/ai/third_party_agents/direct_access. The token is cached until the expiry GitLab reports, and discarded early if a request returns 401.
  2. Send the request to /ai/v1/proxy/anthropic/ or /ai/v1/proxy/openai/v1 with that token and the returned x-gitlab-* headers.

Credits

Based on pi's custom-provider-gitlab-duo example extension (MIT).

Development

npm install
npm run check
npm test
pi -e . --list-models gitlab