Motivation
The original chatbox application was hardcoded to work exclusively with OpenAI's API. This limitation prevented users from leveraging other powerful AI providers like Anthropic's Claude or custom OpenAI-compatible endpoints. As the AI landscape evolves with multiple high-quality providers offering different capabilities and pricing models, users need the flexibility to choose their preferred AI service.
Transforming the chatbox into a universal multi-provider chat application enables users to:
- Switch between OpenAI, Anthropic Claude, and custom OpenAI-compatible APIs
- Dynamically fetch and select from available models for each provider
- Compare responses across different AI providers
- Avoid vendor lock-in and choose the best provider for their use case
This enhancement maintains backward compatibility while unlocking the full potential of modern AI services.
Current Behavior
The chatbox application is hardcoded to use OpenAI's API exclusively. The settings only allow configuration of an OpenAI API key and host, with no option to select different AI providers or their specific models.
Reproduction Steps:
- Open the chatbox application and navigate to Settings
- Observe: Only "API Key" and "API Host" fields are available, assuming OpenAI
- Attempt to use an Anthropic API key
- Observe: The application fails with "failed to fetch" errors because it's calling OpenAI endpoints with Anthropic authentication
- Check the code in
src/devtools/client.ts
- Observe: The endpoint is hardcoded to
/v1/chat/completions (OpenAI-specific) and model is hardcoded to gpt-3.5-turbo
Expected Behavior
Users should be able to select their AI provider (OpenAI, Anthropic Claude, or OpenAI-Compatible) from a dropdown in settings. When a provider is selected, the application should:
- Automatically set the appropriate default API endpoint for that provider
- Dynamically fetch available models from the provider's API
- Allow users to select from fetched models or enter a custom model name
- Route chat requests to the correct endpoint with provider-specific authentication and message formatting
Acceptance Criteria:
Verification
Manual Testing:
- Open the application and navigate to Settings
- Verify the "AI Provider" dropdown displays: OpenAI, Anthropic Claude, OpenAI-Compatible
- Select "OpenAI" and enter a valid OpenAI API key
- Verify the API host defaults to
https://api.openai.com
- Verify the model dropdown fetches and displays OpenAI models (gpt-4, gpt-3.5-turbo, etc.)
- Select a model and send a test chat message
- Verify the chat works correctly with OpenAI
Anthropic Provider Testing:
- Select "Anthropic Claude" from the provider dropdown
- Verify the API host automatically changes to
https://api.anthropic.com
- Enter a valid Anthropic API key
- Verify the model dropdown fetches and displays Anthropic models (claude-sonnet-4, claude-opus-3, etc.)
- Select a model and send a test chat message
- Verify the chat works correctly with Anthropic Claude
OpenAI-Compatible Testing:
- Select "OpenAI-Compatible" from the provider dropdown
- Enter a custom API endpoint (e.g.,
https://api.groq.com)
- Enter the corresponding API key
- Verify the model dropdown shows fallback models with option to enter custom model name
- Send a test chat message
- Verify the chat works with the custom endpoint
Error Handling:
- Enter an invalid API key and attempt to fetch models
- Verify a clear error message is displayed with a "Retry" button
- Attempt to send a chat message with invalid credentials
- Verify the error message includes the provider name (e.g.,
[anthropic] API Error: ...)
Migration Testing:
- If you have existing chatbox data with
openaiKey in settings
- Launch the updated application
- Verify the settings are automatically migrated to use
apiKey and provider: 'openai'
- Verify old chat sessions still work correctly
CORS Verification:
- Open DevTools (Cmd+Option+I) and check the Console tab
- Change provider to Anthropic and enter API key
- Verify no CORS errors appear when fetching models
- Verify console logs show:
[anthropic] Calling API: https://api.anthropic.com/v1/messages
- Send a chat message and verify streaming works without CORS errors
Submission
Download https://cap.so/ to record your screen (use Studio mode). Export as an mp4, and drag and drop into an issue comment below.
Guide to submitting pull requests: https://hackmd.io/@timothy1ee/Hky8kV3hlx
Motivation
The original chatbox application was hardcoded to work exclusively with OpenAI's API. This limitation prevented users from leveraging other powerful AI providers like Anthropic's Claude or custom OpenAI-compatible endpoints. As the AI landscape evolves with multiple high-quality providers offering different capabilities and pricing models, users need the flexibility to choose their preferred AI service.
Transforming the chatbox into a universal multi-provider chat application enables users to:
This enhancement maintains backward compatibility while unlocking the full potential of modern AI services.
Current Behavior
The chatbox application is hardcoded to use OpenAI's API exclusively. The settings only allow configuration of an OpenAI API key and host, with no option to select different AI providers or their specific models.
Reproduction Steps:
src/devtools/client.ts/v1/chat/completions(OpenAI-specific) and model is hardcoded togpt-3.5-turboExpected Behavior
Users should be able to select their AI provider (OpenAI, Anthropic Claude, or OpenAI-Compatible) from a dropdown in settings. When a provider is selected, the application should:
Acceptance Criteria:
/v1/modelsendpoint (with provider-specific authentication)/v1/chat/completions, Anthropic:/v1/messages)Authorization: Bearer, Anthropic:x-api-key+anthropic-version)max_tokensand separates system messages)[DONE], Anthropic:content_block_deltaevents)openaiKeyfield to genericapiKeyVerification
Manual Testing:
https://api.openai.comAnthropic Provider Testing:
https://api.anthropic.comOpenAI-Compatible Testing:
https://api.groq.com)Error Handling:
[anthropic] API Error: ...)Migration Testing:
openaiKeyin settingsapiKeyandprovider: 'openai'CORS Verification:
[anthropic] Calling API: https://api.anthropic.com/v1/messagesSubmission
Download https://cap.so/ to record your screen (use Studio mode). Export as an mp4, and drag and drop into an issue comment below.
Guide to submitting pull requests: https://hackmd.io/@timothy1ee/Hky8kV3hlx