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

# Go SDK

> Add Octen to your Go project.

For AI agents: [docs.octen.ai/integrations/go-sdk.md](https://docs.octen.ai/integrations/go-sdk.md)

> [card] [Get API Key](https://octen.ai/platform/api-keys)
>
> Create a key from the API Platform.

> [card] [pkg.go.dev](https://pkg.go.dev/github.com/Octen-Team/octen-go)
>
> The `github.com/Octen-Team/octen-go` module.

## Install

Requires Go 1.22+.

```bash go theme={null}
go get github.com/Octen-Team/octen-go
```

## Quick Start

```go theme={null}
package main

import (
	"context"
	"fmt"
	"log"

	octen "github.com/Octen-Team/octen-go"
)

func main() {
	client, err := octen.NewClient(octen.WithAPIKey("your-api-key")) // or set OCTEN_API_KEY env var
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	resp, err := client.Search.Search(ctx, octen.SearchParams{
		Query: "latest advances in solid-state batteries",
		Count: octen.Int(5),
	})
	if err != nil {
		log.Fatal(err)
	}
	if resp.Data != nil {
		for _, r := range resp.Data.Results {
			fmt.Println(r.Title, r.URL)
		}
	}
}
```

Request and response fields use the [API reference](https://docs.octen.ai/api-reference/search.md) names in Go style (`include_domains` is `IncludeDomains`). Results are under `resp.Data`, which is `nil` when the response has no data. Optional request fields are pointers, so set them with `octen.Int`, `octen.String`, `octen.Bool`, or `octen.Float64`.

The Go SDK covers the APIs on this page. For other APIs, such as [Embedding](https://docs.octen.ai/api-reference/embedding.md), send HTTP requests as shown in the API reference.

## Broad Search

Decompose a query into sub-queries, search them concurrently, and get results grouped per sub-query. Best for comparisons, surveys, and multi-angle questions.

```go theme={null}
resp, err := client.Search.BroadSearch(ctx, octen.BroadSearchParams{
	Query:      "compare cloud GPU pricing across providers",
	MaxQueries: octen.Int(5), // up to N sub-queries (1-30, default 5)
	SearchOptions: &octen.WebSearchOptions{
		ResultType: octen.String("dynamic"), // only relevant results per sub-query (default "standard")
	},
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Queries -> sub-queries; resp.Data.SearchResults -> grouped results
```

## Web Search

Search the live web and get ranked results with model-ready highlights and optional full content. Best for search bars, answer engines, and news lookup.

```go theme={null}
resp, err := client.Search.Search(ctx, octen.SearchParams{
	Query:          "blog post about artificial intelligence",
	Count:          octen.Int(10),
	TimeRange:      octen.String("week"),
	IncludeDomains: []string{"techcrunch.com", "wired.com"},
	ResultType:     octen.String("dynamic"), // only relevant results, up to Count (default "standard")
})
if err != nil {
	log.Fatal(err)
}
```

## Web Search Premier

Search the live web with deeper retrieval and reranking, so the page that holds the answer ranks higher. Takes the same parameters as Web Search and returns the same response. Best for agent questions, specific facts, and named pages.

```go theme={null}
resp, err := client.Search.SearchPremier(ctx, octen.SearchParams{
	Query:      "latest guidance on EU AI Act compliance",
	ResultType: octen.String("dynamic"), // only relevant results, up to Count (default "standard")
	Count:      octen.Int(10),
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Results -> ranked results, with the same fields as Web Search
```

## News Search

Search live news and get ranked articles, with related coverage grouped into storylines. Best for breaking news, media monitoring, and story tracking.

```go theme={null}
resp, err := client.Search.NewsSearch(ctx, octen.NewsSearchParams{
	Query:     "EU AI Act enforcement",
	TimeRange: octen.String("week"),
	Count:     octen.Int(10),
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Subjects -> storylines; resp.Data.Results -> ranked articles
```

## Business Search

Get the companies and people behind a query as entity cards, alongside ranked sources. Best for company due diligence, people lookup, and competitor comparison.

```go theme={null}
resp, err := client.Search.BusinessSearch(ctx, octen.BusinessSearchParams{
	Query:    "compare Stripe and Adyen payment processing",
	Entities: &octen.BusinessEntityOptions{Count: octen.Int(2), MaxNews: octen.Int(5)},
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Entities -> entity cards (Company or Person); resp.Data.Results -> ranked sources
```

## Place Search

Find places around a point or in a named area as cards with address, coordinates, phone, opening hours, and rating. Best for nearby recommendations, local lookup, and opening hours.

```go theme={null}
resp, err := client.PlaceSearch.Search(ctx, octen.PlaceSearchParams{
	Query:     "coffee shops",
	Latitude:  octen.Float64(35.6812),
	Longitude: octen.Float64(139.7671),
	Radius:    octen.Int(1000), // meters (1-50000), needs both coordinates
	Places:    &octen.PlaceCardOptions{Count: octen.Int(5)},
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Places -> place cards, each with a distance
```

## Pulse Search

Predict the URL a query points to. Best for docs, help pages, and official sites.

```go theme={null}
resp, err := client.Search.PulseSearch(ctx, octen.PulseSearchParams{Query: "github docs", Count: octen.Int(5)})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Results -> titles and URLs; in the default lite mode, URLs have no scheme
```

## Image Search

Search images by a text query or a reference image. Best for image lookup and visual references.

```go theme={null}
resp, err := client.ImageSearch.Search(ctx, octen.ImageSearchParams{
	Inputs: []octen.ImageSearchInput{{Type: "text", Data: octen.String("golden retriever puppy")}}, // one input: text, or an image by URL or base64 Data
	Count:  octen.Int(5),
})
if err != nil {
	log.Fatal(err)
}
```

## Design Search

Search real web pages, app screens, and slides, and get each as an image with its design values, plus web results on the same query. Best for landing pages, app screens, and slide decks.

```go theme={null}
resp, err := client.DesignSearch.Search(ctx, octen.DesignSearchParams{
	Query:  octen.String("pricing page with three tiers"),
	Images: &octen.DesignImageOptions{Count: octen.Int(5)},
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Images -> design images with their design values; resp.Data.Results -> web results
```

## Extract

Fetch 1-20 URLs in one call and get clean markdown or text. Best for reading pages, cleaning articles, and knowledge ingestion.

```go theme={null}
resp, err := client.Extract.Extract(ctx, octen.ExtractParams{
	URLs:   []string{"https://docs.octen.ai/api-reference/search", "https://octen.ai"},
	Format: octen.String("markdown"),
})
if err != nil {
	log.Fatal(err)
}
// resp.Data.Results -> one result per URL: FullContent on success, ErrorMessage if Status is "failed"
```

## Configuration

```go theme={null}
// Also import "time".
client, err := octen.NewClient(
	octen.WithAPIKey("your-api-key"),          // default: the OCTEN_API_KEY env var
	octen.WithBaseURL("https://api.octen.ai"), // default
	octen.WithTimeout(60*time.Second),         // every endpoint; if unset, 30 s (120 s for Broad Search)
	octen.WithMaxRetries(3),                   // default 3
)
if err != nil {
	log.Fatal(err)
}
```

A client is safe for concurrent use, so create one and share it.

## Error Handling

```go theme={null}
// Also import "errors".
_, err := client.Search.Search(ctx, octen.SearchParams{Query: "query"})
if err != nil {
	var validationErr *octen.ValidationError
	var timeoutErr *octen.TimeoutError
	var connErr *octen.ConnectionError
	var apiErr *octen.APIError
	switch {
	case errors.As(err, &validationErr):
		log.Printf("Invalid request, not sent: %v", err)
	case errors.As(err, &timeoutErr):
		log.Println("Request timed out")
	case errors.As(err, &connErr):
		log.Println("Network connection failed")
	case errors.Is(err, octen.ErrAuthentication):
		log.Println("Invalid API key")
	case errors.Is(err, octen.ErrRateLimit) && errors.As(err, &apiErr) && apiErr.RetryAfter != nil:
		log.Printf("Rate limited, retry after %v", *apiErr.RetryAfter)
	case errors.As(err, &apiErr):
		log.Printf("API error: %d - %s (request ID: %s)", apiErr.StatusCode, apiErr.Message, apiErr.RequestID)
	default:
		log.Println(err)
	}
}
```

Requests that fail with HTTP 408, 429, 500, 502, 503, or 504 are automatically retried with exponential backoff, up to `WithMaxRetries` times. Connection errors before the request is sent are also retried. Timeouts are not retried.

Include `RequestID` when you contact support.

***

Last modified on November 24, 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.