Skip to main content

Prerequisites

Use Go 1.25.3 or later, matching the SDK’s go.mod, and an API key for the provider you want to call. This example uses OpenAI directly and requires no gateway, Redis, or workflow service.

Install

Create an application module, then add the SDK:
Commit go.mod and go.sum to pin the resolved dependencies. Use go get github.com/hastekit/agent-sdk-go@<version> when upgrading to a specific release. Set OPENAI_API_KEY in your environment. Do not put the key in source control.

Create an agent

Save this as main.go:
Run it with go run .. NewLLMClient holds provider configuration. Model("OpenAI/gpt-4.1-mini") binds the provider and model for subsequent requests. NewAgent validates the agent configuration and returns an error on invalid setup. Run waits for completion; Text() extracts assistant text from the result. The agent uses in-memory history and a process-local stream broker by default. Those defaults are useful for a first run, but do not provide persistence across restarts or communication between replicas.

Next steps

Use function tools for application actions, history for multiple turns, and AG-UI for an HTTP endpoint and chat UI. For a direct model call without an agent loop, start with text generation.