{"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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/langgraph/chat/transformation.py#L88-L124","documentation":"The LangGraph provider builds its endpoint as {api_base}/runs/stream (streaming) or {api_base}/runs/wait (non-streaming) and has no default host. get_complete_url raises ValueError when api_base is None — it must be supplied via the api_base parameter or the LANGGRAPH_API_BASE environment variable (typically the LangGraph Platform/Agent Server URL).","triggerScenarios":"Calling completion(model=\"langgraph/...\", stream=True) with neither api_base nor LANGGRAPH_API_BASE set; env var defined only in the local shell but not in the deployed container/CI.","commonSituations":"Missing LANGGRAPH_API_BASE when integrating a LangGraph Deployment (e.g. https://my-deployment.langgraph.com); typo'd variable name (LANGGRAPH_API_URL); .env not loaded; proxy config lacking api_base on the langgraph model entry.","solutions":["Set LANGGRAPH_API_BASE to your LangGraph server URL (e.g. https://my-agent.langgraph.com)","Or pass api_base=... explicitly on the call / model_list entry","For LiteLLM proxy, add api_base to the deployment's litellm_params for the langgraph model","Confirm the env var is actually present in the process: printenv LANGGRAPH_API_BASE"],"exampleFix":"# before\nlitellm.completion(model=\"langgraph/my-agent\", messages=msgs, api_key=lg_key)\n\n# after\nlitellm.completion(\n    model=\"langgraph/my-agent\",\n    messages=msgs,\n    api_key=lg_key,\n    api_base=\"https://my-agent.langgraph.com\",\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_langgraph_config(api_base: str | None = None) -> str:\n    base = api_base or os.getenv(\"LANGGRAPH_API_BASE\")\n    if not base:\n        raise ValueError(\"LANGGRAPH_API_BASE is not set; refusing to call LangGraph\")\n    return base.rstrip(\"/\")","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"langgraph/agent\", messages=msgs, api_base=ensure_langgraph_config())\nexcept ValueError as e:\n    if \"api_base is required for LangGraph\" in str(e):\n        raise RuntimeError(\"Bootstrap error: LANGGRAPH_API_BASE missing in this environment\") from e","preventionTips":["Pin LANGGRAPH_API_BASE (and LANGGRAPH_API_KEY) in the same env manifest for every environment","Add a startup connectivity check against {base}/info or /runs before serving traffic","Watch for the common typo LANGGRAPH_API_URL — assert the exact variable name in tests"],"tags":["langgraph","config","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}