package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type AgentSpec struct {
AgentName string `json:"agent_name"`
Description string `json:"description"`
SystemPrompt string `json:"system_prompt"`
ModelName string `json:"model_name"`
MaxLoops int `json:"max_loops"`
Temperature float64 `json:"temperature"`
}
type WorkflowConfig struct {
Name string `json:"name"`
Description string `json:"description"`
AgentCompletions []AgentSpec `json:"agent_completions"`
Tasks []string `json:"tasks"`
MaxLoops int `json:"max_loops"`
}
func main() {
API_BASE_URL := "https://api.swarms.world"
API_KEY := "your_api_key_here"
workflowConfig := WorkflowConfig{
Name: "Product Review Analysis Grid",
Description: "Multiple analysts reviewing multiple product categories",
AgentCompletions: []AgentSpec{
{
AgentName: "Technical Analyst",
Description: "Focuses on technical specifications and performance",
SystemPrompt: "You are a technical analyst. Evaluate products based on specifications, performance metrics, build quality, and technical innovation.",
ModelName: "gpt-4.1",
MaxLoops: 1,
Temperature: 0.3,
},
{
AgentName: "User Experience Analyst",
Description: "Focuses on usability and user satisfaction",
SystemPrompt: "You are a UX analyst. Evaluate products based on ease of use, user interface, customer satisfaction, and overall user experience.",
ModelName: "gpt-4.1",
MaxLoops: 1,
Temperature: 0.4,
},
{
AgentName: "Value Analyst",
Description: "Focuses on pricing and value proposition",
SystemPrompt: "You are a value analyst. Evaluate products based on pricing, cost-effectiveness, ROI, and overall value for money.",
ModelName: "gpt-4.1",
MaxLoops: 1,
Temperature: 0.3,
},
},
Tasks: []string{
"Analyze the smartphone market segment and top products",
"Analyze the laptop market segment and top products",
"Analyze the tablet market segment and top products",
},
MaxLoops: 1,
}
jsonData, _ := json.Marshal(workflowConfig)
req, _ := http.NewRequest("POST", API_BASE_URL+"/v1/batched-grid-workflow/completions", bytes.NewBuffer(jsonData))
req.Header.Set("x-api-key", API_KEY)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Printf("Response: %s\n", string(body))
}