gateway
gateway copied to clipboard
Authentication errors should specify if the failure is from portkey's side or the providers
What Happened?
code
const { OpenAI } = require('openai');
const { PORTKEY_GATEWAY_URL, createHeaders } = require('portkey-ai');
const gateway = new OpenAI({
apiKey: process.env.ANTHROPIC_API_KEY,
baseURL: PORTKEY_`GATEWAY_URL,
defaultHeaders: createHeaders({
provider: "anthropic"
})
});
async function main(){
const chatCompletion = await gateway.chat.completions.create({
messages: [{ role: 'user', content: 'Who are you?' }],
model: 'claude-3-sonnet-20240229',
});
console.log(chatCompletion.data.choices[0].message.content);
}
main();```
This returns a cryptic 401
return new AuthenticationError(status, error, message, headers);
^
AuthenticationError: 401 status code (no body) at APIError.generate (/Users/harshwork/code/ai-browser-node/node_modules/openai/error.js:48:20) at OpenAI.makeStatusError (/Users/harshwork/code/ai-browser-node/node_modules/openai/core.js:263:33) at OpenAI.makeRequest (/Users/harshwork/code/ai-browser-node/node_modules/openai/core.js:306:30) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async main (/Users/harshwork/code/ai-browser-node/form_filler/llm_call_test.js:14:26) { status: 401, headers: { 'alt-svc': 'h3=":443"; ma=86400', 'cf-ray': '88102e39cdd3e61a-DEL', connection: 'keep-alive', 'content-length': '79', 'content-type': 'application/json;charset=UTF-8', date: 'Thu, 09 May 2024 08:04:47 GMT', nel: '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', 'report-to': '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=rI%2B%2FYX8m2lYsFzF00%2FnKGQVEHEbVc4Jo55rvoaKlwkk1%2BSGljN7dcLlVrO2RjPpSR5v%2Fe3HNW%2BT5%2BTJt0GIFjzbMksfLcAtPsa2lj%2BBo9IEa7D%2F5LUGcdnCFHkvKNQB7"}],"group":"cf-nel","max_age":604800}', server: 'cloudflare', vary: 'Accept-Encoding' }, request_id: undefined, error: undefined, code: undefined, param: undefined, type: undefined }
### What Should Have Happened?
Error message should specify if the error is from portkey's side or the providers and if it is running locally or on hosted version.
### Relevant Code Snippet
_No response_
### Your Twitter/LinkedIn
https://twitter.com/hargup13