This file (995B) exceeds the allowed full mode (48 kb) size. The editor full height is disabled, only scrolling is allowed.
If you wish to edit a file, it is recommended to use the scroll mode as some users do not like the full height mode.
import Groq from 'groq-sdk'
export default async (options) => {
const { socket, payload } = options
try {
const apiKey = (payload.apiKey || '').trim()
if (!apiKey) {
socket.emit(options.responseEvent, { status: 'ok', valid: true })
return
}
if (!apiKey.startsWith('gsk_') || apiKey.length < 20) {
socket.emit(options.responseEvent, { status: 'ok', valid: false, message: 'Invalid key format' })
return
}
const client = new Groq({ apiKey })
await client.chat.completions.create({
messages: [{ role: 'user', content: 'test' }],
model: 'openai/gpt-oss-120b',
max_tokens: 1,
})
socket.emit(options.responseEvent, { status: 'ok', valid: true })
} catch (e) {
console.error('validate-groq-api-key error', e.message)
socket.emit(options.responseEvent, { status: 'ok', valid: false, message: e.message })
}
}
| / | Focus search |
| ? | Show this help |
| Esc | Unfocus input |