Create a minimal agent on the in-process runtime and run a single prompt. No Temporal server required.
Requirements: Go 1.26+ and an API key for at least one LLM provider. Verify your Go version with go version.
Step 1 — Create a Go module
mkdir my-agent && cd my-agent
go mod init example.com/my-agent
go get github.com/agenticenv/agent-sdk-go@latest
Step 2 — Set your API key
export OPENAI_API_KEY = sk-your-key-here
For Anthropic or Gemini, see LLM Providers .
Step 3 — Write the agent
Create main.go:
package main
import (
" context "
" fmt "
" log "
" os "
" github.com/agenticenv/agent-sdk-go/pkg/agent "
" github.com/agenticenv/agent-sdk-go/pkg/llm "
" github.com/agenticenv/agent-sdk-go/pkg/llm/openai "
)
func main () {
ctx := context . Background ()
llmClient , err := openai . NewClient (
llm . WithAPIKey ( os . Getenv ( "OPENAI_API_KEY" )),
llm . WithModel ( "gpt-4o" ),
)
if err != nil {
log . Fatalf ( "create LLM client: %v " , err )
}
a , err := agent . NewAgent (
agent . WithName ( "quickstart-agent" ),
agent . WithSystemPrompt ( "You are a helpful assistant." ),
agent . WithLLMClient ( llmClient ),
)
if err != nil {
log . Fatalf ( "create agent: %v " , err )
}
defer a . Close ()
result , err := a . Run ( ctx , "Hello! What can you help me with?" , nil )
if err != nil {
log . Fatalf ( "run agent: %v " , err )
}
fmt . Println ( "Agent:" , result . AgentName )
fmt . Println ( "Model:" , result . Model )
fmt . Println ( "Reply:" , result . Content )
}
Step 4 — Run
Expected output includes the agent name, model, and assistant reply in result.Content.
What happened
Call What it does openai.NewClientCreates an interfaces.LLMClient for OpenAI agent.NewAgentBuilds the agent with your prompt and LLM client; uses in-process runtime by default a.RunExecutes one agent loop synchronously, returns *AgentRunResult a.CloseStops any embedded Temporal worker and flushes OTLP exporters
defer a.Close() is not optional when using the Temporal runtime — it shuts down the embedded local worker. On the in-process runtime it is a no-op but still good practice.
Switch to Temporal (optional)
Add WithTemporalConfig to run the same agent durably. A running Temporal cluster is required — see Prerequisites .
a , err := agent . NewAgent (
agent . WithTemporalConfig ( & agent . TemporalConfig {
Host : "localhost" ,
Port : 7233 ,
Namespace : "default" ,
TaskQueue : "my-app" ,
}),
agent . WithName ( "quickstart-agent" ),
agent . WithSystemPrompt ( "You are a helpful assistant." ),
agent . WithLLMClient ( llmClient ),
)
No other code changes. The agent loop now runs as a durable Temporal workflow. See Temporal runtime for connection options including Temporal Cloud.
Try the repository example
The same pattern is in the Simple Agent example. From the repository root:
export LLM_APIKEY = your-key
export LLM_PROVIDER = openai
export LLM_MODEL = gpt-4o
go run ./examples/simple_agent "Hello"
See Running Examples for environment variable details.
What’s next
LLM Providers Configure OpenAI, Anthropic, Gemini, or a custom client
Streaming Stream partial tokens and lifecycle events
Configuration All agent options and defaults
Tools Add built-in or custom tools to your agent
Examples Runnable examples index