feat(ai,catalog): AIML API onboarding, attribution headers, and model-list metadata - #2
Merged
Merged
Conversation
…-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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main(this fork's main was 2,402 commits behind upstream, synced in chore: sync fork main with upstream can1357/oh-my-pi #1)./loginas "aimlapi.com (1000+ models, one-click set up)", plus manual key paste as an alternative.X-AIMLAPI-Source+X-AIMLAPI-Partner-IDattribution headers on inference and model discovery.AIMLAPI_INFERENCE_URL, keyed into the model cache so switching environments serves a fresh list.Rebase notes
Upstream had independently added a minimal, broken
aimlapiprovider stub in the meantime (packages/ai/src/registry/aimlapi.ts, plus a genericaimlApiModelManagerOptionsinopenai-compat.tsthat referencesisLikelyAimlApiChatModelId— a function that doesn't exist anywhere in the codebase, i.e. was already non-functional on current upstreammain). 3 conflicts resolved:packages/ai/src/registry/registry.ts: upstream had inserted an unrelated new provider (aiandProvider) at the exact spot the oldaimlApiProviderentry used to sit; Nikolay's commit movesaimlApiProviderto the top of the list (so it's "surfaced first in/login"). Resolved by keeping the move and leavingaiandProviderwhere upstream put it — checked for and confirmed no duplicateaimlApiProviderentry remains.packages/catalog/src/provider-models/cache-provider-id.ts: pure "both sides added a new switch case" conflict (upstream addedollama, this commit addsaimlapi) — kept both.packages/catalog/src/provider-models/openai-compat.ts: replaced upstream's minimal (and broken, per above)aimlApiModelManagerOptionsentirely 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 onpackages/catalog,packages/ai,packages/coding-agent(the three packages this change touches)bunx biome checkon the 3 conflict-resolved files — no unused-import/dead-code issuesbun test packages/ai/test/aimlapi-login.test.ts packages/catalog/test/aimlapi-discovery.test.ts— could not run: this environment is missing thepi_nativesnative addon (needs a Bazel build), which fails identically on a clean upstream checkout with zero aimlapi changes (confirmed againstpackages/catalog/test/issue-2105-repro.test.ts), so it's a local-environment gap unrelated to this change, not a regression