BerriAI/litellm · error · ValueError
api_base is required in generic_prompt_config
Error message
api_base is required in generic_prompt_config
What it means
prompt_initializer raises ValueError when litellm_params.api_base is falsy while initializing a prompt from a generic prompt-management API. Generic prompt management fetches prompts over HTTP from a user-supplied base URL, so api_base is mandatory whenever a prompt_id/prompt_spec is used with a generic provider.
Solutions
- Add api_base to your generic_prompt_config, e.g. api_base: https://prompts.internal.example.com.
- Confirm it sits at the level the code reads (litellm_params of the prompt config), not under a nested provider block.
- Also set api_key if the prompt API requires auth.
- Check for empty-string api_base from templated configs — falsy values fail.
Example fix
# before
litellm.global_generic_prompt_config = {'api_key': 'sk-...'}
# after
litellm.global_generic_prompt_config = {'api_base': 'https://prompts.internal.example.com', 'api_key': 'sk-...'} Defensive patterns
Strategy: validation
Validate before calling
if not litellm_params.api_base:
raise ValueError('generic_prompt_config requires api_base (the prompt API URL)') Type guard
def prompt_config_has_api_base(prompt_config: dict) -> bool:
return bool(prompt_config.get('api_base')) Try / catch
try:
prompt_initializer(litellm_params, prompt_spec)
except ValueError as e:
if 'api_base' in str(e):
raise ConfigError('Add api_base to generic_prompt_config') from e
raise Prevention
- Validate generic_prompt_config keys at proxy startup, not on first request.
- Include api_base and api_key in every generic_prompt_config template.
When it happens
Trigger: Routing a completion with a prompt_id and a provider marked as generic prompt management while prompt_config/generic_prompt_config lacks api_base; setting api_key but not api_base in the prompt config; the api_base key nested in the wrong section of config.yaml.
Common situations: Wiring LiteLLM to an internal prompt-management service and forgetting the URL; copy-pasting a generic_prompt_config example that only shows api_key; config structured for a built-in prompt provider (which needs no api_base) then switching to generic without adding it.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- BitBucket configuration not found. Please set…
- Cannot set prompt_directory when working with…
- Either prompt_directory or prompt_data must be set before…
- Gitlab configuration not found. Please set…
- prompt_id is required for Prompt Management Base class
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/80126977ac105c3c.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/generic_prompt_management/__init__.py:43
- api_base: Base URL for the API
- api_key: Optional API key for authentication
- timeout: Request timeout in seconds (default: 30)
"""
import litellm
litellm.global_generic_prompt_config = config
def prompt_initializer(litellm_params: "PromptLiteLLMParams", prompt_spec: "PromptSpec") -> "CustomPromptManagement":
"""
Initialize a prompt from a generic prompt management API.
"""
prompt_id: Final = getattr(litellm_params, "prompt_id", None)
api_base: Final = litellm_params.api_base
api_key: Final = litellm_params.api_key
if not api_base:
raise ValueError("api_base is required in generic_prompt_config")
provider_specific_query_params: Final = litellm_params.provider_specific_query_params
try:
generic_prompt_manager: Final = GenericPromptManager(
api_base=api_base,
api_key=api_key,
prompt_id=prompt_id,
additional_provider_specific_query_params=provider_specific_query_params,
**litellm_params.model_dump(
exclude_none=True,
exclude={
"prompt_id",
"api_key",
"provider_specific_query_params",
"api_base",
},
),View on GitHub (pinned to 77b7c6c40c)