Skip to content

Conversation

TensorNull
Copy link

CometAPI Integration PR

Context

Added complete CometAPI integration to Kilo Code, providing users with access to 500+ AI models through CometAPI's unified interface. This integration includes dynamic model fetching, intelligent model filtering, and a comprehensive settings UI with debugging capabilities.

Implementation

Core Integration Components:

  1. Dynamic Model Fetching (src/api/providers/fetchers/cometapi.ts)

    • Implements real-time model fetching from CometAPI's /v1/models endpoint
    • Intelligent model filtering to exclude non-text generation models (image, video, audio, TTS)
    • Smart context window inference based on model name patterns
    • Graceful fallback to static models on API failures
  2. WebView Message Handler Integration

    • Updated webviewMessageHandler.ts to include CometAPI in router model fetching
    • Proper authentication and error handling for API requests
  3. UI Components and Hooks

    • Enhanced useSelectedModel hook with CometAPI parameter support
    • Updated useProviderModels hook to handle CometAPI models
    • Comprehensive CometAPI settings component with debugging UI
    • Real-time model status monitoring and error reporting
  4. Model Filtering Strategy

    • Filters out image generation models (DALL-E, Stable Diffusion, Flux, etc.)
    • Excludes TTS models (tts*), video generation (veo*, runway*, kling_*), audio generation (suno*), and MidJourney (mj_*) models
    • Maintains focus on text/code generation models only

Key Design Decisions:

  • Removed maxTokens field to avoid displaying inaccurate token limits (CometAPI doesn't provide this data)
  • Hybrid approach combining dynamic API models with static fallbacks
  • Extensive debugging UI for troubleshooting API integration issues
  • Smart model categorization based on naming patterns and known model families

Screenshots

image
before after
No Supports for CometAPI Now supports CometAPI with 500+ models including Claude, GPT-5, Qwen, Gemini, etc.
Limited model selection Filtered, curated list of text generation models only

How to Test

  1. Setup CometAPI Integration:

    • Go to Settings → API Providers
    • Select "CometAPI" from the provider dropdown
    • Enter your CometAPI key from https://api.cometapi.com/console/token
    • Optionally configure custom base URL if needed
  2. Verify Dynamic Model Loading:

    • With API key configured, you should see debug information showing "✅ Success" status
    • Debug panel should display the actual number of models fetched (typically 300-400 after filtering)
    • Model dropdown should populate with filtered text generation models
  3. Test Model Selection:

    • Select a model from the filtered list (e.g., "claude-3-5-sonnet-20241022", "qwen3-coder", "gpt-4o-mini")
    • Verify the selected model appears in the bottom-left corner of the main interface
    • Create a new task and confirm the selected CometAPI model is used
  4. Test Error Handling:

    • Try with an invalid API key - should show error status and fall back to static models
    • Try without network connection - should gracefully handle failures
  5. Verify Model Filtering:

    • Confirm that image generation models (DALL-E, Stable Diffusion) are not visible
    • Verify TTS, video generation (Runway, Kling), and audio models (Suno) are filtered out
    • Only text/code generation models should be available for selection

Get in Touch

Available for questions about this integration. The implementation includes extensive debugging capabilities and error handling to ensure smooth user experience and easy troubleshooting.

TensorNull and others added 13 commits August 13, 2025 21:32
- Implemented CometAPIHandler for managing API interactions.
- Created fetcher for retrieving models from CometAPI.
- Added tests for CometAPIHandler to ensure correct functionality.
- Updated API routing to include CometAPI as a provider option.
- Enhanced webview settings to support CometAPI configuration.
- Integrated CometAPI models into the existing model management system.
- Added validation for CometAPI API key and model ID.
feat: Add CometAPI integration with model fetching and handling
…et, and adjusted test cases to use the new default model description
feat: Add CometAPI integration with model fetching and handling
Copy link

changeset-bot bot commented Aug 14, 2025

⚠️ No Changeset found

Latest commit: 9b30e85

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@TensorNull TensorNull changed the title feat: Add CometAPI integration with model fetching and handling feat: Add CometAPI as a model provider integration, supporting model retrieval and processing. Aug 14, 2025
@TensorNull
Copy link
Author

TensorNull commented Aug 14, 2025

@chrarnoldus Perhaps this time it will work.😊
+1

@TensorNull TensorNull closed this Aug 17, 2025
@TensorNull TensorNull reopened this Aug 17, 2025
@TensorNull
Copy link
Author

Hello, @Juice10 @kevinvandijk @drakonen @beatlevic @mrubens
@saoudrizwan
I have update the PR to the lastest commits.
Please let me know if anything else is needed.

Best regards.

@TensorNull TensorNull closed this Sep 7, 2025
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.

1 participant