{"record":{"id":"8c777f19824c8e13","repo":"BerriAI/litellm","slug":"api-base-is-required-for-langgraph-set-it-via-lan","errorCode":null,"errorMessage":"api_base is required for LangGraph. Set it via LANGGRAPH_API_BASE env var or api_base parameter.","messagePattern":"api_base is required for LangGraph\\. Set it via LANGGRAPH_API_BASE env var or api_base parameter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/langgraph/chat/transformation.py","lineNumber":106,"sourceCode":"        return optional_params\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        \"\"\"\n        Get the complete URL for the LangGraph request.\n\n        Streaming: /runs/stream\n        Non-streaming: /runs/wait\n        \"\"\"\n        if api_base is None:\n            raise ValueError(\n                \"api_base is required for LangGraph. Set it via LANGGRAPH_API_BASE env var or api_base parameter.\"\n            )\n\n        # Remove trailing slash if present\n        api_base = api_base.rstrip(\"/\")\n\n        # Choose endpoint based on streaming mode\n        if stream:\n            return f\"{api_base}/runs/stream\"\n        else:\n            return f\"{api_base}/runs/wait\"\n\n    def _get_assistant_id(self, model: str, optional_params: dict) -> str:\n        \"\"\"\n        Get the assistant ID from model or optional_params.\n\n        model format: \"langgraph/assistant_id\" or just \"assistant_id\"\n        \"\"\"","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/langgraph/chat/transformation.py#L88-L124","documentation":"LangGraphConfig.get_complete_url must build {api_base}/runs/stream (streaming) or {api_base}/runs/wait (non-streaming). Unlike some providers there is no default base URL, so when api_base is None (neither the api_base parameter nor LANGGRAPH_API_BASE env var resolved) it raises ValueError before any HTTP call is made.","triggerScenarios":"litellm.completion(model=\"langgraph/<assistant>\", ...) with neither an api_base kwarg nor LANGGRAPH_API_BASE set in the calling process; using stream=True only changes the endpoint (/runs/stream), the api_base requirement is identical.","commonSituations":"Env var missing in the deployed container/CI; k8s secret not mounted; .env not loaded; proxy deployment entry for a langgraph model missing api_base.","solutions":["Pass api_base explicitly: litellm.completion(model=\"langgraph/<assistant>\", api_base=\"https://my-langgraph-server\", ...)","Or export LANGGRAPH_API_BASE=https://my-langgraph-server in the process that makes the call and restart it","If routing through the LiteLLM proxy, set api_base on the langgraph deployment in config.yaml","Confirm with printenv LANGGRAPH_API_BASE from the same runtime environment"],"exampleFix":"// before\nawait litellm.acompletion(\n    model=\"langgraph/agent\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n)  # ValueError: api_base is required for LangGraph\n\n// after\nawait litellm.acompletion(\n    model=\"langgraph/agent\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    api_base=\"https://my-langgraph-server\",  # or export LANGGRAPH_API_BASE=...\n)","handlingStrategy":"validation","validationCode":"import os\n\nLANGGRAPH_BASE = os.getenv(\"LANGGRAPH_API_BASE\")\nif not LANGGRAPH_BASE:\n    raise SystemExit(\"Set LANGGRAPH_API_BASE (e.g. https://my-langgraph-server) before starting\")\n# then: litellm.completion(model=\"langgraph/<assistant>\", api_base=LANGGRAPH_BASE, ...)","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"langgraph/<assistant>\", messages=msgs)\nexcept ValueError as e:\n    if \"api_base is required for LangGraph\" in str(e):\n        raise ConfigError(\"LANGGRAPH_API_BASE missing\") from e\n    raise","preventionTips":["Fail fast at startup if LANGGRAPH_API_BASE is absent rather than per-request","Pass api_base explicitly on langgraph calls when running multiple environments","Add the variable to deployment manifests and CI secrets checklists"],"tags":["langgraph","api-base","configuration","env-var"],"backgroundTag":"missing-api-base-url","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}