micro/go-micro · error
unknown provider: %s
Error message
unknown provider: %s
What it means
During flow Register, the ai.New factory returned nil because the configured Provider name is not recognized by the AI package. The flow has no model and cannot operate, so registration fails immediately with the offending provider string.
Source
Thrown at flow/flow.go:138
// A flow that dispatches to an agent doesn't run its own model — the
// agent is the engine. Otherwise, set up the augmented LLM.
if f.opts.Agent == "" {
var modelOpts []ai.Option
if f.opts.APIKey != "" {
modelOpts = append(modelOpts, ai.WithAPIKey(f.opts.APIKey))
}
if f.opts.Model != "" {
modelOpts = append(modelOpts, ai.WithModel(f.opts.Model))
}
if f.opts.BaseURL != "" {
modelOpts = append(modelOpts, ai.WithBaseURL(f.opts.BaseURL))
}
modelOpts = append(modelOpts, ai.WithTools(f.toolSet))
f.model = ai.New(f.opts.Provider, modelOpts...)
if f.model == nil {
return fmt.Errorf("unknown provider: %s", f.opts.Provider)
}
}
if f.opts.TriggerTopic != "" {
sub, err := br.Subscribe(f.opts.TriggerTopic, func(p broker.Event) error {
data := string(p.Message().Body)
ctx := ai.WithRunInfo(context.Background(), ai.RunInfo{Dispatch: "broker", Trigger: f.opts.TriggerTopic})
if err := f.Execute(ctx, data); err != nil {
f.log.Logf(logger.ErrorLevel, "Flow %s failed: %v", f.name, err)
}
return nil
})
if err != nil {
return fmt.Errorf("subscribe to %s: %w", f.opts.TriggerTopic, err)
}
f.sub = sub
f.log.Logf(logger.InfoLevel, "Flow %s subscribed to %s", f.name, f.opts.TriggerTopic)
View on GitHub (pinned to 24529f1404)
Solutions
- Check the ai package docs for supported provider strings and fix the Options.Provider value (e.g. "openai", "anthropic").
- Print/inspect the config value feeding f.opts.Provider for typos or trailing whitespace.
- Register a custom provider via the ai package's registry if you need a non-builtin provider.
- If a provider was removed in a library update, pin the previous version or migrate to a supported one.
Example fix
// before
f, _ := flow.New("myflow", flow.Provider("OpenAI"))
// after
f, _ := flow.New("myflow", flow.Provider("openai")) Defensive patterns
Strategy: validation
Validate before calling
supported := map[string]bool{"openai": true, "anthropic": true}
if !supported[strings.ToLower(cfg.Provider)] {
return fmt.Errorf("unsupported provider %q; must be one of openai, anthropic", cfg.Provider)
} Type guard
func providerKnown(p string) bool { return ai.New(p) != nil } Try / catch
if err := f.Register(ctx); err != nil {
var up *fmt.Errorf
if strings.Contains(err.Error(), "unknown provider") {
log.Fatalf("fix provider name in config: %v", err)
}
return err
} Prevention
- Centralize the provider whitelist and validate config at startup.
- Use lowercase canonical provider names everywhere.
- Add a config schema/linter that checks provider values against the compiled ai package.
When it happens
Trigger: Creating a flow with Options.Provider set to a value ai.New does not support (typo like "open-ai", unsupported provider like "mistral" in this version, or empty casing mismatch).
Common situations: Typos in provider names; upgrading/downgrading the library so a provider was added or removed; environment-specific config files pointing at providers not compiled into the build.
Related errors
- flow: LLMOptimizer requires a model
- ai model is nil
- flow: LLMOptimizer returned an empty prompt
- discover tools: %w
- flow: UntilLLM requires a flow model (set Provider/APIKey)
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/0d801904ebbc94e2.
Report an issue: GitHub.