From 45351a6a792f87841d8a15e628a90786a54affce Mon Sep 17 00:00:00 2001 From: Avisek Date: Fri, 13 Feb 2026 20:38:43 +0530 Subject: [PATCH] refactor: Trim trailing slashes from the API base URL and enhance API error messages with status codes. --- pkg/providers/http_provider.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/providers/http_provider.go b/pkg/providers/http_provider.go index b1d0c03..fc78a18 100644 --- a/pkg/providers/http_provider.go +++ b/pkg/providers/http_provider.go @@ -42,7 +42,7 @@ func NewHTTPProvider(apiKey, apiBase, proxy string) *HTTPProvider { return &HTTPProvider{ apiKey: apiKey, - apiBase: apiBase, + apiBase: strings.TrimRight(apiBase, "/"), httpClient: client, } } @@ -116,7 +116,7 @@ func (p *HTTPProvider) Chat(ctx context.Context, messages []Message, tools []Too } if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("API error: %s", string(body)) + return nil, fmt.Errorf("API request failed:\n Status: %d\n Body: %s", resp.StatusCode, string(body)) } return p.parseResponse(body)