aider icon indicating copy to clipboard operation
aider copied to clipboard

Unexpected error: litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":

Open acquirk opened this issue 1 year ago • 5 comments

I think I used the wrong API Key in my .env file, and this happened. This may be expected behavior but I hadn't seen it. It's an issue with litellm, not aider specifically, but I assumed aider should handle this behind the scenes.

Unexpected error: litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}' Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/utils.py", line 10486, in next self.fetch_sync_stream() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/utils.py", line 10591, in fetch_sync_stream self.completion_stream = self.make_call(client=litellm.module_level_client) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/llms/anthropic.py", line 659, in make_sync_call raise AnthropicError(status_code=response.status_code, message=response.read()) litellm.llms.anthropic.AnthropicError: b'{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aider/coders/base_coder.py", line 1124, in send_message yield from self.send(messages, functions=self.functions) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aider/coders/base_coder.py", line 1408, in send yield from self.show_send_output_stream(completion) File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/aider/coders/base_coder.py", line 1482, in show_send_output_stream for chunk in completion: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/utils.py", line 10582, in next raise exception_type( ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/utils.py", line 8438, in exception_type raise e File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/litellm/utils.py", line 6894, in exception_type raise AuthenticationError( litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AnthropicException - b'{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}'

Aider version: 0.56.0 Python version: 3.11.2 Platform: macOS-11.7.10-x86_64-i386-64bit Python implementation: CPython Virtual environment: No OS: Darwin 20.6.0 (64bit) Git version: git version 2.24.3 (Apple Git-128)

Aider v0.56.0 Main model: claude-3-5-sonnet-20240620 with diff edit format, infinite output Weak model: claude-3-haiku-20240307 Git repo: .git with 783 files Repo-map: using 1024 tokens, auto refresh

acquirk avatar Sep 11 '24 13:09 acquirk

Start aider with --verbose and see if it loads the correct authentication information.

You can also use /settings inside aider to see the current setup.

fry69 avatar Sep 11 '24 13:09 fry69

a similar thing happens with ollama.

ollama t=2024-09-12T07:43:47+0000 lvl=info msg="join connections" obj=join

aider:

~/dev$ aider --verbose --model ollama/llama3.1 Config files search order, if no --config:

  • /home/emincan/dev/.aider.conf.yml
  • /home/emincan/.aider.conf.yml ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Too soon to check version: 0.4 hours Command Line Args: --verbose --model ollama/llama3.1 Defaults: --model-settings-file:.aider.model.settings.yml --model-metadata-file:.aider.model.metadata.json --map-refresh: auto --cache-keepalive-pings:0 --map-multiplier-no-files:2 --env-file: /home/emincan/dev/.env --input-history-file:/home/emincan/dev/.aider.input.history --chat-history-file:/home/emincan/dev/.aider.chat.history.md --user-input-color:#00cc00 --tool-error-color:#FF2222 --tool-warning-color:#FFA500 --assistant-output-color:#0088ff --code-theme: default --aiderignore: /home/emincan/dev/.aiderignore --lint-cmd: [] --test-cmd: [] --voice-language: en --encoding: utf-8

Option settings:

  • aiderignore: /home/emincan/dev/.aiderignore
  • anthropic_api_key: None
  • apply: None
  • assistant_output_color: #0088ff
  • attribute_author: True
  • attribute_commit_message_author: False
  • attribute_commit_message_committer: False
  • attribute_committer: True
  • auto_commits: True
  • auto_lint: True
  • auto_test: False
  • cache_keepalive_pings: 0
  • cache_prompts: False
  • chat_history_file: /home/emincan/dev/.aider.chat.history.md
  • chat_language: None
  • check_update: True
  • code_theme: default
  • commit: False
  • commit_prompt: None
  • config: None
  • dark_mode: False
  • dirty_commits: True
  • dry_run: False
  • edit_format: None
  • encoding: utf-8
  • env_file: /home/emincan/dev/.env
  • exit: False
  • file: None
  • files: []
  • git: True
  • gitignore: True
  • gui: False
  • input_history_file: /home/emincan/dev/.aider.input.history
  • install_main_branch: False
  • just_check_update: False
  • light_mode: False
  • lint: False
  • lint_cmd: []
  • list_models: None
  • llm_history_file: None
  • map_multiplier_no_files: 2
  • map_refresh: auto
  • map_tokens: None
  • max_chat_history_tokens: None
  • message: None
  • message_file: None
  • model: ollama/llama3.1
  • model_metadata_file: .aider.model.metadata.json
  • model_settings_file: .aider.model.settings.yml
  • openai_api_base: None
  • openai_api_deployment_id: None
  • openai_api_key: None
  • openai_api_type: None
  • openai_api_version: None
  • openai_organization_id: None
  • pretty: True
  • read: None
  • restore_chat_history: False
  • show_diffs: False
  • show_model_warnings: True
  • show_prompts: False
  • show_repo_map: False
  • stream: True
  • subtree_only: False
  • suggest_shell_commands: True
  • test: False
  • test_cmd: []
  • tool_error_color: #FF2222
  • tool_output_color: None
  • tool_warning_color: #FFA500
  • upgrade: False
  • user_input_color: #00cc00
  • verbose: True
  • verify_ssl: True
  • vim: False
  • voice_language: en
  • weak_model: None
  • yes: None

Checking imports for version 0.56.0 and executable /usr/bin/python3 Installs file: /home/emincan/.aider/installs.json Installs file exists and loaded Not first run, loading imports in background thread No model settings files loaded Searched for model settings files:

  • /home/emincan/.aider.model.settings.yml
  • /home/emincan/dev/.aider.model.settings.yml Model info: { "max_tokens": 32768, "max_input_tokens": 8192, "max_output_tokens": 8192, "input_cost_per_token": 0.0, "output_cost_per_token": 0.0, "litellm_provider": "ollama", "mode": "chat", "supports_function_calling": true } Aider v0.56.0 Model: ollama/llama3.1 with whole edit format Git repo: .git with 0 files Repo-map: disabled Use /help for help, run "aider --help" to see cmd line args ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

create a snake game in python

SYSTEM Act as an expert software developer. SYSTEM Take requests for changes to the supplied code. SYSTEM If the request is ambiguous, ask questions. SYSTEM SYSTEM Always reply to the user in the same language they are using. SYSTEM SYSTEM SYSTEM Once you understand the request you MUST: SYSTEM 1. Determine if any code changes are needed. SYSTEM 2. Explain any needed changes. SYSTEM 3. If changes are needed, output a copy of each file that needs changes. SYSTEM SYSTEM To suggest changes to a file you MUST return the entire content of the updated file. SYSTEM You MUST use this file listing format: SYSTEM SYSTEM path/to/filename.js SYSTEM SYSTEM // entire file content ... SYSTEM // ... goes in between SYSTEM SYSTEM SYSTEM Every file listing MUST use this format: SYSTEM - First line: the filename with any originally provided path SYSTEM - Second line: opening SYSTEM - ... entire content of the file ... SYSTEM - Final line: closing SYSTEM SYSTEM To suggest changes to a file you MUST return a file listing that contains the entire content of the file. SYSTEM NEVER skip, omit or elide content from a file listing using "..." or by adding comments like "... rest of code..."! SYSTEM Create a new file you MUST return a file listing which includes an appropriate filename, including any appropriate path. SYSTEM SYSTEM

USER Change the greeting to be more casual

ASSISTANT Ok, I will: ASSISTANT ASSISTANT 1. Switch the greeting text from "Hello" to "Hey". ASSISTANT ASSISTANT show_greeting.py ASSISTANT ASSISTANT import sys ASSISTANT ASSISTANT def greeting(name): ASSISTANT print(f"Hey {name}") ASSISTANT ASSISTANT if __name__ == '__main__': ASSISTANT greeting(sys.argv[1]) ASSISTANT

USER I switched to a new code base. Please don't consider the above files or try to edit them any longer.

ASSISTANT Ok.

USER I am not sharing any files that you can edit yet.

ASSISTANT Ok.

USER create a snake game in python USER USER To suggest changes to a file you MUST return the entire content of the updated file. USER You MUST use this file listing format: USER USER path/to/filename.js USER USER // entire file content ... USER // ... goes in between USER USER USER Every file listing MUST use this format: USER - First line: the filename with any originally provided path USER - Second line: opening USER - ... entire content of the file ... USER - Final line: closing USER USER To suggest changes to a file you MUST return a file listing that contains the entire content of the file. USER NEVER skip, omit or elide content from a file listing using "..." or by adding comments like "... rest of code..."! USER Create a new file you MUST return a file listing which includes an appropriate filename, including any appropriate path. USER USER Unexpected error: b'' Traceback (most recent call last): File "/home/emincan/.local/lib/python3.10/site-packages/aider/coders/base_coder.py", line 1124, in send_message yield from self.send(messages, functions=self.functions) File "/home/emincan/.local/lib/python3.10/site-packages/aider/coders/base_coder.py", line 1408, in send yield from self.show_send_output_stream(completion) File "/home/emincan/.local/lib/python3.10/site-packages/aider/coders/base_coder.py", line 1482, in show_send_output_stream for chunk in completion: File "/home/emincan/.local/lib/python3.10/site-packages/litellm/llms/ollama.py", line 371, in ollama_completion_stream raise e File "/home/emincan/.local/lib/python3.10/site-packages/litellm/llms/ollama.py", line 329, in ollama_completion_stream raise OllamaError( litellm.llms.ollama.OllamaError: b''

emincangencer avatar Sep 12 '24 07:09 emincangencer

@emincangencer

a similar thing happens with ollama.

Thank you for your initiative, but the original issue is about an authentication error with Anthropic API, your issue seems completely unrelated.

Please make a separate issue for your problem (and please remove your post above from this issue).

Thank you.

fry69 avatar Sep 12 '24 08:09 fry69

your issue seems completely unrelated

I thought it was a dependency issue and that was why I sent it here. And seems like it was in my case. I did force reinstall on the dependencies even though they were fine, including litellm==1.44.7. This solved the issue.

How should I proceed now?

emincangencer avatar Sep 12 '24 09:09 emincangencer

@emincangencer

How should I proceed now?

Please don't hijack other issues. Move your problem to a separate issue you own.

Thank you.

fry69 avatar Sep 12 '24 09:09 fry69

I'm going to close this issue for now, but feel free to add a comment here and I will re-open. Or feel free to file a new issue any time.

paul-gauthier avatar Sep 20 '24 19:09 paul-gauthier