MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / listModels

Method listModels

outdated/gemini/gemini.ts:785–806  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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
809const CONFIG_MAP = {

Callers 1

handleModelListFunction · 0.80

Calls 1

makeRequestMethod · 0.45

Tested by

no test coverage detected