Skip to content

Commit 877d101

Browse files
committed
feat: route Messages API through Codebase proxy for MiniMax/Claude
When logged in, MiniMax and Claude models use Messages protocol via codebase.foundation/api/inference/v1/messages. Auth via x-api-key header with OAuth access token.
1 parent ac1dd56 commit 877d101

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

llm.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,19 @@ func newLLMClientWithTimeout(apiKey, baseURL, model string, timeout time.Duratio
136136
if apiKey == "" && IsLoggedIn() {
137137
token, err := GetAccessToken()
138138
if err == nil {
139+
// Detect protocol from model name — MiniMax and Claude use Messages API
140+
proto := ProtocolChatCompletions
141+
inferenceURL := oauthBaseURL + "/inference"
142+
modelLower := strings.ToLower(model)
143+
if strings.HasPrefix(modelLower, "minimax") || strings.HasPrefix(modelLower, "claude") {
144+
proto = ProtocolMessages
145+
// CLI appends /v1/messages to BaseURL for Messages protocol
146+
}
139147
return &LLMClient{
140148
APIKey: token,
141-
BaseURL: oauthBaseURL + "/inference",
149+
BaseURL: inferenceURL,
142150
Model: model,
143-
Protocol: ProtocolChatCompletions, // Inference proxy speaks OpenAI format
151+
Protocol: proto,
144152
UseCodebaseAI: true,
145153
client: &http.Client{Timeout: timeout},
146154
}
@@ -151,7 +159,7 @@ func newLLMClientWithTimeout(apiKey, baseURL, model string, timeout time.Duratio
151159
baseURL = "https://api.openai.com/v1"
152160
}
153161
if model == "" {
154-
model = "gpt-4o"
162+
model = "MiniMax-M2.7"
155163
}
156164
baseURL = strings.TrimSuffix(baseURL, "/")
157165
protocol := detectProtocol(baseURL)

0 commit comments

Comments
 (0)