Skip to content

feat(provider): add FastRouter as an AI provider#7969

Closed
jatingomnet wants to merge 3 commits into
Kilo-Org:mainfrom
jatingomnet:fastrouter_integration
Closed

feat(provider): add FastRouter as an AI provider#7969
jatingomnet wants to merge 3 commits into
Kilo-Org:mainfrom
jatingomnet:fastrouter_integration

Conversation

@jatingomnet
Copy link
Copy Markdown

Summary
This PR adds support for FastRouter as an AI provider. This allows Kilo Code users to utilize FastRouter's unified routing to 500+ models via a single API key and endpoint.

Scope
New Feature: Integration of a new AI provider.

Changes
Provider Logic: Implemented FastRouter in packages/opencode/src/core/providers/fastrouter.ts.

Hardcoded base URL: https://go.fastrouter.ai/api/v1.

Implemented as an OpenAI-compatible provider to support native streaming and tool-calling.

Dynamic Model Fetching: Updated packages/opencode/src/shared/models.ts to include an API fetch that dynamically retrieves the latest supported models from FastRouter, ensuring the model list stays current without manual updates.

Configuration Schema: Updated packages/opencode/src/shared/providers.ts to register FastRouter and define the required FASTROUTER_API_KEY credential field.

Documentation: Created new documentation file at packages/kilo-docs/pages/ai-providers/fastrouter.md detailing setup and usage.

Verification & Testing
I have conducted end-to-end testing in a local environment:

CLI Testing: Successfully initialized sessions and performed agentic coding tasks using kilo.

Server Testing: Ran kilo serve locally; verified that the background server correctly routes requests to FastRouter and handles SSE (Server-Sent Events) for streaming.

Style Compliance: Followed the project's signature style (Bun runtime, TypeScript, early-return patterns, and no any types).

Comment thread packages/opencode/src/provider/models.ts
Comment thread packages/opencode/src/provider/model-cache.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Mar 31, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

No active issues remain on commentable diff lines in the current review. One warning was found on an unchanged line inside a touched file, so it is listed below instead of as an inline comment.

Fix these issues in Kilo Cloud

Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/opencode/src/provider/model-cache.ts 215 fetchApertisModels() marks every Apertis model as supporting attachments and image input even though the /models response only provides IDs and ownership data, so the UI can advertise image/file support for text-only models and send requests that fail at inference time.
Files Reviewed (18 files)
  • .github/actions/setup-bun/action.yml
  • .github/workflows/close-issues.yml
  • .github/workflows/nix-hashes.yml
  • .github/workflows/publish.yml
  • .github/workflows/test.yml
  • .changeset/README.md
  • .changeset/config.json
  • package.json
  • .gitignore
  • .opencode/.gitignore
  • packages/app/src/hooks/use-providers.ts
  • packages/opencode/src/provider/model-cache.ts - 1 issue
  • packages/opencode/src/provider/models.ts
  • packages/opencode/src/provider/provider.ts
  • packages/opencode/src/provider/transform.ts
  • packages/kilo-docs/pages/ai-providers/fastrouter.md
  • packages/kilo-docs/pages/ai-providers/index.md
  • packages/kilo-docs/pages/code-with-ai/platforms/cli-reference.md

Reviewed by gpt-5.4-20260305 · 2,012,029 tokens

@jatingomnet
Copy link
Copy Markdown
Author

there was a new provider integration in the main branch, there were merge conflicts coming up here, so i have updated the current branch for resolving the same

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode anything else i need to do from my end to move the process forward?, here i see awaiting workflow approval, want to make sure nothing is left from my end.

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus it seems like there is something related to apertis merge recently that is breaking the workflow, this is something i need to fix here?

@jatingomnet
Copy link
Copy Markdown
Author

jatingomnet commented Apr 2, 2026

Line 196 - models.ts
that is not passing the typecheck, merged from apertis integration as provider
@chrarnoldus @marius-kilocode

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode made the fixes, ran bun turbo typecheck and bun turbo test, everything is passing, can we do the review again please

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode can we start the workflows on this now before some other merge in the main repository creates conflicts here, i do apologise for multiple such requests.

}
const priorFr = providers["fastrouter"]
const snapshotModels = priorFr?.models && Object.keys(priorFr.models).length > 0 ? priorFr.models : {}
let frModels = await ModelCache.fetch("fastrouter").catch(() => ({}))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: FastRouter models are fetched even when the provider is disabled

