Skip to main content
Tool calling or function calling allows LLMs to interact with external systems by requesting the execution of specific functions. The HasteKit SDK provides a unified interface for defining tools and handling tool call requests from various LLM providers.

Defining Tools

Tools are defined as part of the responses.Request struct using the Tools field.

Making a Request with Tools

Include the defined tools in your request to the model.

Handling Tool Calls

You can iterate through the Output list to find any requested tool calls.

Streaming Tool Calls

The following example demonstrates how to detect and process a tool call request from a streaming response.

Returning Tool Results

After executing the requested tool, you can send the results back to the model to continue the conversation. Use the OfFunctionCallOutput message type in the InputMessageList.