Go SDK
The Connix Go SDK provides a robust and type-safe way to integrate Connix services into your Go applications. Built with performance and developer experience in mind, it offers idiomatic Go interfaces for all Connix platform features.
Installation
Section titled “Installation”Install the Connix Go SDK using Go modules:
go get github.com/connix-io/connix-go
Authentication
Section titled “Authentication”Before using the SDK, you’ll need an API key from the Connix Console:
package main
import ( "context" "log"
connix "github.com/connix-io/connix-go")
func main() { // Initialize client with API key client := connix.NewClient("your-api-key-here")
// Or use environment variable CONNIX_API_KEY client := connix.NewClientFromEnv()}
Working with Projects
Section titled “Working with Projects”Projects are the primary organizational unit in Connix. Here’s how to create and manage them:
ctx := context.Background()
// Create a new projectproject, err := client.CreateProject(ctx, &connix.CreateProjectRequest{ Name: "my-ai-project",})if err != nil { log.Fatal(err)}fmt.Printf("Created project: %s (ID: %d)\n", project.Name, project.Id)
// List all projectsprojects, err := client.ListProjects(ctx)if err != nil { log.Fatal(err)}
for _, p := range projects.Projects { fmt.Printf("Project: %s (ID: %d)\n", p.Name, p.Id)}
Launching Agents
Section titled “Launching Agents”Deploy AI agents to your Connix environment:
// Launch an agent within a projectagent, err := client.LaunchAgent(ctx, &connix.LaunchAgentRequest{ Name: "code-assistant", ProjectId: project.Id,})if err != nil { log.Fatal(err)}fmt.Printf("Agent launched: %s\n", agent.Message)
Configuration Options
Section titled “Configuration Options”Customize the client behavior with configuration options:
import "time"
client := connix.NewClient( "your-api-key", connix.WithBaseURL("https://api.connix.io"), connix.WithTimeout(30*time.Second), connix.WithRetries(3), connix.WithUserAgent("MyApp/1.0"),)
Error Handling
Section titled “Error Handling”The SDK provides structured error handling with detailed error information:
project, err := client.CreateProject(ctx, req)if err != nil { var connixErr *connix.APIError if errors.As(err, &connixErr) { switch connixErr.StatusCode { case 401: log.Fatal("Invalid API key") case 429: log.Printf("Rate limited, retry after: %s", connixErr.RetryAfter) default: log.Printf("API error: %s (code: %d)", connixErr.Message, connixErr.StatusCode) } } else { log.Printf("Network or other error: %v", err) } return}
Complete Example
Section titled “Complete Example”Here’s a complete example that demonstrates the typical workflow:
package main
import ( "context" "fmt" "log"
connix "github.com/connix-io/connix-go")
func main() { // Initialize client client := connix.NewClientFromEnv() ctx := context.Background()
// Create a project project, err := client.CreateProject(ctx, &connix.CreateProjectRequest{ Name: "ml-training-pipeline", }) if err != nil { log.Fatal(err) }
fmt.Printf("✅ Created project: %s\n", project.Name)
// Launch an agent for the project agent, err := client.LaunchAgent(ctx, &connix.LaunchAgentRequest{ Name: "data-processor", ProjectId: project.Id, }) if err != nil { log.Fatal(err) }
fmt.Printf("🚀 Launched agent: %s\n", agent.Message)
// List all projects to verify projects, err := client.ListProjects(ctx) if err != nil { log.Fatal(err) }
fmt.Printf("📋 Total projects: %d\n", len(projects.Projects))}
API Reference
Section titled “API Reference”Client Methods
Section titled “Client Methods”Projects
Section titled “Projects”CreateProject(ctx context.Context, req *CreateProjectRequest) (*Project, error)
ListProjects(ctx context.Context) (*ListProjectsResponse, error)
Agents
Section titled “Agents”LaunchAgent(ctx context.Context, req *LaunchAgentRequest) (*LaunchAgentResponse, error)
Utilities
Section titled “Utilities”Hello(ctx context.Context, name string) (*HelloResponse, error)
Configuration Options
Section titled “Configuration Options”WithBaseURL(url string)
- Set custom API base URLWithTimeout(duration time.Duration)
- Set request timeoutWithRetries(count int)
- Set retry attempts for failed requestsWithUserAgent(ua string)
- Set custom User-Agent header
type Project struct { Id int32 `json:"id"` Name string `json:"name"`}
type CreateProjectRequest struct { Name string `json:"name"`}
type LaunchAgentRequest struct { Name string `json:"name"` ProjectId int32 `json:"project_id"`}
Examples Repository
Section titled “Examples Repository”For more comprehensive examples, visit our examples repository which includes:
- Multi-agent workflows
- Integration with popular Go frameworks
- Error handling patterns
- Production deployment examples
Support & Community
Section titled “Support & Community”- Documentation: docs.connix.io
- GitHub: github.com/connix-io/connix-go
- Issues: Report bugs and request features
- Email: engineering@connix.io