Skip to content

Veri5ied/valyu-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Valyu

Valyu Go SDK

Go Reference License Release

The official Go SDK for Valyu's DeepSearch API.
Access academic papers, real-time web content, structured data, and AI-powered research.


Installation

go get github.com/Veri5ied/valyu-go

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/Veri5ied/valyu-go/valyu"
    "github.com/Veri5ied/valyu-go/valyu/search"
)

func main() {
    client, err := valyu.New("") // Uses VALYU_API_KEY env var
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    resp, _ := client.Search.Search(ctx, "machine learning transformers", nil)
    for _, r := range resp.Results {
        fmt.Println(r.Title)
    }
}

Authentication

export VALYU_API_KEY="your-api-key"

Or pass directly:

client, err := valyu.New("your-api-key")

APIs

Search

import "github.com/Veri5ied/valyu-go/valyu/search"
import "github.com/Veri5ied/valyu-go/valyu/common"

resp, _ := client.Search.Search(ctx, "query", &search.Options{
    SearchType:    common.SearchTypeProprietary,
    MaxNumResults: 20,
    IncludedSources: []string{"valyu/valyu-arxiv"},
})

Contents

import "github.com/Veri5ied/valyu-go/valyu/contents"
import "github.com/Veri5ied/valyu-go/valyu/common"

resp, _ := client.Contents.Get(ctx, []string{"https://example.com"}, &contents.Options{
    Summary:        true,
    ResponseLength: common.ResponseLengthMax,
})

Answer

import "github.com/Veri5ied/valyu-go/valyu/answer"
import "github.com/Veri5ied/valyu-go/valyu/common"

resp, _ := client.Answer.Answer(ctx, "What are transformers?", &answer.Options{
    SearchType: common.SearchTypeAll,
    FastMode:   true,
})

DeepResearch

import "github.com/Veri5ied/valyu-go/valyu/deepresearch"
import "github.com/Veri5ied/valyu-go/valyu/common"

task, _ := client.DeepResearch.Create(ctx, &deepresearch.CreateOptions{
    Query: "AI safety research summary",
    Mode:  common.DeepResearchModeFast,
})

status, _ := client.DeepResearch.Get(ctx, task.DeepResearchID)

Batch

import "github.com/Veri5ied/valyu-go/valyu/batch"
import "github.com/Veri5ied/valyu-go/valyu/common"

newBatch, _ := client.Batch.Create(ctx, &batch.CreateOptions{
    Name: "Research Batch",
    Mode: common.DeepResearchModeStandard,
})

status, _ := client.Batch.Get(ctx, newBatch.BatchID)

Datasources

sources, _ := client.Datasources.List(ctx)

Configuration

client, err := valyu.New("api-key",
    valyu.WithBaseURL("https://custom.api.com"),
    valyu.WithTimeout(60 * time.Second),
    valyu.WithHTTPClient(customClient),
)

Error Handling

resp, err := client.Search.Search(ctx, "query", nil)
if err != nil {
    log.Fatal("Network error:", err)
}
if !resp.Success {
    log.Fatal("API error:", resp.Error)
}

License

MIT License - see LICENSE for details.

About

Valyu Go package

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages