()
| 783 | } |
| 784 | |
| 785 | async listModels(): Promise<string[]> { |
| 786 | const url = `${this.baseUrl}/v1beta/models`; |
| 787 | |
| 788 | const headers: Record<string, string> = { |
| 789 | 'x-goog-api-key': this.apiKey |
| 790 | }; |
| 791 | |
| 792 | const response = await HttpClient.makeRequest(url, { |
| 793 | method: 'GET', |
| 794 | headers |
| 795 | }); |
| 796 | |
| 797 | if (response.status !== 200 || response.data?.error) { |
| 798 | const errorMsg = response.data?.error?.message || JSON.stringify(response.data); |
| 799 | const sanitizedMsg = errorMsg.replace(/api_key:[A-Za-z0-9_-]+/g, 'api_key:***'); |
| 800 | throw new Error(`API Error: ${response.status} - ${sanitizedMsg}`); |
| 801 | } |
| 802 | |
| 803 | return (response.data?.models || []).map((model: any) => |
| 804 | model.name?.replace('models/', '') || model.name |
| 805 | ); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | const CONFIG_MAP = { |
no test coverage detected