A comprehensive Go SDK for the Exa.ai API, providing idiomatic Go interfaces for neural search, content retrieval, similarity search, and question answering capabilities.
go get github.com/amalucelli/exa-go- Go 1.24 or higher
- Exa.ai API key (Get one here)
package main
import (
"context"
"fmt"
"log"
"github.com/amalucelli/exa-go/exa"
)
func main() {
// Create client with API key
client, err := exa.New(
exa.WithAPIKey("your-api-key"),
)
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Perform a neural search
searchReq := &exa.SearchRequest{
Query: "latest developments in quantum computing",
SearchType: exa.SearchTypeNeural,
NumResults: 10,
}
searchResp, err := client.Search.Search(ctx, searchReq)
if err != nil {
log.Fatal(err)
}
// Print results
for _, result := range searchResp.Results {
fmt.Printf("Title: %s\nURL: %s\nScore: %.2f\n\n",
result.Title, result.URL, result.Score)
}
}The SDK provides several configuration options:
client, err := exa.New(
// Can also use EXA_API_KEY env variable
exa.WithAPIKey("your-api-key"),
// Custom base URL (optional)
exa.WithBaseURL("https://custom-api.exa.ai/"),
// Custom HTTP client (optional)
exa.WithHTTPClient(&http.Client{
Timeout: 30 * time.Second,
}),
// Enable debug logging (optional)
exa.WithDebug(true),
)EXA_API_KEY: Your Exa.ai API key (used if not provided viaWithAPIKey)