Skip to content

feat(ai,catalog): AIML API onboarding, attribution headers, and model-list metadata - #2

Merged
Lookoff-AIMLAPI merged 5 commits into
mainfrom
aimlapi-provider-rebased-2026-08-18
Aug 18, 2026
Merged

feat(ai,catalog): AIML API onboarding, attribution headers, and model-list metadata#2
Lookoff-AIMLAPI merged 5 commits into
mainfrom
aimlapi-provider-rebased-2026-08-18

Conversation

@Lookoff-AIMLAPI

Copy link
Copy Markdown
Member

Summary

  • Rebases Nikolay Grinko's aimlapi.com provider (5 commits) onto the now-current upstream main (this fork's main was 2,402 commits behind upstream, synced in chore: sync fork main with upstream can1357/oh-my-pi #1).
  • Adds a device-authorization "Get API key" login (RFC 8628) for the AIML API provider, surfaced first in /login as "aimlapi.com (1000+ models, one-click set up)", plus manual key paste as an alternative.
  • Sends X-AIMLAPI-Source + X-AIMLAPI-Partner-ID attribution headers on inference and model discovery.
  • Model discovery fetches pricing + modalities (real cost, input modalities, context/output limits, friendly names) instead of "Free"/text-only; chat models only, hottest first then alphabetical.
  • Base URL overridable via AIMLAPI_INFERENCE_URL, keyed into the model cache so switching environments serves a fresh list.

Rebase notes

Upstream had independently added a minimal, broken aimlapi provider stub in the meantime (packages/ai/src/registry/aimlapi.ts, plus a generic aimlApiModelManagerOptions in openai-compat.ts that references isLikelyAimlApiChatModelId — a function that doesn't exist anywhere in the codebase, i.e. was already non-functional on current upstream main). 3 conflicts resolved:

  • packages/ai/src/registry/registry.ts: upstream had inserted an unrelated new provider (aiandProvider) at the exact spot the old aimlApiProvider entry used to sit; Nikolay's commit moves aimlApiProvider to the top of the list (so it's "surfaced first in /login"). Resolved by keeping the move and leaving aiandProvider where upstream put it — checked for and confirmed no duplicate aimlApiProvider entry remains.
  • packages/catalog/src/provider-models/cache-provider-id.ts: pure "both sides added a new switch case" conflict (upstream added ollama, this commit adds aimlapi) — kept both.
  • packages/catalog/src/provider-models/openai-compat.ts: replaced upstream's minimal (and broken, per above) aimlApiModelManagerOptions entirely with this commit's full implementation, which is a strict superset (pricing/modality mapping, hottest-model ordering, attribution headers) and whose dependencies (getAimlApiCommonHeaders, createBundledReferenceMap, AIML_API_CHAT_COMPLETIONS_TYPE, etc.) were all already present/imported.

Test plan

  • bun run check:types (tsgo) — clean on packages/catalog, packages/ai, packages/coding-agent (the three packages this change touches)
  • bunx biome check on the 3 conflict-resolved files — no unused-import/dead-code issues
  • bun test packages/ai/test/aimlapi-login.test.ts packages/catalog/test/aimlapi-discovery.test.ts — could not run: this environment is missing the pi_natives native addon (needs a Bazel build), which fails identically on a clean upstream checkout with zero aimlapi changes (confirmed against packages/catalog/test/issue-2105-repro.test.ts), so it's a local-environment gap unrelated to this change, not a regression

ngrink and others added 5 commits August 18, 2026 16:58
…-list metadata

- Add a device-authorization "Get API key" login (RFC 8628) for the AIML API
  provider, surfaced first in /login as
  "aimlapi.com (1000+ models, one-click set up)".
- Send X-AIMLAPI-Source + X-AIMLAPI-Partner-ID attribution headers on inference
  and on model discovery.
- Model discovery now fetches pricing + modalities (via /v1/models?include=…):
  real cost, input modalities, context/output limits and friendly names are
  surfaced instead of "Free"/text-only; the list is chat (LLM) models only and
  ordered with featured models first, then the rest alphabetically.
- Make the AIML API base URL overridable via AIMLAPI_INFERENCE_URL and key the
  model cache by it, so switching environments serves a fresh model list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The AIML API defaultModel was a bare alias (gpt-5.5-2026-04-23) that never
matches AIML API's namespaced discovery ids (openai/gpt-5.5-2026-04-23), so the
provider default silently fell back to the first available model. Point it at
the real catalog id openai/gpt-5-5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The AIML API "Get API key" login now renders an API-key paste field
next to the device-authorization browser flow. Both run concurrently and
the first key wins: a user who already has a key can paste it (which
aborts polling), otherwise approving in the browser mints one.

When the browser flow wins it fills the visible paste field with the
minted key and shows a bold-accent "already generated" confirmation, via
a new optional `OAuthController.onPromptResolve(value, message)` callback
(forwarded in `AuthStorage.login`). Without a prompt surface the flow
degrades to a plain device-grant login.

Sign-in scene tweaks: auth instructions now render directly under the
login URL they reference (own `#authInstructions` block, blank-line
separated) instead of at the bottom; the paste field renders with no
placeholder; the auto-filled key and its confirmation line stay visible
until login teardown. Polling uses an abortable sleep so paste/cancel
stop it immediately instead of waiting out the interval.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A pasted key was returned unchecked, so a wrong key was stored and the
provider shown as "logged in" until the first real request 401'd. Now the
paste path shows "Validating API key..." and probes GET /v1/billing/balance
with the key (auth-required, non-inference, spends nothing, honors
AIMLAPI_INFERENCE_URL). A non-2xx fails login with
"aimlapi.com API key validation failed (<status>): <message>"; only a
valid key is accepted. The browser-minted key still skips validation.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the API response body from the login error so the one-line message
stays readable: "aimlapi.com API key validation failed (401)" instead of
appending the "create a key on the Billing page" blurb.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Lookoff-AIMLAPI
Lookoff-AIMLAPI merged commit db65bc2 into main Aug 18, 2026
5 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