记得以前未哥研究Deepseek,好像发现了新大陆,说是抄openai的,今天我也发现一块新大陆

本帖于 2025-05-09 12:10:23 时间, 由普通用户 徙倚彷徨神光离合 编辑

马斯克的xAI也和DS一样,也用openai ,

这还不是要命的,要命的是,出错了,出错信息是:

  File "/usr/local/lib/python3.9/dist-packages/openai/_base_client.py", line 1034, in request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: xai-GK7e************************************************************************pybF. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
然后我就去问grok,说你们的API KEY不工作,怎么让我去找openai?得亏是机器人,如果是真人,我可以想象,他一定脸红得象猪肝一样,DS是穷人,抄抄openai还情有可原,你马斯克可是世界首富呀,比那个奥特曼钱多多了嘻嘻,然后告诉我:

  • Default API Endpoint:
    • The openai Python package (e.g., import openai) is primarily designed for OpenAI's API. By default, it sends requests to OpenAI's endpoint: https://api.openai.com/v1.
    • When you provide an API key (e.g., xai-GK7e...pybF), the client sends it to OpenAI's servers for authentication.
    • OpenAI's servers see the xai- prefix, recognize it as invalid for their platform (since it's an xAI key, not an OpenAI key), and return a 401 error with their standard message: "You can find your API key at https://platform.openai.com/account/api-keys."
  • xAI API Compatibility:
    • xAI's API is designed to be compatible with OpenAI's SDK (as noted on xAI's developer pages, e.g., https://x.ai/api), meaning you can use the openai Python package to interact with xAI's API.
    • However, to use xAI's API, you must explicitly tell the client to send requests to xAI's endpoint (https://api.x.ai/v1) instead of OpenAI's default endpoint. If you don’t override the base_url, the client will keep sending requests to OpenAI, resulting in the 401 error.

 

所有跟帖: 

太高深了,不懂。用openai的API是免费的吗? -seattleWA- 给 seattleWA 发送悄悄话 (0 bytes) () 05/09/2025 postreply 12:42:09

不是。 -徙倚彷徨神光离合- 给 徙倚彷徨神光离合 发送悄悄话 (0 bytes) () 05/09/2025 postreply 12:50:31

那是不是grok要给openai交钱,才能用openai做后台? -seattleWA- 给 seattleWA 发送悄悄话 (0 bytes) () 05/09/2025 postreply 12:54:22

-徙倚彷徨神光离合- 给 徙倚彷徨神光离合 发送悄悄话 (0 bytes) () 05/09/2025 postreply 13:20:21

请您先登陆,再发跟帖!