OpenCode Go Kit
A Go API for interacting with the OpenCode API.
Requirements
- Go: 1.26.4+ (to compile, run tests, and generate client bindings)
Installation
To integrate the OpenCode Go Kit into an existing Go project, run:
Quick Start Example
Here is a simple example demonstrating how to configure the client, instantiate the API,
and call a typed API method (e.g., AppAgents) returning Go types:
package main
import (
"context"
"fmt"
"log"
"github.com/dakolli/opencode-go-kit/pkg/api"
"github.com/dakolli/opencode-go-kit/pkg/client"
)
func main() {
ctx := context.Background()
// 1. Create client configuration (either pass values explicitly or let them fallback to environment variables)
config, err := api.NewClientCFG(
"http://localhost:4096", // OpenCode Server URL
"opencode", // Username
"pass1", // Password
)
if err != nil {
log.Fatalf("failed to initialize configuration: %v", err)
}
// 2. Instantiate the clean, typed API wrapper
opencodeAPI, err := api.NewAPI(config)
if err != nil {
log.Fatalf("failed to initialize API: %v", err)
}
// 3. Invoke a typed API method with full parameter support
// Our wrapper automatically unwraps sum-type interfaces into clean, native slice types
agents, err := opencodeAPI.AppAgents(ctx, client.AppAgentsParams{})
if err != nil {
log.Fatalf("API invocation failed: %v", err)
}
fmt.Printf("Retrieved %d AI agents from OpenCode:\n", len(agents))
for _, agent := range agents {
fmt.Printf(" - %s: %s\n", agent.Name, agent.Description.Value)
}
}
API Endpoint Coverage
We have wrapped 83 out of 83 (100.00%) OpenAPI client methods in our clean, typed API wrapper layer.