Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication errors should specify if the failure is from portkey's side or the providers #344

Open
hargup opened this issue May 9, 2024 · 0 comments
Labels
bug Something isn't working triage

Comments

@hargup
Copy link

hargup commented May 9, 2024

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
@hargup hargup added the bug Something isn't working label May 9, 2024
@github-actions github-actions bot added the triage label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant