diff --git a/pkg/lmcli/provider/openai/openai.go b/pkg/lmcli/provider/openai/openai.go index 6dd053f..1a34a17 100644 --- a/pkg/lmcli/provider/openai/openai.go +++ b/pkg/lmcli/provider/openai/openai.go @@ -166,7 +166,14 @@ func (c *OpenAIClient) sendRequest(ctx context.Context, req *http.Request) (*htt req.Header.Set("Authorization", "Bearer "+c.APIKey) client := &http.Client{} - return client.Do(req.WithContext(ctx)) + resp, err := client.Do(req.WithContext(ctx)) + + if resp.StatusCode != 200 { + bytes, _ := io.ReadAll(resp.Body) + return resp, fmt.Errorf("%v", string(bytes)) + } + + return resp, err } func (c *OpenAIClient) CreateChatCompletion(