如何避免使用 SDK 并通过 Groq API 使用原始获取?

问题描述 投票:0回答:1

有人知道如何修复吗?官方的 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
    })
});
javascript node.js fetch-api
1个回答
0
投票
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
       }'
© www.soinside.com 2019 - 2024. All rights reserved.