50/50 RevShare Integration: DeepCode & AIML API - #211
Open
hugoaimlapi wants to merge 3 commits into
Open
Conversation
AI/ML API is an OpenAI-compatible router over ~350 chat models, wired on the generic openai_compat path like Requesty and Forge (HKUDS#159). Attribution headers follow the OpenRouter/Requesty pattern but are keyed on the resolved base URL's host. Model discovery asks the directory for the chat surface only and reads the gateway's nested info metadata after the flat OpenRouter keys. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZwkQDQ6xQfwH8kikYJPNU
The registry spec is read via getattr(providers, spec.name), so a spec without the matching ProvidersConfig field is silently skipped everywhere — both halves are required. The new field has a default, so previously saved configs load unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZwkQDQ6xQfwH8kikYJPNU
…sing 19 tests: registry wiring pinned against OpenRouter/Requesty, header shape (the partner id fails silently when malformed, so its shape is asserted here), origin-scoped attribution, catalog request and nested-metadata parsing, and env hygiene. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZwkQDQ6xQfwH8kikYJPNU
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.
Hi! I'm Hugo from aimlapi.com — an AI aggregator that gives access to 1000+ models in one API, trusted by 400k+ users. We'd love to be available as a verified provider option inside DeepCode—so we went ahead and did all the technical work on our side. To build our partnership, we offer a 50/50 revenue share on all traffic from this integration.
Description
Why
AI/ML API is an OpenAI-compatible router over ~350 chat models, but DeepCode has no template for it, so today it can only be wired as a
customconnection — with no attribution on requests (unlike OpenRouter and Requesty), an unfiltered model directory (936 rows across image, video, speech and embedding endpoint families, of which only 353 are chat models a chat request accepts), and invented context windows: the gateway nests its numbers underinforather than publishing OpenRouter's flat keys, so every model falls through to the built-in 128k/8k fallback.This PR adds aimlapi.com as a first-class gateway template on the same generic
openai_compatpath as OpenRouter and Requesty — no new backend.Related Issues
None — new provider integration; no existing issue tracks it.
Changes Made
core/providers/registry.py+core/config.py: theaimlapiProviderSpec(env keyAIMLAPI_API_KEY, default basehttps://api.aimlapi.com/v1,openai_compatbackend, gateway with OpenRouter-stylevendor/modelids,supports_prompt_caching=True) and the matchingProvidersConfig.aimlapifield. Both halves are required — the config is read viagetattr(providers, spec.name), so a spec without a field is silently skipped. Same wiring as Requesty and Forge in feat(providers): add Requesty, MiniMax and Forge #159.core/providers/openai_compat.py:_DEFAULT_AIMLAPI_HEADERS(HTTP-Referer,X-Title,X-AIMLAPI-Source,X-AIMLAPI-Partner-ID) merged into the client's default headers by_uses_aimlapi_attribution()— the same mechanism as the OpenRouter and Requesty headers, with one deliberate difference: those helpers substring-match the base URL, which would also fire for a third-party proxy that merely fronts the gateway. Here the resolved base URL's host must beaimlapi.com/*.aimlapi.com, so DeepCode's partner identity never travels to someone else's endpoint. User-suppliedextra_headersstill win on a clash; no env vars are touched.core/providers/catalog_service.py: model discovery for this provider asks for the chat surface only (/models?type=openai%2Fchat-completions), and_parse_modelreads the gateway's nestedinfo.contextLength/info.outputMax/info.nameafter the flat OpenRouter keys — a provider that publishes both keeps winning at the top level.tests/test_aimlapi_provider.py: 19 tests — registry wiring pinned against OpenRouter/Requesty, header shape and origin scoping (the partner id fails silently when malformed: the gateway answers 200 and records the traffic as untagged, so its shape is asserted here rather than left to be noticed in production), catalog request and parsing, and env hygiene.How to Test
pytest tests/test_aimlapi_provider.py -q # 19 passedLive run:
Checklist
Additional Notes
Follows the existing OpenRouter/Requesty attribution pattern. Nothing in the agent loop or routing changes; previously saved connections load unchanged (the new
ProvidersConfigfield has a default). Verified against the live gateway: chat, tool calling and streaming return throughcore.config.make_llm_provider, andcache_controlmarkers come back withcached_tokensin usage, which is whysupports_prompt_cachingis set. No user-facing doc enumerates provider templates individually, so no documentation change is needed.