Developing, testing, and deploying GUI-based AI agents is complex. Developers waste precious time wrestling with cloud instances, VNC servers, and environment configurations instead of focusing on what matters: building intelligent agents.
Lybic is the infrastructure layer for your GUI agents.
Lybic (/ΛlaΙͺbΙͺk/) provides a robust, on-demand infrastructure platform designed specifically for the AI agent development lifecycle. This SDK for Go is your command center for programmatically controlling the entire Lybic ecosystem, empowering you to build, test, and scale your agents with unprecedented speed and simplicity.
First, install the package from the Go package repository:
go get github.com/lybic/lybic-sdk-goInitialize the client in your Go application. You can pass nil to the NewClient function to configure the client from environment variables, or provide a lybic.Config struct for programmatic configuration.
This example initializes the client using environment variables.
package main
import (
"context"
"fmt"
"github.com/lybic/lybic-sdk-go"
)
func main() {
// Passing nil initializes a client with environment variables
client, err := lybic.NewClient(nil)
if err != nil {
panic(err)
}
ctx := context.Background()
sandboxes, err := client.ListSandboxes(ctx)
if err != nil {
fmt.Printf("Error listing sandboxes: %v", err)
return
}
fmt.Printf("sandboxes: %+v", sandboxes)
}You can also configure the client programmatically by creating a Config object.
config := lybic.NewConfig() // Initializes with defaults and env variables
config.OrgId = "your-org-id"
config.ApiKey = "your-api-key"
config.Timeout = 20 // seconds
client, err := lybic.NewClient(config)
if err != nil {
panic(err)
}The client can be configured with the following options, either through the Config struct or environment variables:
| Struct Field | Environment Variable | Description | Default Value |
|---|---|---|---|
OrgId |
LYBIC_ORG_ID |
Required. Your organization ID. | "" |
ApiKey |
LYBIC_API_KEY |
Your API key for authentication. | "" |
Endpoint |
LYBIC_API_ENDPOINT |
The API endpoint URL. | https://api.lybic.cn |
Timeout |
- | HTTP request timeout in seconds. | 10 |
ExtraHeaders |
- | A map of extra HTTP headers to send with each request. | nil |
Logger |
- | A custom logger instance. See the Logging section. | nil (disabled) |
The Lybic SDK provides a comprehensive client for interacting with all major platform features.
All examples are available in the examples.md
ListSandboxes(ctx): Retrieve a list of all available sandboxes.CreateSandbox(ctx, dto): Create a new sandbox.GetSandbox(ctx, sandboxId): Retrieve details for a specific sandbox.DeleteSandbox(ctx, sandboxId): Delete a sandbox.ExtendSandbox(ctx, sandboxId, dto): Extend or modify a sandbox.
ExecuteComputerUseAction(ctx, sandboxId, dto): Perform an action (e.g., mouse click, keyboard input) on a sandbox.PreviewSandbox(ctx, sandboxId): Generate a preview (screenshot) of the sandbox state.
ListProjects(ctx): Get a list of all projects.CreateProject(ctx, dto): Create a new project.DeleteProject(ctx, projectId): Delete a project.
GetStats(ctx): Retrieve current platform statistics.ParseComputerUse(ctx, dto): Parse and validate computer use actions.
For interacting with the Model Context Protocol (MCP), which enables tool calling, you need to initialize a separate McpClient.
The NewMcpClient function creates a client for MCP services. It requires an McpOption struct, which can be configured in several ways.
You can initialize the McpClient directly from a lybic.Config object. The client will be created internally.
import (
"context"
"github.com/lybic/lybic-sdk-go"
)
func main() {
// Config can be loaded from environment variables
lybicConfig := lybic.NewConfig()
mcpOpt := lybic.McpOption{
UsingClientConfig: lybicConfig,
}
mcpClient, err := lybic.NewMcpClient(context.Background(), mcpOpt)
if err != nil {
panic(err)
}
defer mcpClient.Close()
// ... use the mcpClient
}If you already have an instance of the main lybic.Client, you can reuse it.
client, err := lybic.NewClient(nil) // Main client
if err != nil {
panic(err)
}
mcpOpt := lybic.McpOption{
UsingClient: client,
}
mcpClient, err := lybic.NewMcpClient(context.Background(), mcpOpt)
if err != nil {
panic(err)
}
defer mcpClient.Close()CallTools(ctx, args, service): Call a tool service likecomputer-usewith the specified arguments.
ListMcpServers(ctx): Get a list of all MCP servers.CreateMcpServer(ctx, dto): Create a new MCP server.GetDefaultMcpServer(ctx): Retrieve the default MCP server.DeleteMcpServer(ctx, mcpServerId): Delete an MCP server.SetMcpServerToSandbox(ctx, mcpServerId, dto): Associate an MCP server with a sandbox.
The Lybic Go SDK also provides a client for interacting with the Lybic Agent Cluster, which allows for more advanced control and automation of your GUI-based AI agents.
For detailed instructions and code examples, please see the Agent Service Documentation.
The SDK uses a flexible logging interface that allows you to integrate your own preferred logging library. Any logger that implements the lybic.Logger interface is supported. The interface is compatible with popular libraries like zap (SugaredLogger), logrus, zerolog, and slog.
The lybic.Logger interface is defined as:
type Logger interface {
Debug(...interface{})
Info(...interface{})
Warn(...interface{})
Error(...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}import (
"github.com/lybic/lybic-sdk-go"
"github.com/sirupsen/logrus"
)
func main() {
// Create a new logrus logger
customLogger := logrus.New()
customLogger.SetLevel(logrus.DebugLevel)
// Create a new Lybic client configuration
config := lybic.NewConfig()
config.OrgId = "your-org-id"
config.ApiKey = "your-api-key"
config.Logger = customLogger // Set the custom logger
// Initialize the client
client, err := lybic.NewClient(config)
if err != nil {
customLogger.Fatalf("Failed to create Lybic client: %v", err)
}
// ... use the client
}If no logger is provided, logging will be disabled.
This README provides a high-level overview. For detailed, up-to-date code examples, tutorials, and a complete API reference, please visit our official documentation site.
We welcome contributions from the community! Please see our Contributing Guidelines for more details on how to get involved.
This project is licensed under the MIT License. See the LICENSE file for details.