Skip to content

LMStudio+CLI The wrong API endpoint is being called. #467

Description

@Unknown3658

Hi everyone,

I’m looking for help from someone familiar with this setup.

The setup:
I have a local LLM running via LMStudio + a local API.
I have WSL (Ubuntu) running this tool: https://github.com/aliasrobotics/cai#cybersecurity-ai-cai

The API responds to curl requests, but the application is trying to access the wrong path, despite the .env configuration.

LM Studio log:

2026-07-13 09:41:14 [ERROR]
 Unexpected endpoint or method. (GET /api/tags). Returning 200 anyway
2026-07-13 09:44:15 [DEBUG]
 Received request: GET to /api/tags
2026-07-13 09:44:15 [ERROR]
 Unexpected endpoint or method. (GET /api/tags). Returning 200 anyway
2026-07-13 09:44:18 [DEBUG]
 Received request: GET to /api/tags

CAI trace

ERROR:cai.cli:Error in main loop: litellm.AuthenticationError: AuthenticationError: OpenAIException - LiteLLM Virtual Key expected. Received=REDA****_KEY, expected to start with 'sk-'.
Traceback (most recent call last):
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 790, in acompletion
    headers, response = await self.make_openai_chat_completion_request(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/litellm_core_utils/logging_utils.py", line 135, in async_wrapper
    result = await func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 436, in make_openai_chat_completion_request
    raise e
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 418, in make_openai_chat_completion_request
    await openai_aclient.chat.completions.with_raw_response.create(
  File "/home/username/cai_env/lib/python3.12/site-packages/openai/_legacy_response.py", line 381, in wrapped
    return cast(LegacyAPIResponse[R], await func(*args, **kwargs))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2032, in create
    return await self._post(
           ^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/openai/_base_client.py", line 1805, in post
    return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/openai/_base_client.py", line 1495, in request
    return await self._request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/openai/_base_client.py", line 1600, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': "LiteLLM Virtual Key expected. Received=REDA****_KEY, expected to start with 'sk-'.", 'type': 'auth_error', 'param': 'None', 'code': '401'}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/main.py", line 507, in acompletion
    response = await init_response
               ^^^^^^^^^^^^^^^^^^^
  File "/home/username/cai_env/lib/python3.12/site-packages/litellm/llms/openai/openai.py", line 837, in acompletion
    raise OpenAIError(
litellm.llms.openai.common_utils.OpenAIError: Error code: 401 - {'error': {'message': "LiteLLM Virtual Key expected. Received=REDA****_KEY, expected to start with 'sk-'.", 'type': 'auth_error', 'param': 'None', 'code': '401'}}

Trying various .env configurations didn't help; the trace isn't showing up—though only with this specific configuration—yet there is still no load visible, as the LMStudio logs aren't working.

OPENAI_API_KEY="sk-1234"
OLLAMA_API_BASE="//http://172.19.16.1:25000/v1"
OLLAMA=""
ALIAS_API_KEY="sk-lm-(token)"  # note, add yours
CAI_STREAM=False
CAI_MODEL="gemma-4-12b-coder-fable5-composer2.5-v1"

I look forward to your feedback. Thank you.

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