Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
08b424a3
authored
Sep 30, 2025
by
Seefs
Committed by
GitHub
Sep 30, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1817 from wzxjohn/hotfix/relay_vertex_claude
fix(relay): wrong URL for claude model in GCP Vertex AI
parents
85381404
237f5994
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
21 deletions
+48
-21
relay/channel/vertex/adaptor.go
+48
-21
No files found.
relay/channel/vertex/adaptor.go
View file @
08b424a3
...
...
@@ -91,7 +91,43 @@ func (a *Adaptor) getRequestUrl(info *relaycommon.RelayInfo, modelName, suffix s
}
a
.
AccountCredentials
=
*
adc
if
a
.
RequestMode
==
RequestModeLlama
{
if
a
.
RequestMode
==
RequestModeGemini
{
if
region
==
"global"
{
return
fmt
.
Sprintf
(
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/google/models/%s:%s"
,
adc
.
ProjectID
,
modelName
,
suffix
,
),
nil
}
else
{
return
fmt
.
Sprintf
(
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s"
,
region
,
adc
.
ProjectID
,
region
,
modelName
,
suffix
,
),
nil
}
}
else
if
a
.
RequestMode
==
RequestModeClaude
{
if
region
==
"global"
{
return
fmt
.
Sprintf
(
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/anthropic/models/%s:%s"
,
adc
.
ProjectID
,
modelName
,
suffix
,
),
nil
}
else
{
return
fmt
.
Sprintf
(
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/anthropic/models/%s:%s"
,
region
,
adc
.
ProjectID
,
region
,
modelName
,
suffix
,
),
nil
}
}
else
if
a
.
RequestMode
==
RequestModeLlama
{
return
fmt
.
Sprintf
(
"https://%s-aiplatform.googleapis.com/v1beta1/projects/%s/locations/%s/endpoints/openapi/chat/completions"
,
region
,
...
...
@@ -99,42 +135,33 @@ func (a *Adaptor) getRequestUrl(info *relaycommon.RelayInfo, modelName, suffix s
region
,
),
nil
}
if
region
==
"global"
{
return
fmt
.
Sprintf
(
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/google/models/%s:%s"
,
adc
.
ProjectID
,
modelName
,
suffix
,
),
nil
}
else
{
var
keyPrefix
string
if
strings
.
HasSuffix
(
suffix
,
"?alt=sse"
)
{
keyPrefix
=
"&"
}
else
{
return
fmt
.
Sprintf
(
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s"
,
region
,
adc
.
ProjectID
,
region
,
modelName
,
suffix
,
),
nil
keyPrefix
=
"?"
}
}
else
{
if
region
==
"global"
{
return
fmt
.
Sprintf
(
"https://aiplatform.googleapis.com/v1/publishers/google/models/%s:%s
?
key=%s"
,
"https://aiplatform.googleapis.com/v1/publishers/google/models/%s:%s
%s
key=%s"
,
modelName
,
suffix
,
keyPrefix
,
info
.
ApiKey
,
),
nil
}
else
{
return
fmt
.
Sprintf
(
"https://%s-aiplatform.googleapis.com/v1/publishers/google/models/%s:%s
?
key=%s"
,
"https://%s-aiplatform.googleapis.com/v1/publishers/google/models/%s:%s
%s
key=%s"
,
region
,
modelName
,
suffix
,
keyPrefix
,
info
.
ApiKey
,
),
nil
}
}
return
""
,
errors
.
New
(
"unsupported request mode"
)
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
...
...
@@ -188,7 +215,7 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel
}
req
.
Set
(
"Authorization"
,
"Bearer "
+
accessToken
)
}
if
a
.
AccountCredentials
.
ProjectID
!=
""
{
if
a
.
AccountCredentials
.
ProjectID
!=
""
{
req
.
Set
(
"x-goog-user-project"
,
a
.
AccountCredentials
.
ProjectID
)
}
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment