> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter-d02e98a0-mintlify-7021d5f4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ChatFunctionTool - Go SDK

> ChatFunctionTool type definition

<Warning>
  The Go SDK and docs are currently in beta.
  Report issues on [GitHub](https://github.com/OpenRouterTeam/go-sdk/issues).
</Warning>

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

## Supported Types

### ChatFunctionToolFunction

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolChatFunctionToolFunction(components.ChatFunctionToolFunction{/* values here */})
```

### DatetimeServerTool

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolDatetimeServerTool(components.DatetimeServerTool{/* values here */})
```

### ImageGenerationServerToolOpenRouter

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolImageGenerationServerToolOpenRouter(components.ImageGenerationServerToolOpenRouter{/* values here */})
```

### ChatSearchModelsServerTool

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolChatSearchModelsServerTool(components.ChatSearchModelsServerTool{/* values here */})
```

### WebFetchServerTool

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolWebFetchServerTool(components.WebFetchServerTool{/* values here */})
```

### OpenRouterWebSearchServerTool

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolOpenRouterWebSearchServerTool(components.OpenRouterWebSearchServerTool{/* values here */})
```

### ChatWebSearchShorthand

```go lines theme={null}
chatFunctionTool := components.CreateChatFunctionToolChatWebSearchShorthand(components.ChatWebSearchShorthand{/* values here */})
```

## Union Discrimination

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

```go lines theme={null}
switch chatFunctionTool.Type {
	case components.ChatFunctionToolUnionTypeChatFunctionToolFunction:
		// chatFunctionTool.ChatFunctionToolFunction is populated
	case components.ChatFunctionToolUnionTypeDatetimeServerTool:
		// chatFunctionTool.DatetimeServerTool is populated
	case components.ChatFunctionToolUnionTypeImageGenerationServerToolOpenRouter:
		// chatFunctionTool.ImageGenerationServerToolOpenRouter is populated
	case components.ChatFunctionToolUnionTypeChatSearchModelsServerTool:
		// chatFunctionTool.ChatSearchModelsServerTool is populated
	case components.ChatFunctionToolUnionTypeWebFetchServerTool:
		// chatFunctionTool.WebFetchServerTool is populated
	case components.ChatFunctionToolUnionTypeOpenRouterWebSearchServerTool:
		// chatFunctionTool.OpenRouterWebSearchServerTool is populated
	case components.ChatFunctionToolUnionTypeChatWebSearchShorthand:
		// chatFunctionTool.ChatWebSearchShorthand is populated
}
```
