Skip to content

feat(ai): add an opper provider alias - #118

Merged
alexshapalov merged 1 commit into
pgrundev:mainfrom
Felixkw12:feat/opper-provider
Oct 12, 2026
Merged

alexshapalov merged 1 commit into
pgrundev:mainfrom
Felixkw12:feat/opper-provider

Conversation

@Felixkw12

Copy link
Copy Markdown
Contributor

What and why

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

Changes:

  • internal/ai/openai.go: defaultOpperURL = "https://api.opper.ai/v3/compat" next to defaultRequestyURL.
  • internal/ai/resolve.go: opper joins the /chat/completions case, maps to its endpoint, and reads its key from OPPER_API_KEY (or PGBOT_AI_API_KEY) only, so an OpenAI or OpenRouter key in the shell is never sent to it. The requesty if/else became a small switch for that. keyVarsFor names OPPER_API_KEY in the missing key error. It is not added to auto detection.
  • internal/ai/resolve_test.go: TestResolve_opper, the requesty test with the names swapped (both key variables, refusal to borrow OPENAI_API_KEY, no auto detection).
  • README environment table and explain section, plus a changelog entry under Unreleased.

The default gpt-5.6-terra is served by Opper under the same id, with reasoning_effort up to max, so PGBOT_AI_MODEL is optional.

How to test:

export PGBOT_AI_PROVIDER=opper
export OPPER_API_KEY=...            # https://platform.opper.ai
export PGBOT_AI_MODEL=claude-sonnet-4-6   # optional
pgbot ask "What needs attention?" "$DATABASE_URL"

Validation:

  • I don't have a Go toolchain on this machine, so scripts/gate.sh, go test and gofmt -l were not run here. The change copies the requesty alias and its test line for line.

Disclosure: Opper is my startup.

Checklist

  • scripts/gate.sh passes (builds HEAD, not just the working tree) (not run locally, see above)
  • 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)

Add Opper, an EU-hosted OpenAI compatible gateway, as a
PGBOT_AI_PROVIDER alias for explain and ask, wired the same way as the
requesty alias. No new client code: it reuses the /chat/completions
provider and only picks the endpoint and key variable.

- internal/ai/openai.go: defaultOpperURL = https://api.opper.ai/v3/compat
- internal/ai/resolve.go: opper joins the /chat/completions case, maps
  to its endpoint and reads its key from OPPER_API_KEY (or
  PGBOT_AI_API_KEY) only. keyVarsFor names OPPER_API_KEY. It is not
  added to auto detection.
- internal/ai/resolve_test.go: TestResolve_opper, a copy of the
  requesty test.
- README environment table and explain section, CHANGELOG entry under
  Unreleased.

The default model gpt-5.6-terra is served by Opper under the same id,
with reasoning_effort up to max, so it works without PGBOT_AI_MODEL.

Not run locally: scripts/gate.sh, go test, gofmt (no Go toolchain on
this machine). The change copies the requesty alias line for line.

Disclosure: Opper is my startup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@alexshapalov
alexshapalov merged commit e8aa24f into pgrundev:main Oct 12, 2026
12 of 21 checks passed
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.

2 participants