Wade111999 on X tested OpenRouter's thinkingmachines/inkling-2-small:free in magpie and got "403 · … is only available on agentic harnesses". OpenRouter serves that free endpoint only to agent apps it lists at openrouter.ai/apps, judged by the app a request is attributed to (its HTTP-Referer; the 403's routing step is "Gate Free Endpoints by Agentic Harness"). Its docs and other clients' real-key reports (Skales #325, OpenTrading #204) say attribution headers of an unlisted app don't pass it, and the paid thinkingmachines/inkling-2-small has no gate. A model test is magpie's own request, so it is refused; magpie never names an app it isn't. Two things magpie did wrong with it: - restAfterMarked read the 403 as the key's: it rested the whole OpenRouter key (Key "openrouter", by backoff), so one agent request for the gated model set every other OpenRouter model aside. It now rests nothing and counts no failure, as a region refusal; a group's next member is still asked (retryable). A key's own 403 still rests the key. - the test showed a bare 403. APIError now puts HarnessOnlyHint after OpenRouter's words: served only to listed agent apps, a magpie test isn't one, the model without :free is served to any request. Not changed: magpie passes the agent's User-Agent to OpenRouter as before, but agents send OpenRouter's attribution headers (HTTP-Referer, X-OpenRouter-Title) only to openrouter.ai itself, so whether OpenRouter serves an agent's request through magpie is not known. Run (mica, mote over its load): - TestHarnessOnlyTestSaysWhy, TestOpenRouterHarnessOnlyRestsNothing: red on origin/main's routing.go and test.go (the key rested {Key:openrouter By:backoff}; the error had no hint), green after. - go test -timeout 45m -count=1 ./internal/provider ./internal/gateway: ok internal/provider 170.7s, ok internal/gateway 1012.0s (mica, ate513cba54+ this diff) Rebased on51eb1ae4b(main's gemini audio change in both packages): go vet of both packages, and the two tests above with -run Gemini|Audio, ok on mica at the pushed head. - go vet, GOOS=linux and GOOS=windows go vet of both packages, gofmt -l: clean. Not tried: a real OpenRouter request; every OpenRouter key on this machine, mote and mica answers 401 "User not found".
32 lines
1.4 KiB
Go
32 lines
1.4 KiB
Go
package provider
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/yetone/magpie/internal/lazyre"
|
|
)
|
|
|
|
// OpenRouter serves some free endpoints only to the agent apps it lists
|
|
// (openrouter.ai/apps), as it attributes a request to an app (its
|
|
// HTTP-Referer). Any other request is answered 403 "thinkingmachines/
|
|
// inkling-2-small:free is only available on agentic harnesses. Try
|
|
// plugging it into a coding agent or productivity app listed on
|
|
// https://openrouter.ai/apps" (Wade111999 on X), its routing step "Gate
|
|
// Free Endpoints by Agentic Harness". The key is fine, and so is the
|
|
// model: the app the request came from is what is turned away, so a
|
|
// magpie test, which is magpie's own request and names no app, is
|
|
// refused, and an agent's may be served. magpie never names an app it
|
|
// isn't.
|
|
|
|
// harnessOnly matches that refusal's words.
|
|
var harnessOnly = lazyre.New(`(?i)only available (?:on|with|via|in|to|for use with) agentic harness`)
|
|
|
|
// HarnessOnlyHint says what the refusal means and what to do.
|
|
const HarnessOnlyHint = "OpenRouter serves this free model only to requests from an agent app it lists at openrouter.ai/apps, which magpie's own requests (a model test) are not; the model without :free is served to any request"
|
|
|
|
// HarnessOnly says whether an error body is OpenRouter's refusal of a
|
|
// request not from an agent app it lists.
|
|
func HarnessOnly(b []byte) bool {
|
|
return harnessOnly.Match(b) || bytes.Contains(b, []byte(HarnessOnlyHint))
|
|
}
|