{"record":{"id":"69125aaf4e68b2fa","repo":"mem0ai/mem0","slug":"model-model-does-not-support-function-calling","errorCode":null,"errorMessage":"Model '{model}' does not support function calling. Please use a model that supports function calling.","messagePattern":"Model '(.+?)' does not support function calling\\. Please use a model that supports function calling\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/proxy/main.py","lineNumber":101,"sourceCode":"        parallel_tool_calls: Optional[bool] = None,\n        deployment_id=None,\n        extra_headers: Optional[dict] = None,\n        # soon to be deprecated params by OpenAI\n        functions: Optional[List] = None,\n        function_call: Optional[str] = None,\n        # set api_base, api_version, api_key\n        base_url: Optional[str] = None,\n        api_version: Optional[str] = None,\n        api_key: Optional[str] = None,\n        model_list: Optional[list] = None,  # pass in a list of api_base,keys, etc.\n    ):\n        if messages is None:\n            messages = []\n        if not any([user_id, agent_id, run_id]):\n            raise ValueError(\"One of user_id, agent_id, run_id must be provided\")\n\n        if not litellm.supports_function_calling(model):\n            raise ValueError(\n                f\"Model '{model}' does not support function calling. Please use a model that supports function calling.\"\n            )\n\n        prepared_messages = self._prepare_messages(messages)\n        if prepared_messages[-1][\"role\"] == \"user\":\n            self._async_add_to_memory(messages, user_id, agent_id, run_id, metadata, filters)\n            relevant_memories = self._fetch_relevant_memories(messages, user_id, agent_id, run_id, filters, top_k)\n            logger.debug(f\"Retrieved {len(relevant_memories)} relevant memories\")\n            prepared_messages[-1][\"content\"] = self._format_query_with_memories(messages, relevant_memories)\n\n        response = litellm.completion(\n            model=model,\n            messages=prepared_messages,\n            temperature=temperature,\n            top_p=top_p,\n            n=n,\n            timeout=timeout,\n            stream=stream,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/proxy/main.py#L83-L119","documentation":"Mem0Proxy checks litellm.supports_function_calling(model) before routing the request, because the proxy injects memory-management tools into the completion call. If litellm's model registry says the requested model cannot do function/tool calling, it raises ValueError immediately rather than sending a request that would fail obscurely at the provider.","triggerScenarios":"Passing a chat-only or completion-only model name (e.g. some base/instruct models, older tiers, or unknown custom model strings) to mem0_proxy.completion(); typos in model names that make litellm fall back to a registry entry without function-calling support; using a custom 'openai/<deployed-name>' style string litellm cannot classify.","commonSituations":"Switching from gpt-4o to a cheaper/local model (e.g. some llama variants) that lacks tool support; on-prem deployments with custom model names litellm maps conservatively; litellm version changes that alter the supports_function_calling table.","solutions":["Use a model known to support function calling (e.g. gpt-4o, gpt-4o-mini, claude-3.5-sonnet, gemini-1.5-pro)","Print litellm.supports_function_calling(model) in a quick REPL to see how litellm classifies your model string","Upgrade litellm so newer models are recognized, or pass the fully qualified provider-prefixed name (e.g. 'azure/<deployment>') so lookup succeeds","For local models, use a tool-calling-capable server (vLLM/Ollama with tools enabled) and the matching litellm provider prefix"],"exampleFix":"# before\nresp = mem0_proxy.completion(messages=messages, model=\"some-base-model\", user_id=\"alice\")\n\n# after\nimport litellm\nassert litellm.supports_function_calling(\"gpt-4o-mini\")\nresp = mem0_proxy.completion(messages=messages, model=\"gpt-4o-mini\", user_id=\"alice\")","handlingStrategy":"validation","validationCode":"import litellm\nif not litellm.supports_function_calling(model):\n    raise ValueError(f\"{model} cannot be used with the mem0 proxy; pick a tool-capable model\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check litellm.supports_function_calling in a startup self-test for every model you route through the proxy","Keep litellm updated when adopting new models","Use fully qualified provider-prefixed model strings"],"tags":["proxy","litellm","function-calling","model-support"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}