Eridian

Go SDK

github.com/eridian-ai/sdk-go with context and retries.

The Go SDK is github.com/eridian-ai/sdk-go. It uses context.Context for cancellation, honors X-Eridian-* headers, and unmarshals object: eridian.inference.response.

Install

go get github.com/eridian-ai/sdk-go

Requires Go 1.21 or later.

Client

package main

import (
    "context"
    "os"
    "time"

    "github.com/eridian-ai/sdk-go/eridian"
)

func main() {
    client := eridian.NewClient(
        eridian.WithAPIKey(os.Getenv("ERIDIAN_API_KEY")),
        eridian.WithProjectID("prj_legal_001"),
        eridian.WithTimeout(30*time.Second),
        eridian.WithRetryPolicy(eridian.RetryPolicy{MaxAttempts: 3}),
    )
    _ = client
}

Inference

resp, err := client.Inference.Create(context.Background(), &eridian.InferenceRequest{
    Model:     "auto",
    ProjectID: "prj_legal_001",
    Messages: []eridian.Message{
        {Role: "user", Content: "Summarize termination risk."},
    },
    Features:       []string{"pii_redaction", "semantic_cache"},
    IdempotencyKey: "contract-summary-4821-v1",
})
if err != nil {
    panic(err)
}
fmt.Println(resp.Object)         // eridian.inference.response
fmt.Println(resp.Eridian.Route)  // gpt or gemini
fmt.Println(resp.Eridian.CostUSD)

Streaming

stream, err := client.Inference.Stream(ctx, &eridian.InferenceRequest{
    Model:     "auto",
    ProjectID: "prj_legal_001",
    Messages:  []eridian.Message{{Role: "user", Content: "Draft the notice."}},
})
if err != nil {
    return err
}
defer stream.Close()

for stream.Next() {
    chunk := stream.Chunk()
    fmt.Print(chunk.Choices[0].Delta.Content)
}
return stream.Err()

Errors

var apiErr *eridian.Error
if errors.As(err, &apiErr) {
    log.Printf("code=%s request_id=%s status=%d", apiErr.Code, apiErr.RequestID, apiErr.Status)
}

eridian.Error surfaces rate_limit_exceeded, budget_exceeded, residency_violation, and model_unavailable as Code. Retry policy retries 408, 429, and 503 only.

Context and residency

Pass a deadline that exceeds routing timeout_ms. Set WithRegion("eu-west-1") on the client when the process is dedicated to one pin. Per-request Region on InferenceRequest must match the project pin when fail_closed is true.

See SDKs, Regions, and Errors.

Production API credentials are issued with an institution workspace. Contact sales if you need access.