ModelsDev.get() already skips Kilo's dynamic fetch when enabled_providers excludes it or disabled_providers contains it, but this block still always awaits ModelCache.fetch("fastrouter"). That means CLI/TUI startup can still spend up to the FastRouter timeout on a provider the user explicitly disabled or never enabled. Please gate this fetch behind the same provider-allowed check so disabled providers don't add avoidable startup latency.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed now

@jatingomnet
Copy link
Copy Markdown
Author

@marius-kilocode @chrarnoldus can we rerun this workflow please

@jatingomnet
Copy link
Copy Markdown
Author

@marius-kilocode @chrarnoldus the only check failing was opencode annotations, can we please run this flow again and check whether my changes has anything to do with this workflow failure or these are upstream changes.

@jatingomnet
Copy link
Copy Markdown
Author

@marius-kilocode @chrarnoldus the only check failing was pretty change, i have fixed this in my local and verified other tests as well. can we run the worflows again, apologies for inconvenience caused.

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode all workflows passed, can we begin with the review and integration

@jatingomnet jatingomnet force-pushed the fastrouter_integration branch from f454278 to 83d19bb Compare April 14, 2026 09:36
@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode handled the merge conflicts, ran the tests in local on CLI and using api call, also confirmed with bun turbo typecheck, can we please start the workflows for the same

Add FastRouter as a new AI provider with dynamic model fetching,
API key auth, and smart routing support.

Made-with: Cursor
@jatingomnet jatingomnet force-pushed the fastrouter_integration branch from 83d19bb to 38b92c4 Compare April 14, 2026 10:33
@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode can we run the workflows again, but one thing - "bun turbo test" is failing on main branch as well, can you please take that into consideration

@jatingomnet
Copy link
Copy Markdown
Author

@chrarnoldus @marius-kilocode seeing the same failure with the main branch, is there something i am missing here?

@johnnyeric
Copy link
Copy Markdown
Contributor

johnnyeric commented May 8, 2026

Thank you for this contribution! Adding a new provider integration is a big task, and we really appreciate you taking the time to build out FastRouter support. Community contributions like this are what keep the project growing.

Before going further, I want to share an alternative path that's usually a better fit for new providers.

The plugin path (recommended). Ship the integration as an OpenCode plugin, a standalone npm package users install via "plugin": ["your-pkg@latest"] in opencode.json.
The code you've already written here is essentially the same; it just lives in your own package. Reference example: https://github.com/jenslys/opencode-gemini-auth (that one even handles OAuth — an API-key-based provider like FastRouter is simpler).

Otherwise, to help us get this merged and ensure the integration is well-supported moving forward, please review and complete the following checklist:

  • Maintenance: Please specify who will be the maintenance contact for this provider.
  • Kilo Gateway: Please also submit a corresponding PR to add this provider to the Kilo Gateway.
  • Community: Please consider joining Kilo's Discord community (if you haven't already) and encourage your users to join as well!

Next Steps: Once you've checked off these items and linked the Kilo Gateway PR, leave a comment here so we know it's ready for a final review. If you get stuck or have any questions, just let us know - we are happy to help!

@jatingomnet
Copy link
Copy Markdown
Author

Thank you for this contribution! Adding a new provider integration is a big task, and we really appreciate you taking the time to build out FastRouter support. Community contributions like this are what keep the project growing.

Before going further, I want to share an alternative path that's usually a better fit for new providers.

The plugin path (recommended). Ship the integration as an OpenCode plugin, a standalone npm package users install via "plugin": ["your-pkg@latest"] in opencode.json. The code you've already written here is essentially the same; it just lives in your own package. Reference example: https://github.com/jenslys/opencode-gemini-auth (that one even handles OAuth — an API-key-based provider like FastRouter is simpler).

Otherwise, to help us get this merged and ensure the integration is well-supported moving forward, please review and complete the following checklist:

  • Maintenance: Please specify who will be the maintenance contact for this provider.
  • Kilo Gateway: Please also submit a corresponding PR to add this provider to the Kilo Gateway.
  • Community: Please consider joining Kilo's Discord community (if you haven't already) and encourage your users to join as well!

Next Steps: Once you've checked off these items and linked the Kilo Gateway PR, leave a comment here so we know it's ready for a final review. If you get stuck or have any questions, just let us know - we are happy to help!

the master branch has seen a lot of changes during this time, will do a fresh work considering your comments

@jatingomnet
Copy link
Copy Markdown
Author

@johnnyeric #10207, this is the new PR with the suggested changes
also the PR for gateway - Kilo-Org/cloud#3226, please check and take action

thank you

@jatingomnet
Copy link
Copy Markdown
Author

closing this PR now

@jatingomnet
Copy link
Copy Markdown
Author

opened another PR for the same - #10207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants