@@ -229,8 +229,6 @@ export default defineCommand({
229229 const region = ( flags . region as string ) || "cn-beijing" ;
230230 const format = detectOutputFormat ( config . output ) ;
231231
232- const credential = await resolveConsoleGatewayCredential ( config ) ;
233-
234232 let models : string [ ] ;
235233 const typeMap = new Map < string , string > ( ) ;
236234
@@ -243,21 +241,8 @@ export default defineCommand({
243241 . filter ( Boolean ) ,
244242 ) ,
245243 ] ;
246- const searchResults = await Promise . all (
247- models . map ( ( name ) => fetchModelList ( config , credential . token , { name, pageSize : 50 } ) ) ,
248- ) ;
249- for ( let idx = 0 ; idx < models . length ; idx ++ ) {
250- const matched = searchResults [ idx ] . models . find ( ( item ) => item . model === models [ idx ] ) ;
251- if ( matched ) {
252- typeMap . set ( models [ idx ] , resolveModelType ( ( matched . capabilities as string [ ] ) || [ ] ) ) ;
253- }
254- }
255244 } else {
256- const modelInfos = await fetchAllModels ( config , credential . token ) ;
257- models = modelInfos . map ( ( info ) => info . name ) ;
258- for ( const info of modelInfos ) {
259- typeMap . set ( info . name , info . type ) ;
260- }
245+ models = [ ] ;
261246 }
262247
263248 const requestData = {
@@ -270,13 +255,33 @@ export default defineCommand({
270255 api : FREE_TIER_API ,
271256 data : requestData ,
272257 region,
273- token : credential . token . slice ( 0 , 8 ) + "..." ,
274258 } ,
275259 format ,
276260 ) ;
277261 return ;
278262 }
279263
264+ const credential = await resolveConsoleGatewayCredential ( config ) ;
265+
266+ if ( ! modelFlag ) {
267+ const modelInfos = await fetchAllModels ( config , credential . token ) ;
268+ models = modelInfos . map ( ( info ) => info . name ) ;
269+ for ( const info of modelInfos ) {
270+ typeMap . set ( info . name , info . type ) ;
271+ }
272+ requestData . queryFreeTierQuotaRequest . models = models ;
273+ } else {
274+ const searchResults = await Promise . all (
275+ models . map ( ( name ) => fetchModelList ( config , credential . token , { name, pageSize : 50 } ) ) ,
276+ ) ;
277+ for ( let idx = 0 ; idx < models . length ; idx ++ ) {
278+ const matched = searchResults [ idx ] . models . find ( ( item ) => item . model === models [ idx ] ) ;
279+ if ( matched ) {
280+ typeMap . set ( models [ idx ] , resolveModelType ( ( matched . capabilities as string [ ] ) || [ ] ) ) ;
281+ }
282+ }
283+ }
284+
280285 const [ quotaResult , stopResult ] = await Promise . all ( [
281286 callConsoleGateway ( config , credential . token , {
282287 api : FREE_TIER_API ,
0 commit comments