Skip to content

BOUNTY: Convert the endpoints to a smart router like litellm does in python #286

Open

Description

@sandys

this bounty refers to the JS SDK only http://github.com/arakoodev/EdgeChains/tree/ts/JS/edgechains

we are super inspired by Litellm in python (and have a lot of respect for them) - https://github.com/BerriAI/litellm and we want to create a similar infrastructure in Edgechain.js using Typescript. We are hoping libraries like axios makes this easier.

the four features we want are these:

  1. load balance between multiple deployments. It picks the deployment which is below rate-limit and has the least amount of tokens used. (only openai, google palm and cohere needed). this includes basic reliability features (https://docs.litellm.ai/docs/routing#basic-reliability) like timeouts/retries/etc. you can use axios.interceptors.response.use to achieve these.
  2. streaming capability
  3. token usage - https://docs.litellm.ai/docs/completion/token_usage
  4. logging - https://docs.litellm.ai/docs/observability/callbacks (only sentry and posthog needed)

Once created, you will replace the Endpoint class with this new infrastructure (https://github.com/arakoodev/EdgeChains/blob/ts/JS/edgechains/lib/src/lib/endpoints/OpenAiEndpoint.ts)

project will be deemed complete when:

  1. you add testcases for all the features above.
  2. mock the openai, palm and cohere endpoints for testing. (you can take inspiration from here https://github.com/polly3d/mockai)
  3. you have deleted the current endpoint classes and replaced it with your new classes in all examples and testcases.

NOTE: the core of edgechains is the usage of jsonnet (https://jsonnet.org/) configuration to manage all kinds of config - like prompts, etc. we will prefer that as far as possible, we use jsonnet to configure this routing.

Activity

  1. sandys commented on Dec 2, 2023

    @sandys
    ContributorAuthor

    /bounty 200

  2. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    /attempt #286

    Options
  3. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    @sandys can i be assigned this issue?

  4. sandys commented on Dec 2, 2023

    @sandys
    ContributorAuthor

    @rajdip-b happy to.
    but first want to check if you understand what has to be achieved ? any doubts, etc ?

  5. guhitb commented on Dec 2, 2023

    @guhitb

    @rajdip-b Any interest in collaborating on this?

  6. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    @sandys As per my understanding, the main challenge is creating the load balancer in the endpoints of OpenAiEndpoint.ts. I was going through the references you mentioned and have a clarity over what needs to be implemented. I would have to do some further digging about the how's of the implementation, but yes, I feel I can definitely give it a shot!

    And not to mention, as and when issues come up, I will ping you about them.

  7. sandys commented on Dec 2, 2023

    @sandys
    ContributorAuthor

    @rajdip-b there are 4 capabilities needed (as mentioned in my original post). it is important that you look at all four, because the architecture will need to be inclusive.
    also, this architecture will REPLACE the current endpoint structure

  8. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    @guhitb, are you familiar with the project structure/implementation details? I would be happy to collaborate!

  9. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    @rajdip-b there are 4 capabilities needed (as mentioned in my original post). it is important that you look at all four, because the architecture will need to be inclusive. also, this architecture will REPLACE the current endpoint structure

    Yeah, of course, I understand that. For me, I feel the challenge would be implementing load balancing, hence mentioned that. As for the rest, I feel they can be done with lesser efforts than the former.

  10. sandys commented on Dec 2, 2023

    @sandys
    ContributorAuthor

    very well. assigned to @rajdip-b best wishes. please feel free to drop in to discord if u want to discuss anything quickly. https://discord.gg/Avsbume2

  11. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    very well. assigned to @rajdip-b best wishes. please feel free to drop in to discord if u want to discuss anything quickly. https://discord.gg/Avsbume2

    Discord is my go-to for discussion! Hopping in right now!

  12. guhitb commented on Dec 2, 2023

    @guhitb

    @rajdip-b Not yet, aside from browsing through the repo today. I don't have much experience with open source, but I'm sure I can help with mocks, logging, tests, etc. The load balancing part feels a little daunting though.

  13. rajdip-b commented on Dec 2, 2023

    @rajdip-b

    @rajdip-b Not yet, aside from browsing through the repo today. I don't have much experience with open source, but I'm sure I can help with mocks, logging, tests, etc. The load balancing part feels a little daunting though.

    Hey sure thing! We can pair up!

    Drop me a text on discord! _the_heisenberg

  14. 93 remaining items

  15. CrowAleksito commented on Nov 7, 2026

    @CrowAleksito

    Submitted PR #817 (#817) — all CI checks (js, changes) and CLA Assistant are green (MERGEABLE).

    Summary of what PR #817 delivers:

    • LiteLLM-inspired Smart Router (Router.ts): Load balances across OpenAI, Google PaLM/Gemini, and Cohere deployments (selecting below RPM/TPM rate limits with least tokens used), with timeout & exponential-backoff retry handling via �xios.interceptors.response.use and automatic failover.
    • First-class Jsonnet configuration (
      outer.jsonnet)
      : Configures deployments, rate limits, retries, and callbacks via Jsonnet (Router.fromJsonnetFile / Router.fromJsonnet).
    • Streaming, Token Usage & Observability (Logger.ts): Full ReadableStream SSE streaming, LiteLLM-style usage (prompt_tokens, completion_tokens, otal_tokens), and Sentry + PostHog success_callback / ailure_callback.
    • MockAI Offline Test Suite (MockLLM.ts,
      outer.test.ts) & Complete Migration
      : Deleted legacy endpoint classes (openai.ts, gemini.ts, llama.ts) and migrated all JS/edgechains examples, HydeSearchService, TestGenerator, and test suites (10/10 tests passing).
  16. flux-axiom commented on Nov 9, 2026

    @flux-axiom

    /attempt #286

    Submitted PR implementing the LiteLLM-style SmartRouter across OpenAI, Google PaLM, and Cohere deployments (least-tokens-used load balancing below rate limits, response interceptors, timeouts/retries, streaming, token usage accounting, Sentry & PostHog callbacks, and Jsonnet config support) with passing unit tests.

  17. KrazyArcher commented on Nov 10, 2026

    @KrazyArcher

    /attempt #286

  18. almagas commented on Nov 10, 2026

    @almagas

    /claim #286

  19. KrazyArcher commented on Nov 11, 2026

    @KrazyArcher

    /claim #286

    🚀 Complete Production-Ready Implementation in PR #839

    • PR Link: feat: implement LiteLLM-style smart router for endpoints (#286) #839
    • Architecture: Native zero-dependency LiteLLM-style SmartRouterEndpoint integrated directly into JS/edgechains/arakoodev/src/ai/src/index.ts (alongside existing OpenAI, GeminiAI, LlamaAI, and RetellAI modules) as well as JS/edgechains/lib/src/lib/endpoints/SmartRouterEndpoint.ts.
    • Key Features Implemented:
      • 4 Routing Strategies: round-robin, simple-shuffle, least-busy (in-flight tracking), and latency-based (EMA latency tracking).
      • Automatic Cross-Provider Failover & Exponential Backoff on 429 / 5xx / timeout errors.
      • Per-endpoint Health Cooldown tracking (cooldownUntil) + Model Fallback chains (fallbacks map).
      • Full support for chatCompletion, completion, generateEmbeddings, and streamCompletion (SSE).
    • Verification & Unit Tests:
      • node --test JS/edgechains/arakoodev/src/ai/src/tests/smartRouter.test.mjs -> 2/2 Passed ✅
      • All GitHub CI checks (CLA Assistant, PR Build / js, PR Build / changes) -> 100% Passed ✅

    💳 Settlement / Payout Wallets (USDC / Crypto)

    • Solana (USDC / SOL): 4Ch1arer4BF2ndVDq2pSRQdRfDQ8BNp7fg9tc3c5zc3Y
    • EVM (Polygon / Base / Arbitrum / ERC-20 / BSC): 0xde5e802f702446806a5f809e8f1f55a60214c991
  20. khuxaiphi-stack commented on Nov 12, 2026

    @khuxaiphi-stack

    /attempt #286

    Implementation Plan

    1. Implement SmartRouter in JS/edgechains/lib/src/lib/endpoints/ supporting load-balanced routing across OpenAI, Google PaLM, and Cohere deployments based on rate-limit window and lowest token usage.
    2. Add Axios response/error interceptors for automatic retries, exponential backoff, timeouts, and fallback deployment routing.
    3. Add streaming completion support, token usage calculation (tokenCounter / costPerToken), and Sentry + PostHog observability callbacks, with comprehensive unit tests.
  21. ItsMeSoumo commented on Nov 13, 2026

    @ItsMeSoumo

    /attempt #286

    Implementation Plan: LiteLLM Dynamic Smart Router for EdgeChains

    I would like to claim this bounty to implement the resilient smart router pattern using LiteLLM in the JS/TS SDK.

    Technical Architecture & Deliverables:

    1. Multi-Deployment Load Balancer:
      • Implement dynamic routing across LLM providers (OpenAI, Google PaLM, Cohere) tracking rate limits and active token usage.
      • Route traffic to whichever deployment is healthy, below rate limit, and has the lowest cumulative token load.
    2. Resilience & Interceptor Pipeline:
      • Integrate with Axios interceptors (axios.interceptors.response.use) for automatic retries, exponential backoff, and latency timeout triggers.
    3. Observability & Streaming:
      • Add streaming response handling, exact token counting, and telemetry callbacks (Sentry & PostHog).
      • Support Jsonnet configuration for prompt management and routing rules.
    4. Endpoint Migration & Tests:
      • Refactor OpenAiEndpoint.ts to use the new SmartRouter architecture.
      • Comprehensive test suite with mocked endpoints (OpenAI, PaLM, Cohere).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions