Skip to content

Conversation

@fran3cc
Copy link
Collaborator

@fran3cc fran3cc commented Jan 26, 2026

Related GitHub Issue

Closes: RooCodeInc#10962

Roo Code Task Context (Optional)

N/A

Description

This PR adds Keywords AI as a new LLM provider in Roo Code, integrating their OpenAI-compatible gateway API with optional observability controls.

Key Implementation Details:

  1. Provider Handler (src/api/providers/keywordsai.ts):

    • Created KeywordsAiHandler extending OpenAiHandler to leverage the OpenAI-compatible gateway
    • Injects disable_log: true into request body when logging is disabled via the getExtraRequestParams() hook
    • Sets custom header X-KeywordsAI-Source: RooCode-Extension for tracking
  2. Base Handler Enhancement (src/api/providers/openai.ts):

    • Added protected getExtraRequestParams() method to allow subclasses to inject provider-specific body parameters
    • This pattern enables Keywords AI (and future providers) to add custom parameters without duplicating the entire request flow
  3. Model Fetching (src/api/providers/fetchers/keywordsai.ts):

    • Implemented getKeywordsAiModels() to fetch available models from Keywords AI API
    • Integrated with the router models caching system
  4. Provider Settings (packages/types/src/provider-settings.ts):

    • Added keywordsaiSchema with keywordsaiApiKey, keywordsaiBaseUrl, and keywordsaiEnableLogging fields
    • Added keywordsai to provider types and model ID mappings
  5. UI Components (webview-ui/src/components/settings/providers/KeywordsAI.tsx):

    • Created settings UI with API key, base URL, and "Enable Logging" checkbox
    • Integrated with model picker using router models
  6. Model Selection Logic (webview-ui/src/components/ui/hooks/useSelectedModel.ts):

    • Added dedicated keywordsai case in switch statement to properly use router models
    • Follows the same pattern as other dynamic providers (openrouter, requesty, unbound, etc.)
  7. Type Fixes:

    • Added keywordsai: {} to RouterModels type and test mocks
    • Fixed TypeScript compilation errors to ensure check-types passes

Design Choices:

  • Used inheritance (KeywordsAiHandler extends OpenAiHandler) rather than composition to minimize code duplication
  • Gateway-only approach: Only implements the chat completions gateway with optional logging control, no tracing features
  • Consistent with existing dynamic provider patterns for maintainability

Test Procedure

Manual Testing Steps:

  1. Configuration:

    • Go to Settings → Providers → Keywords AI
    • Enter API key (or leave empty if using default)
    • Optionally configure base URL (defaults to https://api.keywordsai.co/api/)
    • Toggle "Enable Logging" checkbox
    • Click "Refresh Models" to fetch available models
  2. Model Selection:

    • Select Keywords AI as provider
    • Verify model picker shows available models from Keywords AI API
    • Select a model (e.g., gpt-4o)
  3. Chat Functionality:

    • Start a chat conversation
    • Verify requests are sent to Keywords AI gateway
    • Check that chat completions work correctly
  4. Logging Control:

    • With "Enable Logging" enabled: Verify requests include observability data
    • With "Enable Logging" disabled: Verify disable_log: true is sent in request body
  5. Type Checking:

    • Run pnpm check-types (or turbo check-types)
    • Verify no TypeScript errors

Testing Environment:

  • Node.js 20.19.2
  • VS Code Extension environment
  • Keywords AI API access (API key required)

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Add screenshots showing Keywords AI provider settings UI and model picker here if available.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required.

Documentation Needed:

  • Add Keywords AI to the list of supported providers on the Roo Code website/documentation
  • Document Keywords AI provider configuration steps (API key, base URL, enable logging)
  • Add Keywords AI to any provider comparison tables or feature lists

Note: Documentation updates should be made in the appropriate documentation repository/website. This PR only includes code changes.

Additional Notes

  • This implementation focuses on the gateway API only. Tracing features were explicitly excluded per requirements.
  • The getExtraRequestParams() pattern in OpenAiHandler can be reused by future providers that need to inject custom parameters.
  • Keywords AI uses the same model fetching pattern as other dynamic providers (openrouter, requesty, etc.) for consistency.

Get in Touch

.francccc0303

@fran3cc fran3cc merged commit 68a8064 into main Jan 26, 2026
@fran3cc fran3cc deleted the gateway branch January 26, 2026 04:32
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.

[ENHANCEMENT] Add Keywords AI as LLM provider with gateway API and observability

2 participants