Getting 401 error for connection in custom app but works via curl elsewhere - Groq

Full disclosure this is my first make custom app but I think I am following all the instructions available from make and the api (Groq) that I’m trying to connect to.

if I run the following from my terminal it works fine and produces an output:

curl -X POST “https://api.groq.com/openai/v1/chat/completions
-H “Authorization: Bearer ”
-H “Content-Type: application/json”
-d ‘{“messages”: [{“role”: “user”, “content”: “pick yes or no”}], “model”: “mixtral-8x7b-32768”}’

but when I try to create a connection in the custom app it comes back with a 401 error.

Connection:Communication

{
“url”: “https://api.groq.com/openai/v1/chat/completions”,
“method”: “POST”,
“headers”: {
“Authorization”: “Bearer {{paramaters.apiKey}}”,
“Content-Type”: “application/json”
},
“qs”: {
“messages”: [ { “role”: “user”, “content”: “can you hear me?” } ],
“model”: “mixtral-8x7b-32768”
},
“log”: {
“sanitize”: [
“request.headers.authorization”
]
}
}

Connection: Parameters

[
{
“name”: “apiKey”,
“type”: “text”,
“label”: “API Key”,
“help”: “Enter the API key provided by Groq”,
“required”: true
}
]

Base:

{
// Default request configuration
“baseUrl”: “https://api.groq.com/openai/v1”, // Default base URL for all modules and RPCs.
“method”: “POST”,
“headers”: {
“Authorization”: “Bearer {{connection.apiKey}}”,
“Content-Type”: “application/json”
},
“response”: {
“error”: {
“message”: “[{{statusCode}}] {{body.error}}”
}
},
“log”: {
“sanitize”: [ // Excludes sensitive parameters from logs.
“request.headers.authorization” // Omit HTTP header “Authorization”.
]
}
}

Modules: Communication

{
// Request to API endpoint.
“url”: “/chat/completions”, // Relative to base URL
“method”: “POST”,
“qs”: {
“messages”: [
{
“role”: “{{parameters.role}}”,
“content”: “{{parameters.prompt}}”
}
],
“model”: “mixtral-8x7b-32768”
},
“body”: {},
“response”: {
“output”: “{{body}}”
}
}

Module: Mappable Parameters

[
{
“name”: “role”,
“type”: “text”,
“label”: “Role”,
“required”: true
},
{
“name”: “prompt”,
“type”: “text”,
“label”: “Prompt”,
“required”: true
}
]

I’m not sure where I am going wrong, any insight would be appreciated.

i see on the cURL example you are using POST method and pass the param with -d
which means data (body)

and on the custom app you are using qs which is query params and you need to pass the data in the bodyy and not in the query params:

"body": {
“messages”: [ { “role”: “user”, “content”: “can you hear me?” } ],
“model”: “mixtral-8x7b-32768”
}
2 Likes