BerriAI/litellm · error · OobaboogaError

API Base not set. Set one via completion(..,api_base='your-a

Error message

API Base not set. Set one via completion(..,api_base='your-api-url')

What it means

oobabooga's text-generation-webui exposes an OpenAI-compatible API, but LiteLLM cannot guess its address. In the chat completion handler, if the model string is not an http(s) URL and no api_base was supplied (no explicit arg, no OOBABOOGA_API_BASE env var), this 404 OobaboogaError is raised.

Source

Thrown at litellm/llms/oobabooga/chat/oobabooga.py:43

    litellm_params: dict,
    custom_prompt_dict={},
    logger_fn=None,
    default_max_tokens_to_sample=None,
):
    headers: Final = oobabooga_config.validate_environment(
        api_key=api_key,
        headers={},
        model=model,
        messages=messages,
        optional_params=optional_params,
        litellm_params=litellm_params,
    )
    if model.startswith(("http://", "https://")):
        completion_url = model
    elif api_base:
        completion_url = api_base
    else:
        raise OobaboogaError(
            status_code=404,
            message="API Base not set. Set one via completion(..,api_base='your-api-url')",
        )
    model = model

    completion_url = completion_url + "/v1/chat/completions"
    data: Final = oobabooga_config.transform_request(
        model=model,
        messages=messages,
        optional_params=optional_params,
        litellm_params=litellm_params,
        headers=headers,
    )
    ## LOGGING

    logging_obj.pre_call(
        input=messages,
        api_key=api_key,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass the URL explicitly: `litellm.completion(model='oobabooga/<model>', api_base='http://127.0.0.1:5000', messages=...)`.
  2. Or set the environment variable before starting your app: `export OOBABOOGA_API_BASE=http://127.0.0.1:5000`.
  3. Or embed the URL in the model string: `model='http://127.0.0.1:5000'`.
  4. Ensure text-generation-webui is running with its OpenAI extension (--api) and the port matches.

Example fix

# before
resp = litellm.completion(model="oobabooga/my-model", messages=[...])

# after
resp = litellm.completion(model="oobabooga/my-model", api_base="http://127.0.0.1:5000", messages=[...])
Defensive patterns

Strategy: validation

Validate before calling

import os
api_base = api_base or os.environ.get("OOBABOOGA_API_BASE")
if not api_base:
    raise ValueError("OOBABOOGA_API_BASE not set and api_base not provided")

Prevention

When it happens

Trigger: Calling `litellm.completion(model='oobabooga/<model>', messages=...)` without `api_base=` and without the OOBABOOGA_API_BASE environment variable set.

Common situations: forgetting api_base on a new machine, env var not exported in the shell/service that runs LiteLLM (common in Docker/systemd where env doesn't propagate), or renaming the env var after an upgrade.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/965ccb615258b12b. Report an issue: GitHub.