{"record":{"id":"b3edb8c510ba402b","repo":"BerriAI/litellm","slug":"api-base-is-required-for-infinity-embeddings","errorCode":null,"errorMessage":"api_base is required for Infinity embeddings","messagePattern":"api_base is required for Infinity embeddings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/infinity/embedding/transformation.py","lineNumber":33,"sourceCode":"class InfinityEmbeddingConfig(BaseEmbeddingConfig):\n    \"\"\"\n    Reference: https://infinity.modal.michaelfeil.eu/docs\n    \"\"\"\n\n    def __init__(self) -> None:\n        pass\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        if api_base is None:\n            raise ValueError(\"api_base is required for Infinity embeddings\")\n        # Remove trailing slashes and ensure clean base URL\n        api_base = api_base.rstrip(\"/\")\n        if not api_base.endswith(\"/embeddings\"):\n            api_base = f\"{api_base}/embeddings\"\n        return api_base\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        if api_key is None:\n            api_key = get_secret_str(\"INFINITY_API_KEY\")","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/infinity/embedding/transformation.py#L15-L51","documentation":"Raised by the Infinity embedding config when building the request URL: Infinity is a self-hosted service, so there is no default host and api_base must be provided (e.g. http://localhost:7111). Without it the URL cannot be constructed and a ValueError aborts the call.","triggerScenarios":"litellm.embedding(model='infinity/<model>', input=[...]) without api_base=... and without an api_base in the proxy/model config.","commonSituations":"Copying example code that omits api_base, forgetting to set api_base in the litellm proxy model entry, or a typo like api_bass/api-base in kwargs.","solutions":["Pass api_base: litellm.embedding(model='infinity/BAAI/bge-m3', input=texts, api_base='http://localhost:7111').","In litellm proxy config, set api_base on the infinity model entry.","Ensure the Infinity server is reachable at that base (curl http://host:port/models)."],"exampleFix":"# before\nlitellm.embedding(model='infinity/BAAI/bge-m3', input=texts)\n\n# after\nlitellm.embedding(model='infinity/BAAI/bge-m3', input=texts, api_base='http://localhost:7111')","handlingStrategy":"validation","validationCode":"def get_infinity_base() -> str:\n    base = os.environ.get('INFINITY_API_BASE') or 'http://localhost:7111'\n    if not base.startswith(('http://', 'https://')):\n        raise ValueError(f'invalid Infinity api_base: {base!r}')\n    return base","typeGuard":"def is_valid_api_base(base: object) -> bool:\n    return isinstance(base, str) and base.startswith(('http://', 'https://')) and len(base) > len('http://')","tryCatchPattern":null,"preventionTips":["Fail fast on startup if INFINITY_API_BASE is unset","Centralize self-hosted base URLs in env config, never inline per call site"],"tags":["infinity","embeddings","configuration","api-base","self-hosted"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}