Skip to content

Expected either api_key or auth_token to be set #87

@zooyf

Description

@zooyf
Attaching to backend-1, frontend-1
frontend-1  |    ▲ Next.js 15.3.3
frontend-1  |    - Local:        http://localhost:3000
frontend-1  |    - Network:      http://0.0.0.0:3000
frontend-1  |
frontend-1  |  ✓ Starting...
frontend-1  |  ✓ Ready in 80ms
backend-1   | Using Anthropic Client, reading ANTHROPIC_API_KEY from .env
backend-1   | INFO:websocket_server:Starting WebSocket server on 0.0.0.0:8000
backend-1   | INFO:     Started server process [20]
backend-1   | INFO:     Waiting for application startup.
backend-1   | INFO:     Application startup complete.
backend-1   | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
backend-1   | INFO:     172.26.0.1:61210 - "GET /workspace/a7b4ce5c-ad0c-4f16-9efd-7088d77c5897/undefined HTTP/1.1" 404 Not Found
backend-1   | INFO:     ('172.26.0.1', 63964) - "WebSocket /ws?device_id=05976f32-e391-482f-a684-4be8b276436e" [accepted]
backend-1   | Workspace manager created: <ii_agent.utils.workspace_manager.WorkspaceManager object at 0xffff81def430>
backend-1   | INFO:     172.26.0.1:63978 - "GET /api/sessions/05976f32-e391-482f-a684-4be8b276436e HTTP/1.1" 200 OK
backend-1   | INFO:     connection open
backend-1   | INFO:websocket_server:Client disconnected
backend-1   | INFO:     connection closed
backend-1   | INFO:     ('172.26.0.1', 63996) - "WebSocket /ws?device_id=05976f32-e391-482f-a684-4be8b276436e" [accepted]
backend-1   | INFO:     172.26.0.1:63986 - "GET /api/sessions/05976f32-e391-482f-a684-4be8b276436e HTTP/1.1" 200 OK
backend-1   | Workspace manager created: <ii_agent.utils.workspace_manager.WorkspaceManager object at 0xffff81e7b0d0>
backend-1   | INFO:     connection open
backend-1   | Created new session e162bf34-008e-4f19-8925-7eac06697ef5 with workspace at /app/workspace/e162bf34-008e-4f19-8925-7eac06697ef5
backend-1   | Using DuckDuckGo to search
backend-1   | Using Markdownify to visit webpage
backend-1   | No image search API key found, using DuckDuckGo
backend-1   |
backend-1   | --------------------------------------------- USER INPUT ---------------------------------------------
backend-1   | 总结2020至今人形机器人资料,并生成一些幻灯片供我演示。
backend-1   |
backend-1   |
backend-1   | --------------------------------------------- NEW TURN ---------------------------------------------
backend-1   |
backend-1   | (Current token count: 9)
backend-1   |
backend-1   | ERROR:websocket_server:Error running agent: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted"
backend-1   | Traceback (most recent call last):
backend-1   |   File "/app/ws_server.py", line 447, in run_agent_async
backend-1   |     await anyio.to_thread.run_sync(
backend-1   |   File "/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
backend-1   |     return await get_async_backend().run_sync_in_worker_thread(
backend-1   |   File "/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread
backend-1   |     return await future
backend-1   |   File "/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 967, in run
backend-1   |     result = context.run(func, *args)
backend-1   |   File "/venv/lib/python3.10/site-packages/ii_agent/agents/anthropic_fc.py", line 342, in run_agent
backend-1   |     return self.run(tool_input, self.history)
backend-1   |   File "/venv/lib/python3.10/site-packages/ii_agent/tools/base.py", line 68, in run
backend-1   |     result = self.run_impl(tool_input, message_history)
backend-1   |   File "/venv/lib/python3.10/site-packages/ii_agent/agents/anthropic_fc.py", line 224, in run_impl
backend-1   |     model_response, _ = self.client.generate(
backend-1   |   File "/venv/lib/python3.10/site-packages/ii_agent/llm/anthropic.py", line 263, in generate
backend-1   |     raise e
backend-1   |   File "/venv/lib/python3.10/site-packages/ii_agent/llm/anthropic.py", line 237, in generate
backend-1   |     response = self.client.messages.create(  # type: ignore
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_utils/_utils.py", line 283, in wrapper
backend-1   |     return func(*args, **kwargs)
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/resources/messages/messages.py", line 978, in create
backend-1   |     return self._post(
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_base_client.py", line 1290, in post
backend-1   |     return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_base_client.py", line 1009, in request
backend-1   |     request = self._build_request(options, retries_taken=retries_taken)
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_base_client.py", line 505, in _build_request
backend-1   |     headers = self._build_headers(options, retries_taken=retries_taken)
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_base_client.py", line 446, in _build_headers
backend-1   |     self._validate_headers(headers_dict, custom_headers)
backend-1   |   File "/venv/lib/python3.10/site-packages/anthropic/_client.py", line 196, in _validate_headers
backend-1   |     raise TypeError(
backend-1   | TypeError: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted"
backend-1   | INFO:     172.26.0.1:63282 - "GET /workspace/e162bf34-008e-4f19-8925-7eac06697ef5/undefined HTTP/1.1" 404 Not Found

New Error Occured...
I just change the gemini-2.5-pro-preview-05-06 to gemini-2.5-flash-preview-04-17 globally.(agent.ts & base.py)

Image

echo $GEMINI_API_KEY display my key successfully.

Originally posted by @zooyf in #51

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