We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用 ai-proxy 插件代理 Gemini 服务时报无效的认证凭证错误
ai-proxy 中配置如下
CURL 访问参数如下
curl https://example.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${HIGRESS_API_KEY}" \ -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' { "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } }
但是使用同一个 KEY,使用 CURL 调用官方接口是可以正常返回
curl "https://generativelanguage.googleapis.com/v1/models/gemini-2.0-flash:generateContent" \ -H 'Content-Type: application/json' \ -H 'x-goog-api-key: GEMINI_API_KEY' \ -d '{ "contents": [{ "parts":[{"text": "Who are you?"}] }] }' { "candidates": [ { "content": { "parts": [ { "text": "I am a large language model, trained by Google.\n" } ], "role": "model" }, "finishReason": "STOP", "avgLogprobs": -3.197540354449302e-05 } ], "usageMetadata": { "promptTokenCount": 4, "candidatesTokenCount": 12, "totalTokenCount": 16, "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 4 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 12 } ] }, "modelVersion": "gemini-2.0-flash" }
同样使用同一套 KEY, 我切换为 openai 兼容接口,也是可以正常调用
curl https://example.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${HIGRESS_API_KEY}" \ -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' {"choices":[{"finish_reason":"stop","index":0,"message":{"content":"I am a large language model, trained by Google.\n","role":"assistant"}}],"created":1746698000,"model":"gemini-2.0-flash","object":"chat.completion","usage":{"completion_tokens":12,"prompt_tokens":4,"total_tokens":16}}
The text was updated successfully, but these errors were encountered:
CC @hanxiantao
Sorry, something went wrong.
使用 ai-proxy 插件代理 Gemini 服务时报无效的认证凭证错误 ai-proxy 中配置如下 CURL 访问参数如下 curl https://example.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer ${HIGRESS_API_KEY}" -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' { "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } } 但是使用同一个 KEY,使用 CURL 调用官方接口是可以正常返回 curl "https://generativelanguage.googleapis.com/v1/models/gemini-2.0-flash:generateContent" -H 'Content-Type: application/json' -H 'x-goog-api-key: GEMINI_API_KEY' -d '{ "contents": [{ "parts":[{"text": "Who are you?"}] }] }' { "candidates": [ { "content": { "parts": [ { "text": "I am a large language model, trained by Google.\n" } ], "role": "model" }, "finishReason": "STOP", "avgLogprobs": -3.197540354449302e-05 } ], "usageMetadata": { "promptTokenCount": 4, "candidatesTokenCount": 12, "totalTokenCount": 16, "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 4 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 12 } ] }, "modelVersion": "gemini-2.0-flash" } 同样使用同一套 KEY, 我切换为 openai 兼容接口,也是可以正常调用 curl https://example.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer ${HIGRESS_API_KEY}" -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' {"choices":[{"finish_reason":"stop","index":0,"message":{"content":"I am a large language model, trained by Google.\n","role":"assistant"}}],"created":1746698000,"model":"gemini-2.0-flash","object":"chat.completion","usage":{"completion_tokens":12,"prompt_tokens":4,"total_tokens":16}}
curl https://example.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer ${HIGRESS_API_KEY}" -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' { "error": { "code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } } 但是使用同一个 KEY,使用 CURL 调用官方接口是可以正常返回
curl "https://generativelanguage.googleapis.com/v1/models/gemini-2.0-flash:generateContent" -H 'Content-Type: application/json' -H 'x-goog-api-key: GEMINI_API_KEY' -d '{ "contents": [{ "parts":[{"text": "Who are you?"}] }] }' { "candidates": [ { "content": { "parts": [ { "text": "I am a large language model, trained by Google.\n" } ], "role": "model" }, "finishReason": "STOP", "avgLogprobs": -3.197540354449302e-05 } ], "usageMetadata": { "promptTokenCount": 4, "candidatesTokenCount": 12, "totalTokenCount": 16, "promptTokensDetails": [ { "modality": "TEXT", "tokenCount": 4 } ], "candidatesTokensDetails": [ { "modality": "TEXT", "tokenCount": 12 } ] }, "modelVersion": "gemini-2.0-flash" } 同样使用同一套 KEY, 我切换为 openai 兼容接口,也是可以正常调用
curl https://example.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer ${HIGRESS_API_KEY}" -d '{ "messages": [ { "role": "user", "content": "Who are you?" } ], "model": "gemini-2.0-flash" }' {"choices":[{"finish_reason":"stop","index":0,"message":{"content":"I am a large language model, trained by Google.\n","role":"assistant"}}],"created":1746698000,"model":"gemini-2.0-flash","object":"chat.completion","usage":{"completion_tokens":12,"prompt_tokens":4,"total_tokens":16}}
我周末的时候自己复现下,到时候回复下
hanxiantao
No branches or pull requests
使用 ai-proxy 插件代理 Gemini 服务时报无效的认证凭证错误
ai-proxy 中配置如下
CURL 访问参数如下
但是使用同一个 KEY,使用 CURL 调用官方接口是可以正常返回
同样使用同一套 KEY, 我切换为 openai 兼容接口,也是可以正常调用
The text was updated successfully, but these errors were encountered: