-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Integration request from AIML API #7461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hugoaimlapi
wants to merge
15
commits into
nexu-io:main
Choose a base branch
from
aimlapi:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+428
−10
Open
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d994406
feat(aimlapi): add aimlapi.com as a BYOK chat provider
aimlapihello 8b4ca56
feat(aimlapi): surface aimlapi.com across the protocol maps
aimlapihello e1e9858
fix(aimlapi): default to the gpt-5.6-terra alias, not the -pro variant
aimlapihello a1e555b
Merge pull request #1 from aimlapi/feat/aimlapi-provider
Lookoff-AIMLAPI 8e54083
fix(aimlapi): show the aimlapi.com tab first in the BYOK picker
aimlapihello 507d099
Merge pull request #2 from aimlapi/feat/aimlapi-provider
Lookoff-AIMLAPI 59a19f3
fix: register aimlapi.com in KNOWN_PROVIDERS with the correct protocol
Lookoff-AIMLAPI 9c5cb92
Merge pull request #3 from aimlapi/add-aimlapi-known-provider
Lookoff-AIMLAPI ebb78da
fix(aimlapi): recognize aimlapi.com as a supported BYOK chat protocol
Lookoff-AIMLAPI 2f3a565
Merge pull request #4 from aimlapi/fix/aimlapi-byok-chat
Lookoff-AIMLAPI 973e7a7
fix(aimlapi): attribute the runtime that actually serves chat
aimlapihello 437a7b5
Merge pull request #5 from aimlapi/fix/aimlapi-opencode-attribution
Lookoff-AIMLAPI 7a01606
fix(aimlapi): wire the memory extractor and drop the duplicate chat r…
aimlapihello bf5bcd2
refactor(aimlapi): list the provider after the first-party ones
aimlapihello a90feec
fix(aimlapi): keep chat history across turns in BYOK OpenCode
aimlapihello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // aimlapi.com BYOK provider — shared identity + outbound header helper. | ||
| // | ||
| // aimlapi.com (https://aimlapi.com) is an OpenAI-wire-compatible aggregator: | ||
| // a single API key fronts ~900 models from many creators, routed by model name | ||
| // on the upstream side. Because the wire shape is identical to OpenAI's, the | ||
| // chat proxy, connection test and model discovery all reuse the OpenAI call | ||
| // shape — the ONLY thing that differs is the outbound headers, which is why | ||
| // every outbound call point funnels through `aimlapiHeaders()` rather than | ||
| // hand-building `Authorization` inline. | ||
| // | ||
| // The distinctive aimlapi.com detail is the attribution pair: aimlapi.com | ||
| // expects `X-AIMLAPI-Source` and `X-AIMLAPI-Partner-ID` on EVERY request it | ||
| // serves — inference, catalog and key checks alike, not just sign-up. Injecting | ||
| // them in one helper keeps the invariant "every aimlapi.com request carries our | ||
| // attribution" enforceable in one place instead of being re-derived at each | ||
| // call site; the aggregator's rebate accounting keys off exactly this, and a | ||
| // missing header means the request serves fine but is silently untagged. | ||
|
|
||
| /** | ||
| * Provisioned partner for this integration. Valid on both aimlapi.com's staging | ||
| * and production backends, so it ships compiled in and one build works against | ||
| * either — only the base URL differs. Overridable via `AIMLAPI_PARTNER_ID` for | ||
| * a staging-only test id. | ||
| */ | ||
| export const AIMLAPI_PARTNER_ID = 'part_9TWZWFsyMyNrBDEENq5JaU0r'; | ||
|
|
||
| /** | ||
| * `<channel>/<client>` — the channel is a small closed set (agent|mcp|web) and | ||
| * the client is this integration's registry slug. | ||
| */ | ||
| export const AIMLAPI_SOURCE = 'agent/open-design'; | ||
|
|
||
| /** | ||
| * Default base URL the daemon assumes when the BYOK form leaves the field | ||
| * blank. Kept here as the single source of truth so the chat proxy, model | ||
| * discovery and connection test all default to the same origin. | ||
| * | ||
| * Note the `/v1`: aimlapi.com's OpenAI-compatible surface lives there, while | ||
| * `/v2` on the same host is billing/usage only and 404s for chat completions. | ||
| */ | ||
| export const AIMLAPI_DEFAULT_BASE_URL = 'https://api.aimlapi.com/v1'; | ||
|
|
||
| function partnerId(): string { | ||
| return (process.env.AIMLAPI_PARTNER_ID || '').trim() || AIMLAPI_PARTNER_ID; | ||
| } | ||
|
|
||
| /** | ||
| * The attribution pair on its own (no auth). For any route that carries its own | ||
| * auth header — spread this alongside it so every aimlapi.com request, whatever | ||
| * the wire protocol, still carries attribution. | ||
| */ | ||
| export function aimlapiAttributionHeaders(): Record<string, string> { | ||
| return { | ||
| 'X-AIMLAPI-Source': AIMLAPI_SOURCE, | ||
| 'X-AIMLAPI-Partner-ID': partnerId(), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Build the outbound header set for an aimlapi.com request: Bearer auth plus | ||
| * the attribution pair. Callers spread the result into their `fetch` headers | ||
| * and may add `content-type` etc. on top. | ||
| */ | ||
| export function aimlapiHeaders(apiKey: string): Record<string, string> { | ||
| return { | ||
| authorization: `Bearer ${apiKey}`, | ||
| ...aimlapiAttributionHeaders(), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Origin of a configured base URL, for callers that need to reach a sibling | ||
| * path on the same host. Falls back to the default origin when the configured | ||
| * value is unusable, so a malformed setting degrades instead of throwing. | ||
| */ | ||
| export function aimlapiOriginFromBase(baseUrl: string | undefined | null): string { | ||
| const candidate = (baseUrl || '').trim() || AIMLAPI_DEFAULT_BASE_URL; | ||
| try { | ||
| return new URL(candidate).origin; | ||
| } catch { | ||
| return new URL(AIMLAPI_DEFAULT_BASE_URL).origin; | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.