xAI SDK: how to force the model to call a specific function

Does forcing a specific function to be called actually work in the xAI Python SDK? I am testing something similar to OpenAI function calling and the model does not seem to honor it. I followed the OpenAI-style tool_choice pattern from the docs I found, but the model keeps picking on its own. The function itself works when the model chooses it voluntarily.

Yes, it works, but you need to use the requiredtool helper. Import it with from xaisdk.chat import required_tool and pass it when you create the chat. That pins the model to the function you name. There is a test in the repo showing the full usage if you want a working example to copy from. Source: https://github.com/xai-org/xai-sdk-python/issues/16