siyuan-note/siyuan · error
provider not found
Error message
provider not found
What it means
Returned by resolveAIProvider in kernel/api/ai.go, which backs POST /api/ai/chatGPT and /api/ai/chatGPTWithAction. When the request body has no inline providerConfig object, the kernel reads arg["provider"] as a string ID and scans the configured providers in model.Conf.AI.Providers. If no configured provider has exactly that ID, the API envelope returns code -1 with this message.
Source
Thrown at kernel/api/ai.go:68
}
if strings.TrimSpace(provider.BaseURL) == "" {
return nil, errors.New("provider base URL is required")
}
ai := &conf.AI{Providers: []*conf.Provider{provider}}
ai.Normalize()
if len(ai.Providers) != 1 {
return nil, errors.New("invalid provider config")
}
return ai.Providers[0], nil
}
providerID, _ := arg["provider"].(string)
for _, provider := range model.Conf.AI.Providers {
if provider != nil && provider.ID == providerID {
return provider, nil
}
}
return nil, errors.New("provider not found")
}
func chatGPT(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
var msg string
if !util.ParseJsonArgs(arg, ret, util.BindJsonArg("msg", &msg, true, true)) {
return
}
ret.Data = model.ChatGPT(msg)
}
View on GitHub (pinned to afa823b6b4)
Solutions
- Pass the exact provider id from the current workspace's AI configuration (Settings - AI, or read the configured provider list) in the provider field
- Omit provider and pass a full inline providerConfig object with baseURL, model and API key, which the kernel validates and normalizes itself
- If no provider is configured at all, add one in Settings - AI before calling the chat endpoints
- Confirm you are attached to the same workspace where the provider was configured (model.Conf.AI.Providers is per-workspace)
Example fix
// before
fetchPost('/api/ai/chatGPT', { input: msg, provider: 'gpt' }); // stale/hand-written id -> "provider not found"
// after
const providers = await fetchGet('/api/ai/getConfigs'); // read configured ids
const id = providers.ai.providers[0]?.id;
if (!id) { /* configure a provider first */ }
fetchPost('/api/ai/chatGPT', { input: msg, provider: id }); Defensive patterns
Strategy: validation
Validate before calling
const cfg = await fetchGet('/api/ai/getConfigs');
const ids = new Set((cfg.data.ai.providers || []).map(p => p.id));
if (!ids.has(providerId)) {
throw new Error(`provider [${providerId}] not configured`);
}
await fetchPost('/api/ai/chatGPT', { input, provider: providerId }); Type guard
function isConfiguredProviderId(id: string, providers: { id: string }[]): boolean {
return providers.some(p => typeof p?.id === 'string' && p.id === id);
} Try / catch
// after fetchPost, inspect the envelope
if (res.code === -1 && res.msg === 'provider not found') {
const fresh = await fetchGet('/api/ai/getConfigs'); // re-sync provider ids and retry once with a valid id
} Prevention
- Fetch the provider list from the same workspace right before the call instead of hard-coding ids
- Treat provider ids as per-workspace state; refresh them after settings changes or workspace switches
- Prefer inline providerConfig for programmatic one-off calls — it bypasses id lookup entirely
When it happens
Trigger: POST /api/ai/chatGPT with a "provider" field that is empty, misspelled, or refers to a provider deleted from Settings - AI; sending neither "providerConfig" nor a valid "provider"; sending a provider id that belongs to a different workspace or profile than the running kernel.
Common situations: The AI provider list was reset or reconfigured and a plugin still sends the old provider id; fresh install where no AI provider is configured yet; multiple providers configured but the request omits the provider field entirely; copying a request body between test and production workspaces with different provider ids.
Related errors
- provider base URL is required
- invalid provider config
- unknown cloud provider [%d]
- invalid provider [%d]
- get block failed: %s
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/5f3d92f4bc66a73d.
Report an issue: GitHub.