package aiprovider import ( "context" "encoding/json" "net/http" "os" "testing" "time" ) func TestAgentRouterSmoke(t *testing.T) { if os.Getenv("AGENTROUTER_SMOKE") != "1" { t.Skip("set AGENTROUTER_SMOKE=1 to run the real provider contract") } client := NewAgentRouter(Config{ BaseURL: os.Getenv("AGENTROUTER_BASE_URL"), APIKey: os.Getenv("AGENTROUTER_API_KEY"), Model: os.Getenv("AGENTROUTER_MODEL"), Timeout: 30 * time.Second, }, &http.Client{}) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() result, _, err := client.Generate(ctx, Request{ SchemaName: "health", Schema: map[string]any{ "type": "object", "properties": map[string]any{"ok": map[string]any{"type": "boolean"}}, "required": []string{"ok"}, "additionalProperties": false, }, Instructions: "Return a structured health response.", Input: json.RawMessage(`{"healthCheck":true}`), MaxOutputTokens: 64, }) if err != nil { t.Fatal(err) } var response struct { OK bool `json:"ok"` } if json.Unmarshal(result, &response) != nil || !response.OK { t.Fatalf("unexpected provider response: %s", result) } }