有人知道如何修复吗?官方的 sdk 过于复杂,我只想发出 fetch 请求。
const response = await fetch('https://api.groq.com/v1/engines/llama3/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${env.GROQ_API_KEY}`
},
body: JSON.stringify({
prompt,
// maxTokens: 150000, // Customize as needed
temperature: 0.5, // Customize as needed
topP: 1.0, // Customize as needed
n: 1, // Number of completions to generate
stop: null // Optional stopping sequence
})
});
curl "https://api.groq.com/openai/v1/chat/completions" \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GROQ_API_KEY}" \
-d '{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "Hello"
}
],
"model": "llama3-8b-8192",
"temperature": 1,
"max_tokens": 1024,
"top_p": 1,
"stream": true,
"stop": null
}'