Closed TianzeWang closed 1 month ago
Updating the curl command that could work correctly
curl -X POST "https://cld.wangtianze3682.workers.dev/v1/messages" \ -H "x-api-key: MYAPIKEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-3-5-sonnet", "max_tokens": 4096, "messages": [ {"role": "user", "content": "Your test message here"} ] }'
What happened?
I set up my customize API, which is based on a cloudflare service routing the Google vertex Claude API, and I have my baseurl and the api_key I defined. I set up the same in yaml and .env, and the endpoint could show in dropdown list, but it will pop error.
I checked the log:
{ "error": { "message": "invalid x-api-key", "type": "authentication_error" }, "headers": { "access-control-allow-origin": "*", "cf-ray": "8c5fbc08efd2d1be-KIX", "connection": "keep-alive", "content-length": "86", "content-type": "application/json", "date": "Fri, 20 Sep 2024 06:24: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=Focmn0%2FKf3nsCPf%2BPx5%2Ff6xNLWgZ23rSnpqHC4yzId7KHvOE7L7r%2F5pN86xtH4bI8ufAY3DPB49n1RmR%2FKl5Yqvpbe8W8RjnKdMcGMkSl2fIf49zvD%2BA0PUQiMZAFADKCILaAEdnjodEXz0NOp6YCz4%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}", "server": "cloudflare", "vary": "Accept-Encoding" }, "level": "error", "message": "[handleAbortError] AI response error; aborting request: 401 invalid x-api-key", "stack": "Error: 401 invalid x-api-key\n at APIError.generate (/app/api/node_modules/openai/error.js:48:20)\n at OpenAI.makeStatusError (/app/api/node_modules/openai/core.js:263:33)\n at OpenAI.makeRequest (/app/api/node_modules/openai/core.js:306:30)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async ChatCompletionStream._createChatCompletion (/app/api/node_modules/openai/lib/ChatCompletionStream.js:53:24)\n at async ChatCompletionStream._runChatCompletion (/app/api/node_modules/openai/lib/AbstractChatCompletionRunner.js:314:16)", "status": 401, "type": "authentication_error" }
Steps to Reproduce
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Screenshots
No response
Code of Conduct