BerriAI/litellm · error · ValueError
FIREWORKS_ACCOUNT_ID is not set. Please set the environment
Error message
FIREWORKS_ACCOUNT_ID is not set. Please set the environment variable, to query Fireworks AI's `/models` endpoint.
What it means
FireworksAIConfig.get_models() lists models via Fireworks AI's account-scoped endpoint /v1/accounts/{account_id}/models. Before issuing the request it resolves FIREWORKS_ACCOUNT_ID from the environment/secrets; if that variable is absent it raises this ValueError. Unlike the OpenAI-compatible /models route, Firewalls requires an explicit account id to scope the query.
Source
Thrown at litellm/llms/fireworks_ai/chat/transformation.py:770
api_base = api_base or get_secret_str("FIREWORKS_API_BASE") or "https://api.fireworks.ai/inference/v1"
dynamic_api_key: Final = api_key or (
get_secret_str("FIREWORKS_API_KEY")
or get_secret_str("FIREWORKS_AI_API_KEY")
or get_secret_str("FIREWORKSAI_API_KEY")
or get_secret_str("FIREWORKS_AI_TOKEN")
)
return api_base, dynamic_api_key
def get_models(self, api_key: str | None = None, api_base: str | None = None):
api_base, api_key = self._get_openai_compatible_provider_info(api_base=api_base, api_key=api_key)
if api_base is None or api_key is None:
raise ValueError(
"FIREWORKS_API_BASE or FIREWORKS_API_KEY is not set. Please set the environment variable, to query Fireworks AI's `/models` endpoint."
)
account_id: Final = get_secret_str("FIREWORKS_ACCOUNT_ID")
if account_id is None:
raise ValueError(
"FIREWORKS_ACCOUNT_ID is not set. Please set the environment variable, to query Fireworks AI's `/models` endpoint."
)
base = api_base.rstrip("/")
base = base.removesuffix("/v1")
response: Final = litellm.module_level_client.get(
url=f"{base}/v1/accounts/{account_id}/models",
headers={"Authorization": f"Bearer {api_key}"},
)
if response.status_code != 200:
raise ValueError(
f"Failed to fetch models from Fireworks AI. Status code: {response.status_code}, Response: {response.json()}"
)
models: Final = response.json()["models"]
return ["fireworks_ai/" + model["name"] for model in models]View on GitHub (pinned to 6c2dcb801b)
Solutions
- Export FIREWORKS_ACCOUNT_ID (the numeric account id from the Fireworks console URL, e.g. 1234567890) in the environment where litellm runs.
- If set via a secret manager or .env, confirm the variable name spelling and that the file is actually loaded before litellm is imported/used.
- As a workaround, call the OpenAI-compatible models endpoint instead (GET {FIREWORKS_API_BASE}/models with the Bearer key) which does not need the account id.
Example fix
# before
export FIREWORKS_API_KEY=fw_...
python -c "import litellm; litellm.get_model_list('fireworks_ai')" # ValueError
# after
export FIREWORKS_API_KEY=fw_...
export FIREWORKS_ACCOUNT_ID=1234567890
python -c "import litellm; litellm.get_model_list('fireworks_ai')" Defensive patterns
Strategy: validation
Validate before calling
import os
def can_list_fireworks_models() -> bool:
return all([
bool(os.getenv("FIREWORKS_API_KEY")),
bool(os.getenv("FIREWORKS_API_BASE") or True), # defaults internally
bool(os.getenv("FIREWORKS_ACCOUNT_ID")),
])
if not can_list_fireworks_models():
print("FIREWORKS_ACCOUNT_ID (and FIREWORKS_API_KEY) must be set before listing models") Try / catch
try:
models = litellm.get_model_list("fireworks_ai")
except ValueError as e:
if "FIREWORKS_ACCOUNT_ID" in str(e):
os.environ["FIREWORKS_ACCOUNT_ID"] = load_account_id_from_vault()
models = litellm.get_model_list("fireworks_ai")
else:
raise Prevention
- Centralize Fireworks env setup (key + account id) in one bootstrap function run at app start.
- Add a startup readiness check that asserts all required Fireworks env vars are non-empty before serving traffic.
- Document that model listing needs FIREWORKS_ACCOUNT_ID even though chat does not.
When it happens
Trigger: Calling litellm.get_model_list('fireworks_ai') (or any path into FireworksAIConfig.get_models) while FIREWORKS_API_KEY/FIREWORKS_API_BASE are set but FIREWORKS_ACCOUNT_ID is not exported in the environment.
Common situations: CI jobs, Docker containers, or proxy deployments where only FIREWORKS_API_KEY was configured; using a Fireworks key from a workspace where the account id was never exported because chat/rerank calls work fine without it.
Related errors
- FIREWORKS_API_KEY is not set
- AZURE_SENTINEL_DCR_IMMUTABLE_ID is required. Set it as an en
- AZURE_SENTINEL_ENDPOINT is required. Set it as an environmen
- AZURE_SENTINEL_TENANT_ID or AZURE_TENANT_ID is required. Set
- AZURE_SENTINEL_CLIENT_ID or AZURE_CLIENT_ID is required. Set
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/e5df121bc8a0ad63.
Report an issue: GitHub.