mirror of
https://github.com/hanzoai/sdk.git
synced 2026-10-30 15:00:56 +00:00
- Add complete multi-language SDK matrix (Python, TS, Go, Rust, PHP, Ruby, Dart, Java, Kotlin, Swift, C++, C#, Fetch, Angular, CLI) - Fix dedicated org repository links (hanzo-php/sdk, hanzo-ruby/sdk, hanzo-dart/sdk, hanzo-go/sdk, etc.) - Add OpenAPI 3.1 canonical specification (spec/openapi.json) for /v1 routes and Kai decision governance - Add wire conformance test fixtures (auth, chat, SSE streaming, tool calls, Kai decisions, embeddings, errors) - Add standalone zero-dependency Python conformance runner and local mock gateway (conformance/runner.py) - Add runnable multi-language quickstarts in examples/ - Add GitHub Actions CI workflow for conformance verification (.github/workflows/conformance.yml) Co-authored-by: Hanzo Dev <[email protected]>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/hanzoai/go-sdk"
|
|
)
|
|
|
|
func main() {
|
|
apiKey := os.Getenv("HANZO_API_KEY")
|
|
if apiKey == "" {
|
|
apiKey = "sk-test-key"
|
|
}
|
|
|
|
client := hanzo.NewClient(hanzo.WithAPIKey(apiKey))
|
|
ctx := context.Background()
|
|
|
|
// 1. List Models
|
|
fmt.Println("--- 1. List Models ---")
|
|
models, err := client.Models.List(ctx)
|
|
if err == nil && len(models.Data) > 0 {
|
|
fmt.Printf("Model count: %d, first: %s\n", len(models.Data), models.Data[0].ID)
|
|
}
|
|
|
|
// 2. Chat Completion
|
|
fmt.Println("\n--- 2. Chat Completion ---")
|
|
resp, err := client.Chat.CreateCompletion(ctx, hanzo.ChatCompletionRequest{
|
|
Model: "zen5",
|
|
Messages: []hanzo.ChatMessage{
|
|
{Role: "user", Content: "Hello from Go!"},
|
|
},
|
|
})
|
|
if err == nil && len(resp.Choices) > 0 {
|
|
fmt.Printf("Reply: %s\n", resp.Choices[0].Message.Content)
|
|
}
|
|
|
|
// 3. Kai Decision
|
|
fmt.Println("\n--- 3. Kai Decision Evaluation ---")
|
|
decision, err := client.Decisions.Evaluate(ctx, hanzo.KaiDecisionRequest{
|
|
AgentID: "agent-go-01",
|
|
PolicyID: "pol-safety-core",
|
|
Action: map[string]any{"type": "exec", "payload": map[string]any{"cmd": "status"}},
|
|
})
|
|
if err == nil {
|
|
fmt.Printf("Decision: %s (Score: %.2f)\n", decision.Verdict, decision.Confidence)
|
|
}
|
|
}
|