ChatFunctionTool - Go SDK

ChatFunctionTool type definition

The Go SDK and docs are currently in beta. Report issues on GitHub.

Tool definition for function calling (regular function or OpenRouter built-in server tool)

Supported Types

ChatFunctionToolFunction

1chatFunctionTool := components.CreateChatFunctionToolChatFunctionToolFunction(components.ChatFunctionToolFunction{/* values here */})

DatetimeServerTool

1chatFunctionTool := components.CreateChatFunctionToolDatetimeServerTool(components.DatetimeServerTool{/* values here */})

ChatSearchModelsServerTool

1chatFunctionTool := components.CreateChatFunctionToolChatSearchModelsServerTool(components.ChatSearchModelsServerTool{/* values here */})

OpenRouterWebSearchServerTool

1chatFunctionTool := components.CreateChatFunctionToolOpenRouterWebSearchServerTool(components.OpenRouterWebSearchServerTool{/* values here */})

ChatWebSearchShorthand

1chatFunctionTool := components.CreateChatFunctionToolChatWebSearchShorthand(components.ChatWebSearchShorthand{/* values here */})

Union Discrimination

Use the Type field to determine which variant is active, then access the corresponding field:

1switch chatFunctionTool.Type {
2 case components.ChatFunctionToolUnionTypeChatFunctionToolFunction:
3 // chatFunctionTool.ChatFunctionToolFunction is populated
4 case components.ChatFunctionToolUnionTypeDatetimeServerTool:
5 // chatFunctionTool.DatetimeServerTool is populated
6 case components.ChatFunctionToolUnionTypeChatSearchModelsServerTool:
7 // chatFunctionTool.ChatSearchModelsServerTool is populated
8 case components.ChatFunctionToolUnionTypeOpenRouterWebSearchServerTool:
9 // chatFunctionTool.OpenRouterWebSearchServerTool is populated
10 case components.ChatFunctionToolUnionTypeChatWebSearchShorthand:
11 // chatFunctionTool.ChatWebSearchShorthand is populated
12}