Tencent/WeKnora · error
API key is required for Baidu provider
Error message
API key is required for Baidu provider
What it means
Returned by NewBaiduProvider when the WebSearchProviderParameters carry an empty APIKey. The Baidu AI Search API cannot be called without credentials, so provider construction fails fast — a configuration/sentinel guard, not a runtime fault.
Source
Thrown at internal/infrastructure/web_search/baidu.go:40
// Not configurable by tenants — prevents SSRF.
defaultBaiduWebSearchURL = "https://qianfan.baidubce.com/v2/ai_search/web_search"
defaultBaiduTimeout = 15 * time.Second
defaultBaiduResults = 5
maxBaiduResults = 50
maxBaiduQueryUnits = 72
)
// BaiduProvider implements web search using Baidu AI Search API.
type BaiduProvider struct {
client *http.Client
baseURL string
apiKey string
}
// NewBaiduProvider creates a new Baidu web search provider from parameters.
func NewBaiduProvider(params types.WebSearchProviderParameters) (interfaces.WebSearchProvider, error) {
if params.APIKey == "" {
return nil, fmt.Errorf("API key is required for Baidu provider")
}
client, err := NewSearchHTTPClient(defaultBaiduTimeout, params.ProxyURL)
if err != nil {
return nil, fmt.Errorf("create Baidu HTTP client: %w", err)
}
return &BaiduProvider{
client: client,
baseURL: defaultBaiduWebSearchURL, // Hardcoded — not tenant-configurable
apiKey: params.APIKey,
}, nil
}
// Name returns the provider name.
func (p *BaiduProvider) Name() string {
return "baidu"
}
// Search performs a web search using Baidu AI Search API.View on GitHub (pinned to 988cbb0330)
Solutions
- Configure the Baidu API key in the tenant's web search provider settings
- Pick a different search provider if no Baidu credentials are available
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/infrastructure/web_search/baidu.go:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/9305a97fa72902d1.
Report an issue: GitHub.