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

Inconsistent error message for invalid model depending on API key #690

Open
dandv opened this issue Feb 24, 2025 · 0 comments
Open

Inconsistent error message for invalid model depending on API key #690

dandv opened this issue Feb 24, 2025 · 0 comments

Comments

@dandv
Copy link
Contributor

dandv commented Feb 24, 2025

This is an issue with the Messages API rather than the SDK: attempting to use an invalid model identifier results in different error messages, depending on the API key being specified.

const response = await fetch('https://api.anthropic.com/v1/messages', {
  method: 'POST',
  headers: {
    'x-api-key': 'sk-ant-api03-H8yfz...-Q7161AAA',
    'anthropic-version': '2023-06-01',  // required by the Messages API
  },
  body: JSON.stringify({
    messages: [{ role: 'user', content: 'Hello' }],
    max_tokens: 4096,  // required, maximum
    model: 'invalid-model',
  }),
});
console.log(await response.json());

With the API key above, which I obtained from my Anthropic console, I see the following error:

{
  "type": "error",
  "error": { "type": "not_found_error", "message": "model: invalid-model" }
}

With a different API key, sk-ant-api03-1WH_3x...-ONyGHQAA, provided by @zack-anthropic, I see a different error message when running the same code:

{
  "type": "error",
  "error": { "type": "not_found_error", "message": "Not found" }
}

Related: #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant