Repository: moeru-ai/airi
File: packages/stage-ui/src/stores/providers/openai-compatible-builder.ts (TypeScript)

Code before:

      if (errors.length > 0) {
        return {
          errors,
          reason: errors.map(e => e.message).join(', '),
          valid: false,
        }
      }

      const validationChecks = validation || []

      // Auto-detect first available model for validation
      let model = 'test' // fallback to `test` if fails
      try {
        const models = await listModels({
          apiKey,
          baseURL: baseUrl,
          headers: {
            ...additionalHeaders,
            Authorization: `Bearer ${apiKey}`,
          },
        })
          .then(models => models.filter(model =>
            [
              // exclude embedding models
              'embed',
              // bypass gemini pro quota
              // TODO: more elegant solution
              'gemini-2.5-pro',
            ].every(str => !model.id.includes(str)),
          ))

        if (models.length > 0)
          model = models[0].id
      }
      catch (e) {
        console.warn(`Model auto-detection failed: ${(e as Error).message}`)
      }

      // Health check = try generating text (was: fetch(`${baseUrl}chat/completions`))
      if (validationChecks.includes('health')) {
        try {
          await generateText({
            apiKey,
            baseURL: baseUrl,
            headers: {
              ...additionalHeaders,
              Authorization: `Bearer ${apiKey}`,
            },
            model,
            messages: message.messages(message.user('ping')),

Review comment (suggestion):
```suggestion
              // exclude embedding models
              'embed',
              // exclude tts models, specifically for OpenAI
              'tts',
```

Code after:

      if (errors.length > 0) {
        return {
          errors,
          reason: errors.map(e => e.message).join(', '),
          valid: false,
        }
      }

      const validationChecks = validation || []

      // Auto-detect first available model for validation
      let model = 'test' // fallback to `test` if fails
      try {
        const models = await listModels({
          apiKey,
          baseURL: baseUrl,
          headers: {
            ...additionalHeaders,
            Authorization: `Bearer ${apiKey}`,
          },
        })
          .then(models => models.filter(model =>
            [
              // exclude embedding models
              'embed',
              // exclude tts models, specifically for OpenAI
              'tts',
              // bypass gemini pro quota
              // TODO: more elegant solution
              'gemini-2.5-pro',
            ].every(str => !model.id.includes(str)),
          ))

        if (models.length > 0)
          model = models[0].id
      }
      catch (e) {
        console.warn(`Model auto-detection failed: ${(e as Error).message}`)
      }

      // Health check = try generating text (was: fetch(`${baseUrl}chat/completions`))
      if (validationChecks.includes('health')) {
        try {
          await generateText({
            apiKey,
            baseURL: baseUrl,
            headers: {
              ...additionalHeaders,
              Authorization: `Bearer ${apiKey}`,
            },