feat(llm): add aimlapi.com as an LLM endpoint with partner attribution - #1
Open
Lookoff-AIMLAPI wants to merge 4 commits into
Open
feat(llm): add aimlapi.com as an LLM endpoint with partner attribution#1Lookoff-AIMLAPI wants to merge 4 commits into
Lookoff-AIMLAPI wants to merge 4 commits into
Conversation
EverOS reaches every model through the same OpenAI-protocol clients, so
an aimlapi.com key already works today by setting base_url alone. What
does not work is attribution: aimlapi.com credits the project that sent
the traffic only when the request carries partner headers, and a missing
header fails silently — the call succeeds, the credit is simply lost.
The headers cannot be pinned to the SDK layer, because the same client
class is what talks to OpenRouter, OpenAI, DeepInfra and vLLM. So the
helper is origin-scoped: it parses the configured base_url and returns
an empty mapping for any host that is not aimlapi.com, which is why the
LLM, multimodal and embedding clients can all call it unconditionally.
Matching on the parsed hostname at a dot boundary keeps a lookalike host
(api.aimlapi.com.example.net) from collecting headers meant for us, and
returning a fresh dict each call keeps callers from mutating a shared
constant. Where a client accepts only per-request options — the everalgo
LLMConfig passthrough — the headers ride extra_headers, which the openai
SDK forwards as headers rather than as body fields; for other providers
no key is added to the request at all, since some upstreams reject a
null-valued option outright.
Tests pin the partner id against ^part_[A-Za-z0-9]{1,64}$, because a
malformed id is accepted by the API and then earns nothing.
The shipped `[llm]` and `[multimodal]` model slugs are already spelled the way aimlapi.com spells them, so pointing EverOS at it is a base_url and key change with no model rewriting — worth saying out loud, because the docs currently read as if OpenRouter were a dependency rather than one choice of OpenAI-protocol endpoint. Both shipped default models were called live through the component/llm client path before this was written, structured-output path included. The multimodal caveat is recorded rather than papered over: the image parts EverOS sends carry `image_url.detail = null`, which aimlapi.com rejects with a 400 while OpenAI and OpenRouter accept it. Anyone who switches `[multimodal]` over would otherwise hit it with no explanation. `.env.example` is regenerated from the template it must match, per the `make docs-check` gate.
Leads the Quick Start with aimlapi.com instead of OpenRouter. This is a placement preference, not a correctness change: both endpoints spell the shipped model slugs identically, so the walkthrough works either way and the alternative stays one line below. Separated from the preceding commits so it can be dropped wholesale before the docs change is offered upstream, where choosing a default provider is the maintainers' call and not a contributor's. EverOS has no provider registry, list, or featured-badge mechanism, so there is nothing to reorder and no badge convention to follow — the Quick Start is the only place a provider is named prominently.
The placeholder part_everos was a readable stand-in chosen before the partner was registered. Registration mints the id server-side, so the real value is part_VxTyAUvoIVbl30dPrB7kbRZk. A wrong or unknown partner id is accepted with a 200 and silently not attributed, so this would not have surfaced at runtime.
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
Makes aimlapi.com a first-class OpenAI-protocol endpoint for EverOS.
EverOS has no LLM provider registry —
component/llm/client.pybuilds oneOpenAI-compatible client from
base_url, and everything (OpenRouter, OpenAI,vLLM, DeepInfra) goes through it. So an aimlapi.com key already worked before
this PR by setting
base_urlalone. Two things did not:when the request carries partner headers. A missing header fails silently —
the call succeeds and the credit is simply lost.
dependency rather than one choice of endpoint.
1.
feat(llm): attribute traffic sent to aimlapi.com—2d0ace6New
everos/component/utils/attribution.py. Four headers —X-AIMLAPI-Partner-ID,X-AIMLAPI-Source,HTTP-Referer,X-Title— withHTTP-Referer/X-Titlenaming EverOS, not the provider.The headers are origin-scoped, which is the whole design constraint here:
the same client class talks to every other provider, so the helper parses the
configured
base_urland returns{}for any host that is not aimlapi.com.Matching is on the parsed hostname at a dot boundary, so
api.aimlapi.com.example.netgets nothing. A freshdictis returned per call;no shared constant is handed out for mutation.
Wired at all three client construction sites:
component/llm/client.py([llm]+[multimodal])LLMConfig.extra = {"extra_headers": ...}— everalgo'sOpenAICompatClientsplatsconfig.extrainto the request, and the openai SDK forwardsextra_headersas headers, not body fields. Empty dict for every other provider, so no key is added to the request at all (some upstreams 400 on a null-valued option).component/llm/openai_provider.pyAsyncOpenAI(default_headers=...), merged into the SDK's own defaults rather than over them.component/embedding/openai_provider.pyTests (25 new): the partner id is asserted against
^part_[A-Za-z0-9]{1,64}$(a malformed id is accepted by the API and then earns nothing, silently);
every non-aimlapi host — OpenRouter, OpenAI, DeepInfra, a lookalike domain, a
proxy with our host in a query string — must yield an empty mapping; and each
construction site is checked to actually forward them, because a client built
without them still works, just unattributed.
2.
docs(config): document aimlapi.com as an LLM endpoint—81eb32fdocs/configuration.md,config.example.toml,config/default.toml,templates/env.template(and.env.example, whichmake docs-checkrequiresto match the template). The shipped
[llm]and[multimodal]model slugs arealready spelled the way aimlapi.com spells them, so this is a
base_url+ keychange with no model rewriting.
3.
chore(aimlapi): fork-only placement — do not send upstream—cb397ffLeads the README/QUICKSTART Quick Start with aimlapi.com. Separated so it can
be dropped wholesale before the docs commit is offered upstream — picking a
default provider is a maintainer call. EverOS has no provider registry, no
provider list, and no featured-badge convention, so there was nothing to
reorder and no badge mechanism to reuse; the provider-endpoints table in
docs/configuration.mdis alphabetical.Area
Verification
Both model ids shipped in the docs (
openai/gpt-4.1-mini,google/gemini-3-flash-preview) pass the catalog id-or-alias check and werecalled live. Catalog membership alone is not treated as proof in either
direction: the catalog is known to omit ids that work and to list at least one
that 404s. No model id was removed.
Known limitation — recorded, not papered over
[multimodal]image requests fail against aimlapi.com. everalgo'sImageUrlInner.detaildefaults toNoneandmodel_dump()emits it, so everyimage part goes out as
{"url": ..., "detail": null}, which aimlapi.com rejects:Isolated by direct probe with an otherwise identical, valid data-URI image:
detailomitted → 200'Red';detail: "auto"→ 200'Red';detail: null→ 400. OpenAI and OpenRouter accept the null. The serialisationlives in the
everalgodependency, not in this repo, so it is documented ratherthan worked around here. Text-only
[multimodal]calls are unaffected.Checklist
main..envfiles, dependency folders, or generated output.make docs-check).Notes for Reviewers
extra_headers-through-LLMConfig.extraroute is the only way to attachheaders without forking
everalgo; it is worth a look, since a futureeveralgo release could start validating
extraas body-only.component/llm/factory.py/OpenAIProviderare currently referenced only bytheir own unit test — the live path is
client.py→everalgo.build_client.Both were wired anyway so the exported public surface behaves consistently.
max_tokensdoes not reliably bound reasoning tokens on every upstream, so itshould not be presented anywhere as a cost bound. Observed here:
google/gemini-3-flash-previewwithmax_tokens: 16returns HTTP 200 whosechoices[0]has nomessagekey at all (onlyfinish_reason: "length"),and a
usageobject with nocompletion_tokens. everalgo's_chat_createguards
choicesbeing empty but not a choice without amessage.By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.