mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
feat(gemini-cli): add proper User-Agent and X-Goog-Api-Client headers
Match native GeminiCLI client fingerprint to avoid upstream rejection. Also fix base executor to call transformRequest before buildHeaders so subclasses can store model context for header generation. Made-with: Cursor
This commit is contained in:
committed by
decolua
parent
10b22d1318
commit
06a5307160
@@ -1,5 +1,5 @@
|
||||
import { BaseExecutor } from "./base.js";
|
||||
import { PROVIDERS, OAUTH_ENDPOINTS } from "../config/constants.js";
|
||||
import { PROVIDERS, OAUTH_ENDPOINTS, GEMINI_CLI_API_CLIENT, geminiCLIUserAgent } from "../config/constants.js";
|
||||
|
||||
export class GeminiCLIExecutor extends BaseExecutor {
|
||||
constructor() {
|
||||
@@ -15,11 +15,15 @@ export class GeminiCLIExecutor extends BaseExecutor {
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${credentials.accessToken}`,
|
||||
...(stream && { "Accept": "text/event-stream" })
|
||||
"User-Agent": geminiCLIUserAgent(this._currentModel),
|
||||
"X-Goog-Api-Client": GEMINI_CLI_API_CLIENT,
|
||||
"Accept": stream ? "text/event-stream" : "application/json"
|
||||
};
|
||||
}
|
||||
|
||||
transformRequest(model, body, stream, credentials) {
|
||||
// Store model for use in buildHeaders (called by base.execute after transformRequest)
|
||||
this._currentModel = model;
|
||||
if (!body.project && credentials?.projectId) {
|
||||
body.project = credentials.projectId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user