feat: add Infron AI chat provider#3433
Open
meridah7 wants to merge 1 commit into
Open
Conversation
Adds Infron (https://infron.ai) as an aggregator provider for the puter-chat-completion driver, following the OpenRouter provider as reference per doc/contributing-apis.md. - OpenAI-compatible gateway at llm.onerouter.pro/v1 - Dynamic model catalog (kv-cached 15 min, authenticated fetch), filtered to chat-capable LLM entries - Bills the gateway-reported authoritative cost when present (usage: {include: true}); falls back to catalog per-token pricing - Registered as an aggregator so its aliases never shadow first-party providers - Offline unit tests (mocked SDK/axios against a real test server) plus an env-gated integration test
Collaborator
|
. |
Member
|
@meridah7 could you sign the CLA please |
ProgrammerIn-wonderland
self-requested a review
July 23, 2026 23:19
ProgrammerIn-wonderland
approved these changes
Jul 23, 2026
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.
What
Adds Infron as a provider for the
puter-chat-completiondriver, followingdoc/contributing-apis.mdand using the OpenRouter provider as the reference implementation (as suggested by the Puter team).Infron is an AI inference platform with an OpenAI-compatible gateway (
https://llm.onerouter.pro/v1) serving 400+ models across 100+ upstream inference providers.How it works
InfronProvidermirrorsOpenRouterProvider: OpenAI SDK pointed at the gateway, dynamic model catalog fromGET /v1/models(kv-cached for 15 minutes). Two deliberate differences, both driven by the gateway's actual API shape:pricingobject; prices are USD per million tokens (min_prompt_price/min_completion_price), converted to microcents per token (× 100). Non-chat catalog entries (image/video/embeddings/search) and display-only entries are filtered out viacategory_type/is_display_only.usage: { include: true }, which makes the gateway report an authoritativecost(USD) on the response. Like OpenRouter'susage.costbranch, that cost is billed as a singlebilledUsageline item with per-token costs zeroed. One wrinkle: Infron reportscostat the top level of the response rather than insideusage— non-streaming reads it off the spread completion, streaming merges it in via anindex_usage_from_stream_chunkdeviation. Ifcostis ever absent, metering falls back to catalog per-token pricing (cache reads billed at the full prompt rate there, so the fallback never under-bills).infron(apiKey+ optionalapiBaseUrl), added to theAGGREGATORSset so its aliases never shadow first-party providers in the model map — same treatment asopenrouterandtogether-ai.infron:<vendor>/<model>with the same alias scheme as OpenRouter. Default model:infron:deepseek/deepseek-v4-flash.Testing
InfronProvider.test.ts, 13 tests): same harness as the OpenRouter suite — realPuterServer+ liveMeteringService, OpenAI SDK and axios mocked at the module boundary. Covers construction/base-URL override, authenticated catalog fetch, kv caching, category filtering, price-unit conversion, request shape (prefix stripping,usage.include,stream_options), both metering branches (top-level cost and per-token fallback, non-stream and stream), and moderation.InfronProvider.integration.test.ts): env-gated onPUTER_TEST_AI_INFRON_API_KEY, exercises the real gateway; verified passing locally.src/backend/drivers/ai-chat/suite passes locally (428 tests).coston stream + non-stream, usage field names) were all verified against the live gateway while writing this, not assumed from docs.Security pass
providers.infron.apiKeyis configured.Happy to adjust anything to better match house conventions!