# Error using function callbacks on custom inference endpoint

**URL:** <https://discuss.huggingface.co/t/error-using-function-callbacks-on-custom-inference-endpoint/165365>\
**Category:** Beginners\
**Created:** [August 2, 2025, 9:56am UTC](https://discuss.huggingface.co/t/error-using-function-callbacks-on-custom-inference-endpoint/165365 "2025-08-02T09:56:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devz92](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/devz92/32/52012_2.png) [@devz92](https://discuss.huggingface.co/u/devz92)\
**Post date:** [August 2, 2025, 9:56am UTC](https://discuss.huggingface.co/t/error-using-function-callbacks-on-custom-inference-endpoint/165365/1 "2025-08-02T09:56:53Z")

</div>

Hi guys, I’m having some problems related to the tool calling  
testing it with my custom inference endpoint

using this example:

```auto
const testTools = [
      {
        "type": "function",
        "function": {
          "name": "get_number",
          "description": "Get the number",
          "parameters": {
            "type": "object",
            "properties": {
              "number": {
                "type": "string",
                "description": "the number to get",
              },
            },
            "required": ["number"],
          },
        },
      },
    ]

```

I’m not able to make it work  
without the tool, it works perfectly, but adding it to the request payload makes the response something like this:

```auto
"error\\\": \\\"\\\\\\\"Tool error: Failed to parse generated text: expected value at line 1 column 1 \\\\\\\\\\\\\\\"<|python_tag

```

this is the call I’m doing

```auto
    const response = await inferenceClient.chatCompletion({
      endpointUrl: endpointURL,
      messages: messages.map((message) => ({
        role: message.role,
        content: message.content,
      })),
      max_tokens: xxx,
      temperature: xxx,
      tools: testTools,
      tool_choice: 'auto'
    });

```

Maybe I’m missing something? or is anyone having the same problem?  
thanks in advance for your help!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [August 2, 2025, 11:17am UTC](https://discuss.huggingface.co/t/error-using-function-callbacks-on-custom-inference-endpoint/165365/2 "2025-08-02T11:17:22Z")

</div>

There seems to be [some incompatibility between TGI and Llama’s Function Calling](https://github.com/huggingface/text-generation-inference/issues/2480), so you [may need to use a slightly hacky workaround](https://discuss.huggingface.co/t/function-calling-not-working-with-inference-clients-on-seemingly-any-model/138581/14).

### Resources

- [Tool use does not work on Neuron backend #3114 (Same error)](https://github.com/huggingface/text-generation-inference/issues/3114)
- [Function/tool calling never resolves #2986](https://github.com/huggingface/text-generation-inference/issues/2986#issuecomment-2643403042)
