For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
        • Models
        • ChatFunctionTool
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Supported Types
  • ChatFunctionToolFunction
  • DatetimeServerTool
  • ImageGenerationServerToolOpenRouter
  • ChatSearchModelsServerTool
  • WebFetchServerTool
  • OpenRouterWebSearchServerTool
  • ChatWebSearchShorthand
  • Union Discrimination
Go SDKAPI ReferenceModels

ChatFunctionTool - Go SDK

ChatFunctionTool type definition
Was this page helpful?
Previous

OAuth - Go SDK

OAuth method reference
Next
Built with

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 */})

ImageGenerationServerToolOpenRouter

1chatFunctionTool := components.CreateChatFunctionToolImageGenerationServerToolOpenRouter(components.ImageGenerationServerToolOpenRouter{/* values here */})

ChatSearchModelsServerTool

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

WebFetchServerTool

1chatFunctionTool := components.CreateChatFunctionToolWebFetchServerTool(components.WebFetchServerTool{/* 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.ChatFunctionToolUnionTypeImageGenerationServerToolOpenRouter:
7 // chatFunctionTool.ImageGenerationServerToolOpenRouter is populated
8 case components.ChatFunctionToolUnionTypeChatSearchModelsServerTool:
9 // chatFunctionTool.ChatSearchModelsServerTool is populated
10 case components.ChatFunctionToolUnionTypeWebFetchServerTool:
11 // chatFunctionTool.WebFetchServerTool is populated
12 case components.ChatFunctionToolUnionTypeOpenRouterWebSearchServerTool:
13 // chatFunctionTool.OpenRouterWebSearchServerTool is populated
14 case components.ChatFunctionToolUnionTypeChatWebSearchShorthand:
15 // chatFunctionTool.ChatWebSearchShorthand is populated
16}