High-performance Go client library for AINative Studio APIs with advanced concurrency, observability, and enterprise features.
- High-Performance HTTP Client: Optimized for concurrent operations with connection pooling
- Advanced Retry Logic: Exponential backoff with jitter and circuit breaker
- Full API Coverage: Complete support for ZeroDB, Agent Swarm, and Memory APIs
- Type Safety: Comprehensive struct definitions with JSON tags
- Context Propagation: Proper Go context handling throughout
- Observability: OpenTelemetry integration for metrics and tracing
- Enterprise Ready: Connection pooling, timeouts, and resource management
go mod init your-project
go get github.com/AINative-Studio/Go-SDKpackage main
import (
"context"
"fmt"
"log"
"github.com/AINative-Studio/Go-SDK/ainative"
)
func main() {
// Create client with API key
client, err := ainative.NewClient(&ainative.Config{
APIKey: "your-api-key",
BaseURL: "https://api.ainative.studio",
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// List projects
projects, err := client.ZeroDB.Projects.List(ctx, &ainative.ListProjectsRequest{
Limit: 10,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d projects\n", len(projects.Projects))
}// Search vectors
results, err := client.ZeroDB.Vectors.Search(ctx, "project-id", &ainative.VectorSearchRequest{
Vector: []float64{0.1, 0.2, 0.3},
TopK: 5,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Found %d similar vectors\n", len(results.Matches))// Start an agent swarm
swarm, err := client.AgentSwarm.Start(ctx, &ainative.StartSwarmRequest{
ProjectID: "project-id",
Objective: "Analyze codebase and suggest improvements",
Agents: []ainative.AgentConfig{
{Type: "code_analyzer", Count: 2},
{Type: "security_scanner", Count: 1},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Started swarm: %s\n", swarm.ID)- β Projects: Create, list, get, update, suspend, delete
- β Vectors: Upsert, search, get statistics, manage namespaces
- β Memory: Store, search, list, tag management
- β Analytics: Usage statistics, cost analysis, performance metrics
- β Swarms: Start, stop, get status, list active swarms
- β Orchestration: Task assignment, agent coordination
- β Monitoring: Real-time metrics, agent health checks
- β Configuration: Agent types, custom prompts, resource limits
- β Authentication: API key management, JWT tokens
- β Error Handling: Structured error responses with retry logic
- β Rate Limiting: Automatic backoff and retry strategies
- β Observability: OpenTelemetry metrics and tracing
import (
"net/http"
"time"
"github.com/AINative-Studio/Go-SDK/ainative"
)
client, err := ainative.NewClient(&ainative.Config{
APIKey: "your-api-key",
BaseURL: "https://api.ainative.studio",
HTTPClient: &http.Client{
Timeout: 30 * time.Second,
Transport: &http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 10,
IdleConnTimeout: 90 * time.Second,
},
},
})import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)
client, err := ainative.NewClient(&ainative.Config{
APIKey: "your-api-key",
BaseURL: "https://api.ainative.studio",
Tracer: otel.Tracer("ainative-client"),
})client, err := ainative.NewClient(&ainative.Config{
APIKey: "your-api-key",
BaseURL: "https://api.ainative.studio",
RetryConfig: &ainative.RetryConfig{
MaxRetries: 5,
InitialDelay: 100 * time.Millisecond,
MaxDelay: 10 * time.Second,
BackoffMultiplier: 2.0,
Jitter: true,
},
})The Go SDK is optimized for high-performance operations:
- Connection Pooling: Reuses HTTP connections for efficiency
- Concurrent Operations: Thread-safe client with goroutine support
- Memory Efficient: Minimal allocations with object pooling
- Fast JSON: Optimized JSON marshaling/unmarshaling
- Benchmarks: 50%+ faster than Python SDK, 30%+ faster than TypeScript
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run benchmarks
go test -bench=. ./...
# Run integration tests (requires API key)
AINATIVE_API_KEY=your-key go test -tags=integration ./...See the examples/ directory for comprehensive examples:
- Basic Operations: Project management, vector search
- Advanced Workflows: Agent swarm orchestration, memory management
- Performance: Concurrent operations, batch processing
- Observability: Metrics collection, distributed tracing
We welcome contributions! See CONTRIBUTING.md for development setup, style conventions, and the pull request process. Quick version:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make changes and add tests
- Run tests:
go test ./... - Submit a pull request
Licensed under the MIT License. See LICENSE for details.