pi-gitlab-provider1.0.2
GitLab AI gateway model proxy provider for pi (Anthropic and OpenAI models via GitLab Duo)
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
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
apiorai_featuresscope:export GITLAB_TOKEN=glpat-...OAuth: run
/login gitlabin pi and authorize in your browser. pi listens onhttp://127.0.0.1:31853/callbackto 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_IDto its application ID.- redirect URI
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
| Variable | Default | Purpose |
|---|---|---|
GITLAB_TOKEN |
Personal access token | |
GITLAB_URL |
https://gitlab.com |
GitLab instance for login and direct access tokens |
GITLAB_OAUTH_CLIENT_ID |
bundled gitlab.com app | OAuth application for a self-managed instance |
GITLAB_AI_GATEWAY_URL |
https://cloud.gitlab.com |
AI gateway hosting the proxies |
GITLAB_MODELS_REF |
main |
ai-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
- 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. - Send the request to
/ai/v1/proxy/anthropic/or/ai/v1/proxy/openai/v1with that token and the returnedx-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