Skip to content

Incorrect API key error with LM Studio running locally #829

@Harvester62

Description

@Harvester62

I am on Windows 11 Pro, with LM Studio 0.3.32 and Agent Zero 0.9.7-10 and I am not sure if what happens is due to incorrect settings or if its a bug. As soon as I start a conversation I get this error complaining about an invalid LM Studio API key which shouldn't be required:

Traceback (most recent call last):

  File "/opt/venv-a0/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 991, in async_streaming

    headers, response = await self.make_openai_chat_completion_request(

                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv-a0/lib/python3.12/site-packages/litellm/litellm_core_utils/logging_utils.py", line 190, in async_wrapper

    result = await func(*args, **kwargs)

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv-a0/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 454, in make_openai_chat_completion_request

    raise e

  File "/opt/venv-a0/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 436, in make_openai_chat_completion_request

    await openai_aclient.chat.completions.with_raw_response.create(

  File "/opt/venv-a0/lib/python3.12/site-packages/openai/_legacy_response.py", line 381, in wrapped

    return cast(LegacyAPIResponse[R], await func(*args, **kwargs))

                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv-a0/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2589, in create

    return await self._post(

           ^^^^^^^^^^^^^^^^^

  File "/opt/venv-a0/lib/python3.12/site-packages/openai/_base_client.py", line 1794, in post

    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv-a0/lib/python3.12/site-packages/openai/_base_client.py", line 1594, in request

    raise self._make_status_error_from_response(err.response) from None

openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: fake-api-key. You can find your API key at [https://platform.openai.com/account/api-keys.',⁠](https://platform.openai.com/account/api-keys.',) 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}

LM STUDIO

Image

AGENT ZERO

All three models are set as follows:

Image

Thanks in advance for any help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions