Skip to content

Conversation

@cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Sep 18, 2025

Closes #181. Introduced by #155. With that change, ChatGithub() stopped submitting input to the proper base_url

import chatlas as ctl

chat = ctl.ChatGithub()
chat.chat("Hello")
Traceback (most recent call last):
  File "/Users/cpsievert/github/chatlas/dev.py", line 4, in <module>
    chat.chat("Hello")
    ~~~~~~~~~^^^^^^^^^
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 858, in chat
    for _ in response:
             ^^^^^^^^
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 2549, in __next__
    chunk = next(self._generator)
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 2063, in _chat_impl
    for chunk in self._submit_turns(
                 ~~~~~~~~~~~~~~~~~~^
        user_turn_result,
        ^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        kwargs=kwargs,
        ^^^^^^^^^^^^^^
    ):
    ^
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 2193, in _submit_turns
    response = self.provider.chat_perform(
        stream=True,
    ...<3 lines>...
        kwargs=all_kwargs,
    )
  File "/Users/cpsievert/github/chatlas/chatlas/_provider_openai.py", line 282, in chat_perform
    return self._client.chat.completions.create(**kwargs)  # type: ignore
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/cpsievert/github/chatlas/.venv/lib/python3.13/site-packages/openai/_utils/_utils.py", line 286, in wrapper
    return func(*args, **kwargs)
  File "/Users/cpsievert/github/chatlas/.venv/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 1147, in create
    return self._post(
           ~~~~~~~~~~^
        "/chat/completions",
        ^^^^^^^^^^^^^^^^^^^^
    ...<46 lines>...
        stream_cls=Stream[ChatCompletionChunk],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/cpsievert/github/chatlas/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1259, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/chatlas/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1047, in request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: ghp_vqnW****************************KjDv. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

@cpsievert cpsievert merged commit 2581208 into main Sep 18, 2025
7 checks passed
@cpsievert cpsievert deleted the fix/chat-github-base-url branch September 18, 2025 18:03
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

Successfully merging this pull request may close these issues.

AuthenticationError when using ChatGithub

2 participants