{"record":{"id":"0829b742af31c006","repo":"dagger/dagger","slug":"provider-q-not-configured-run-dagger-llm-add-ke","errorCode":null,"errorMessage":"provider %q not configured, run 'dagger llm add-key %s' first","messagePattern":"provider %q not configured, run 'dagger llm add-key (.+?)' first","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/dagger/llm_config.go","lineNumber":647,"sourceCode":"var llmSetDefaultCmd = &cobra.Command{\n\tUse:   \"set-default <provider> [model]\",\n\tShort: \"Set default provider and optionally model\",\n\tArgs:  cobra.RangeArgs(1, 2),\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tprovider := args[0]\n\n\t\tcfg, err := llmconfig.Load()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif cfg == nil {\n\t\t\treturn fmt.Errorf(\"no LLM configuration found, run 'dagger llm setup' first\")\n\t\t}\n\n\t\t// Verify provider exists\n\t\tproviderCfg, ok := cfg.LLM.Providers[provider]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"provider %q not configured, run 'dagger llm add-key %s' first\",\n\t\t\t\tprovider, provider)\n\t\t}\n\n\t\tcfg.LLM.DefaultProvider = provider\n\t\tif len(args) > 1 {\n\t\t\tcfg.LLM.DefaultModel = args[1]\n\t\t} else {\n\t\t\t// Don't carry the previous provider's model over: it would be\n\t\t\t// exported as this provider's model and prefix routing could send\n\t\t\t// requests back to the old provider. Prefer the provider's own\n\t\t\t// configured model, then its catalog default; otherwise clear it.\n\t\t\tmodel := providerCfg.Model\n\t\t\tif model == \"\" {\n\t\t\t\tmodel = llmconfig.DefaultModelForProvider(provider)\n\t\t\t}\n\t\t\tcfg.LLM.DefaultModel = model\n\t\t}\n","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/internal/cmd/dagger/llm_config.go#L629-L665","documentation":"`dagger llm use <provider>` loaded a config file but the requested provider has no entry in [llm.providers], meaning no API key/credentials were ever stored for it. The command refuses to make it the default without configuration.","triggerScenarios":"`dagger llm use <name>` where <name> is absent from cfg.LLM.Providers (llm_config.go:647): typo in provider name, key never added via `dagger llm add-key`, provider removed earlier with `dagger llm remove-key`, or a different config file in scope via DAGGER_CONFIG.","commonSituations":"Using a provider name that differs from the alias used at add-key time; switching machines where the key wasn't migrated; after removing the key; CI environment missing the config with keys.","solutions":["Run `dagger llm add-key <provider>` first, then `dagger llm use <provider>`","Verify the exact provider name against [llm.providers] in the config file","Check DAGGER_CONFIG points at the config that actually holds the key","Re-add credentials if the provider entry was removed previously"],"exampleFix":"// before (shell)\ndagger llm use anthropic   # key never added\n// after (shell)\ndagger llm add-key anthropic\ndagger llm use anthropic","handlingStrategy":"validation","validationCode":"cfg, err := llmconfig.Load()\nif err != nil { return err }\nif cfg == nil { return errors.New(\"no config\") }\nif _, ok := cfg.LLM.Providers[provider]; !ok {\n    return fmt.Errorf(\"provider %q not configured; run 'dagger llm add-key %s' first\", provider, provider)\n}","typeGuard":"func providerReady(cfg *llmconfig.Config, name string) bool {\n    if cfg == nil { return false }\n    p, ok := cfg.LLM.Providers[name]\n    return ok && (p.APIKey != \"\" || p.AuthToken != \"\")\n}","tryCatchPattern":"if _, ok := cfg.LLM.Providers[provider]; !ok {\n    return fmt.Errorf(\"provider %q not configured, run 'dagger llm add-key %s' first\", provider, provider)\n}","preventionTips":["Always `dagger llm add-key <provider>` before `dagger llm use <provider>`","Use identical provider aliases across add-key/use/remove-key","After remove-key, re-add before switching back to that provider","Sync the config (with keys) when moving between machines"],"tags":["cli","config","llm"],"backgroundTag":"provider-not-configured","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}