Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
20.94k stars 1.93k forks source link

Uncaught AuthenticationError in chat.py line 647 #2001

Closed mateodelnorte closed 2 weeks ago

mateodelnorte commented 2 weeks ago

Aider version: 0.59.1 Python version: 3.11.3 Platform: macOS-14.6.1-arm64-arm-64bit Python implementation: CPython Virtual environment: No OS: Darwin 23.6.0 (64bit) Git version: git version 2.47.0

An uncaught exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 757, in main
    coder.run()
  File "base_coder.py", line 730, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 773, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1212, in send_message
    saved_message = self.auto_commit(edited)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1895, in auto_commit
    res = self.repo.commit(fnames=edited, context=context, aider_edits=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 110, in commit
    commit_message = self.get_commit_message(diffs, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 195, in get_commit_message
    commit_message = simple_send_with_retries(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 44, in wrapper
    return decorated_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 102, in simple_send_with_retries
    _hash, response = send_completion(**kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 83, in send_completion
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "utils.py", line 1086, in wrapper
    raise e
  File "utils.py", line 974, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 2847, in completion
    raise exception_type(
  File "main.py", line 1586, in completion
    response = anthropic_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "chat.py", line 976, in completion
    headers = validate_environment(api_key, headers, model, messages=messages)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "chat.py", line 647, in validate_environment
    raise litellm.AuthenticationError(
litellm.exceptions.AuthenticationError: litellm.AuthenticationError: Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params. Please set `ANTHROPIC_API_KEY` in your environment vars
fry69 commented 2 weeks ago

Thank you for filing this issue.

Looks like you did not set the required API key?

Missing Anthropic API Key - A call is being made to anthropic but no key is set either in the environment variables or via params. Please set ANTHROPIC_API_KEY in your environment vars

mateodelnorte commented 2 weeks ago

I'm running via a VS Code extension and didn't realize it was specifying a non-openrouter model, when I'm specifying an openrouter env var. Thanks!