> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agenticenv.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create your first agent and run it in under 5 minutes

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

```bash theme={null}
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

```bash theme={null}
export OPENAI_API_KEY=sk-your-key-here
```

For Anthropic or Gemini, see [LLM Providers](/getting-started/llm-providers).

## Step 3 — Write the agent

Create `main.go`:

```go theme={null}
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

```bash theme={null}
go run .
```

Expected output includes the agent name, model, and assistant reply in `result.Content`.

## What happened

| Call               | What it does                                                                              |
| ------------------ | ----------------------------------------------------------------------------------------- |
| `openai.NewClient` | Creates an [`interfaces.LLMClient`](/getting-started/llm-providers) for OpenAI            |
| `agent.NewAgent`   | Builds the agent with your prompt and LLM client; uses in-process runtime by default      |
| `a.Run`            | Executes one agent loop synchronously, returns [`*AgentRunResult`](/features/token-usage) |
| `a.Close`          | Stops any embedded Temporal worker and flushes OTLP exporters                             |

<Warning>
  `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.
</Warning>

## Switch to Temporal (optional)

Add `WithTemporalConfig` to run the same agent durably. A running Temporal cluster is required — see [Prerequisites](/getting-started/prerequisites#temporal-optional).

```go theme={null}
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](/runtimes/temporal) for connection options including Temporal Cloud.

## Try the repository example

The same pattern is in the [Simple Agent](/examples/simple-agent) example. From the repository root:

```bash theme={null}
export LLM_APIKEY=your-key
export LLM_PROVIDER=openai
export LLM_MODEL=gpt-4o
go run ./examples/simple_agent "Hello"
```

See [Running Examples](/examples/running-examples) for environment variable details.

## What's next

<CardGroup cols={2}>
  <Card title="LLM Providers" icon="brain" href="/getting-started/llm-providers">
    Configure OpenAI, Anthropic, Gemini, or a custom client
  </Card>

  <Card title="Streaming" icon="wave-square" href="/getting-started/streaming">
    Stream partial tokens and lifecycle events
  </Card>

  <Card title="Configuration" icon="sliders" href="/getting-started/configuration">
    All agent options and defaults
  </Card>

  <Card title="Tools" icon="wrench" href="/features/tools">
    Add built-in or custom tools to your agent
  </Card>

  <Card title="Examples" icon="play" href="/examples/running-examples">
    Runnable examples index
  </Card>
</CardGroup>
