Skip to content

Add API connection detection for custom providers #32

Open
fengcunhan wants to merge 2 commits intoworkany-ai:devfrom
fengcunhan:dev
Open

Add API connection detection for custom providers #32
fengcunhan wants to merge 2 commits intoworkany-ai:devfrom
fengcunhan:dev

Conversation

@fengcunhan
Copy link

Add API connection detection for custom providers

cunhanfeng and others added 2 commits February 9, 2026 17:50
Add detection button to validate custom API provider configuration
before using it for AI agent tasks.

Features:
- Detection button in both "Add Provider" form and "Edit Provider" panel
- Validates baseUrl and apiKey by calling /v1/messages endpoint
- Visual feedback: green (success) or red (failure) button styling
- 60-second timeout for slow local models
- Error messages displayed below button for troubleshooting

Backend changes:
- POST /providers/detect endpoint for API validation
- Refactored providers routes with extracted constants and helper functions
- Added type definitions for all request/response bodies
- Global error handler for consistent error responses
- Extracted formatProviderMetadata() to reduce duplication

The detection uses minimal request payload (1 token, "OK" message)
to quickly verify API connectivity without consuming credits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add internationalization support for the API connection detection
feature introduced in the previous commit. This ensures proper
localization for both Chinese and English users.

Frontend changes:
- Added tt() interpolation support for dynamic error messages
- Replaced hardcoded Chinese text with translation keys
- Updated detect button labels (Detecting, Success, Failed)
- Localized validation messages and connection status

Backend changes:
- Standardized API error messages to English
- Changed response messages from Chinese to English

Translation keys added:
- detectConfig, detecting, success, failed
- connectionSuccess, connectionFailed
- connectionTimeout, networkError
- fillBaseUrlAndApiKey, connectionError

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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