grok2api icon indicating copy to clipboard operation
grok2api copied to clipboard

bug: 生成的URL需要使用token鉴权

Open BytePioneer-AI opened this issue 9 months ago • 2 comments

两个问题哈:

  1. 设置了base64返回图片,但仍是返回了url。
  2. 返回的url是grok原始url,需携带相关token才能访问,否则没有权限。

麻烦看下

BytePioneer-AI avatar Feb 21 '26 05:02 BytePioneer-AI

图片接口原始响应

{"provider":"openai-compatible","requestId":null,"status":200,"response":{"created":1771652437,"data":[{"b64_json":"https://assets.grok.com/users/f77b0175-3590-446b-bf30-ba682edcf34b/generated/4854b7b6-85eb-4273-b4a6-cf1508665f77/image.jpg"}],"usage":{"total_tokens":0,"input_tokens":0,"output_tokens":0,"input_tokens_details":{"text_tokens":0,"image_tokens":0}}}}

BytePioneer-AI avatar Feb 21 '26 05:02 BytePioneer-AI

看了下日志,似乎是因为鉴权的问题,但是grok2 api 已经配置了呀。


2026-02-21 13:21:31 | INFO     | response_middleware.py:60 - Response: GET /v1/admin/tokens - 200 (9.84ms)
INFO:     172.18.0.1:45944 - "GET /v1/admin/tokens HTTP/1.1" 200 OK
2026-02-21 13:21:38 | INFO     | upload.py:244 - Upload success: file.png -> e891124b-f032-44b8-bc32-f2e40054bbc2
2026-02-21 13:21:39 | INFO     | video.py:93 - Media post created: e891124b-f032-44b8-bc32-f2e40054bbc2 (type=MEDIA_POST_TYPE_IMAGE)
2026-02-21 13:21:40 | INFO     | chat.py:206 - Chat connected: model=imagine-image-edit, stream=True
2026-02-21 13:21:51 | ERROR    | download.py:164 - Failed to convert users/f77b0175-3590-446b-bf30-ba682edcf34b/generated/9f3182d7-27a9-43d6-8174-65299266ba43/image.jpg to base64: Invalid file path
2026-02-21 13:21:51 | WARNING  | image_edit.py:482 - Failed to convert image to base64, falling back to URL: Invalid file path
2026-02-21 13:21:51 | ERROR    | download.py:164 - Failed to convert users/f77b0175-3590-446b-bf30-ba682edcf34b/generated/7843090b-fb19-4326-97b9-7a4c44efa350/image.jpg to base64: Invalid file path
2026-02-21 13:21:51 | WARNING  | image_edit.py:482 - Failed to convert image to base64, falling back to URL: Invalid file path
2026-02-21 13:21:52 | INFO     | response_middleware.py:60 - Response: POST /v1/chat/completions - 200 (32830.71ms)
INFO:     172.18.0.1:59632 - "POST /v1/chat/completions HTTP/1.1" 200 OK
2026-02-21 13:30:46 | INFO     | response_middleware.py:44 - Request: GET /v1/admin/verify
2026-02-21 13:30:46 | INFO     | response_middleware.py:60 - Response: GET /v1/admin/verify - 200 (6.99ms)
INFO:     172.18.0.1:33914 - "GET /v1/admin/verify HTTP/1.1" 200 OK
2026-02-21 13:30:46 | INFO     | response_middleware.py:44 - Request: GET /v1/admin/verify
2026-02-21 13:30:46 | INFO     | response_middleware.py:44 - Request: GET /v1/admin/config
2026-02-21 13:30:46 | INFO     | response_middleware.py:60 - Response: GET /v1/admin/verify - 200 (7.63ms)
INFO:     172.18.0.1:33930 - "GET /v1/admin/verify HTTP/1.1" 200 OK
2026-02-21 13:30:46 | INFO     | response_middleware.py:60 - Response: GET /v1/admin/config - 200 (4.23ms)
INFO:     172.18.0.1:33914 - "GET /v1/admin/config HTTP/1.1" 200 OK
2026-02-21 13:30:46 | INFO     | response_middleware.py:44 - Request: GET /v1/admin/storage
2026-02-21 13:30:46 | INFO     | response_middleware.py:60 - Response: GET /v1/admin/storage - 200 (1.45ms)
INFO:     172.18.0.1:33930 - "GET /v1/admin/storage HTTP/1.1" 200 OK
2026-02-21 13:40:14 | INFO     | response_middleware.py:44 - Request: POST /v1/chat/completions
2026-02-21 13:40:14 | INFO     | manager.py:124 - TokenManager initialized: 1 pools with 1 tokens
2026-02-21 13:40:27 | INFO     | upload.py:244 - Upload success: file.png -> e5c73755-cf72-4b9a-92e6-502032d0ffe6
2026-02-21 13:40:28 | INFO     | video.py:93 - Media post created: e5c73755-cf72-4b9a-92e6-502032d0ffe6 (type=MEDIA_POST_TYPE_IMAGE)
2026-02-21 13:40:29 | INFO     | chat.py:206 - Chat connected: model=imagine-image-edit, stream=True
2026-02-21 13:40:36 | ERROR    | download.py:164 - Failed to convert users/f77b0175-3590-446b-bf30-ba682edcf34b/generated/4854b7b6-85eb-4273-b4a6-cf1508665f77/image.jpg to base64: Invalid file path
2026-02-21 13:40:36 | WARNING  | image_edit.py:482 - Failed to convert image to base64, falling back to URL: Invalid file path
2026-02-21 13:40:36 | ERROR    | download.py:164 - Failed to convert users/f77b0175-3590-446b-bf30-ba682edcf34b/generated/3370b19a-667a-4a1a-9469-fab472036a17/image.jpg to base64: Invalid file path
2026-02-21 13:40:36 | WARNING  | image_edit.py:482 - Failed to convert image to base64, falling back to URL: Invalid file path
2026-02-21 13:40:37 | INFO     | response_middleware.py:60 - Response: POST /v1/chat/completions - 200 (23021.80ms)
INFO:     172.18.0.1:40748 - "POST /v1/chat/completions HTTP/1.1" 200 OK

BytePioneer-AI avatar Feb 21 '26 05:02 BytePioneer-AI