(client tls_client.HttpClient, api_key string, proxy string)
| 28 | return header |
| 29 | } |
| 30 | func GerOrganizationId(client tls_client.HttpClient, api_key string, proxy string) (string, error) { |
| 31 | header := baseHeader() |
| 32 | |
| 33 | if proxy != "" { |
| 34 | client.SetProxy(proxy) |
| 35 | } |
| 36 | req, err := http.NewRequest(http.MethodGet, "https://api.groq.com/platform/v1/user/profile", nil) |
| 37 | header.Set("authorization", "Bearer "+api_key) |
| 38 | req.Header = header |
| 39 | if err != nil { |
| 40 | return "", err |
| 41 | } |
| 42 | response, err := client.Do(req) |
| 43 | if err != nil { |
| 44 | return "", err |
| 45 | } |
| 46 | if response.StatusCode != 200 { |
| 47 | return "", errors.New("response status code is not 200") |
| 48 | } |
| 49 | var result groq.Profile |
| 50 | err = json.NewDecoder(response.Body).Decode(&result) |
| 51 | if err != nil { |
| 52 | return "", err |
| 53 | } |
| 54 | return result.User.Orgs.Data[0].Id, nil |
| 55 | } |
| 56 | |
| 57 | func GetSessionToken(client tls_client.HttpClient, api_key string, proxy string) (groq.AuthenticateResponse, error) { |
| 58 | if proxy != "" { |
nothing calls this directly
no test coverage detected