Skip to content

feat(ai): add a requesty provider alias - #105

Open
Thibaultjaigu wants to merge 1 commit into
pgrundev:mainfrom
Thibaultjaigu:add-requesty-provider
Open

Thibaultjaigu wants to merge 1 commit into
pgrundev:mainfrom
Thibaultjaigu:add-requesty-provider

Conversation

@Thibaultjaigu

Copy link
Copy Markdown

What and why

Adds Requesty (an OpenAI compatible LLM gateway) as a PGBOT_AI_PROVIDER alias for explain and ask, wired the same way as the existing openrouter alias. No new client code: it reuses the /chat/completions provider and only picks the endpoint and key variable.

Changes:

  • internal/ai/openai.go: defaultRequestyURL = "https://router.requesty.ai/v1" next to defaultOpenRouterURL.
  • internal/ai/resolve.go: requesty joins the /chat/completions case, maps to its endpoint, and reads its key from REQUESTY_API_KEY (or PGBOT_AI_API_KEY) only, so an OpenAI or OpenRouter key in the shell is never sent to it. keyVarsFor names REQUESTY_API_KEY in the missing key error. It is not added to auto detection, so it only runs when selected explicitly.
  • internal/ai/resolve_test.go: covers the endpoint with both key variables, the refusal to borrow OPENAI_API_KEY, and that REQUESTY_API_KEY alone is not auto detected.
  • README environment table and explain section (including the EU endpoint https://router.eu.requesty.ai/v1 via PGBOT_AI_BASE_URL), plus a changelog entry under Unreleased.

How to test:

export PGBOT_AI_PROVIDER=requesty
export REQUESTY_API_KEY=rqsty-...
export PGBOT_AI_MODEL=openai/gpt-4o-mini   # optional, default gpt-5.6-terra also works
pgbot ask "What needs attention?" "$DATABASE_URL"

Validation:

  • scripts/gate.sh passes on HEAD (build, vet, golangci-lint 0 issues, tests, 6 targets). gofmt -l clean.
  • Live call through Resolve() and openaiModel.Generate against Requesty: HTTP 200 with openai/gpt-4o-mini, and HTTP 200 with the default gpt-5.6-terra through the reasoning path (max_completion_tokens and reasoning_effort).
  • govulncheck not run locally; no dependencies changed.

Checklist

  • scripts/gate.sh passes (builds HEAD, not just the working tree)
  • New SQL is read-only; no EXPLAIN ANALYZE; findings stay deterministic (computed in Go) (no SQL touched)
  • No PII enters a model.Context / --json / the store (unchanged)
  • --json change is additive, or model.SchemaVersion bumped + schema regenerated (go run ./tools/schemagen) (no --json change)
  • A new finding has a docs/findings/<id>.md page + catalog entry (no new finding)

Disclosure: I work at Requesty. Happy to adjust anything to match project conventions.

PGBOT_AI_PROVIDER=requesty points the /chat/completions client at
https://router.requesty.ai/v1, the same way the openrouter alias picks
its endpoint. The key comes from REQUESTY_API_KEY or PGBOT_AI_API_KEY
only, so an OpenAI or OpenRouter key in the shell is never sent to it,
and it is never auto-detected.

Documented in the README environment table and the explain section,
including the EU endpoint, and in the changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant