Files
magpie/internal/provider/nous_test.go
T
yetone 591ed58b53 provider: Nous Portal is a vendor preset, Nous Research's API with a Portal key (#392, Vocllum, laojianzi)
Nous Research makes the Hermes models and serves them, with other makers'
models, through Nous Portal. #392 was wrongly answered as a relay. A new
preset, nous ("Nous Portal", KindVendor with Hosts, lobe-icons
nousresearch icon), points chat completions at
https://inference-api.nousresearch.com/v1. A Portal API key goes in as a
Bearer, the way Hermes Agent's own nous-api provider uses NOUS_API_KEY.
The model list is the Portal's /v1/models, which uses vendor/model ids.
An entry another app has at that URL, such as Hermes Agent's base_url,
now imports as the preset.

The preset sets no Anthropic endpoint. The Portal's /v1/messages serves
only its anthropic/* models (Hermes Agent's
test_nous_portal_anthropic_wire.py), so Claude Code's requests are
translated to chat completions for every model. It sets no Responses
endpoint either, because none is documented.

The preset is added to the README (en, zh), docs/reference.md, and the
site's import pages and icon.

Sources:
- hermes-agent docs: integrations/nous-portal, integrations/providers,
  features/subscription-proxy.
- hermes-agent source at 6e7b83a2: hermes_cli/auth_constants.py
  (DEFAULT_NOUS_INFERENCE_URL), plugins/model-providers/nous,
  cli-config.yaml.example ("nous-api - Nous Portal API key (requires:
  NOUS_API_KEY)"), agent/anthropic_endpoints.py, and
  tests/e2e/core/live/_helpers.py, whose live run calls the Portal with
  NOUS_API_KEY.

Probed without a key:
- /v1/models answers 200 with 423 models.
- /v1/chat/completions with a bad Bearer answers 401 "Your API key is
  invalid, blocked or out of funds".
- /v1/messages answers an Anthropic-shaped 401.

Not tried: a real Portal key or a real request, since no key was
available. Also not built: OAuth sign-in with the 1-hour token and its
refresh (Hermes Agent's ~/.hermes/auth.json).

Run:
- TestNousPortalPreset fails without the preset (no preset "nous") and
  with an Anthropic endpoint added (endpoints: … "https://inference-api.nousresearch.com").
- go test -tags nogui of internal/provider, internal/gui and
  internal/catalog passes.
- gofmt -l is clean.
- go vet, GOOS=linux go vet and GOOS=windows go vet -tags nogui on
  ./internal/provider pass.
- add-sheet and add-button GUI tests pass in Chromium and WebKit (6/6).
2026-10-14 04:40:21 +08:00

29 lines
1.1 KiB
Go

package provider
import "testing"
// Nous Portal (#392) is a vendor preset at its OpenAI-compatible inference
// API, chat completions only: its /v1/messages serves just the anthropic/*
// models, so it is no Anthropic endpoint for Claude Code's other picks.
func TestNousPortalPreset(t *testing.T) {
p, err := FromPreset("nous")
if err != nil {
t.Fatal(err)
}
if p.Chat != "https://inference-api.nousresearch.com/v1" || p.Responses != "" || p.Anthropic != "" {
t.Fatalf("endpoints: %q %q %q", p.Chat, p.Responses, p.Anthropic)
}
if p.Name != "Nous Portal" || p.Icon != "nousresearch" || p.KeysURL != "https://portal.nousresearch.com" {
t.Fatalf("preset: %+v", p)
}
pr := Preset("nous")
if pr.Kind != KindVendor || !pr.Hosts || pr.NoKey {
t.Fatalf("kind %q hosts %v noKey %v", pr.Kind, pr.Hosts, pr.NoKey)
}
// an entry another app has at the Portal (Hermes Agent's base_url) is the preset
im, why := imported("Nous", "k", endpoints{chat: "https://inference-api.nousresearch.com/v1/"}, nil)
if why != "" || im.Preset != "nous" || im.Icon != "nousresearch" || im.Anthropic != "" {
t.Fatalf("imported: %q %+v", why, im)
}
}