Skip to content

Commit 46c4c2b

Browse files
authored
fix responses (#5113)
1 parent 391c3df commit 46c4c2b

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

packages/cost/models/providers/helicone.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ export class HeliconeProvider extends BaseProvider {
1616
return `${this.baseUrl}/anthropic/v1/messages`;
1717
}
1818

19-
// Use responses endpoint for pro and codex models
20-
const isResponsesEndpoint = endpoint.providerModelId.includes("gpt-5-pro") ||
19+
// Use responses endpoint for pro/codex models or when bodyMapping is RESPONSES
20+
const isResponsesEndpoint = requestParams.bodyMapping === "RESPONSES" ||
21+
endpoint.providerModelId.includes("gpt-5-pro") ||
2122
endpoint.providerModelId.includes("gpt-5-codex");
2223

2324
const path = isResponsesEndpoint ? "/responses" : "/chat/completions";
@@ -56,25 +57,7 @@ export class HeliconeProvider extends BaseProvider {
5657
return JSON.stringify(anthropicBody);
5758
}
5859

59-
const isResponsesEndpoint = endpoint.providerModelId.includes("gpt-5-pro") ||
60-
endpoint.providerModelId.includes("gpt-5-codex");
61-
62-
if (isResponsesEndpoint) {
63-
// Convert messages to input format for /responses endpoint
64-
const { messages, ...rest } = context.parsedBody;
65-
let input = "";
66-
if (Array.isArray(messages)) {
67-
input = messages.map((m: any) => m.content).join("\n");
68-
}
69-
70-
return JSON.stringify({
71-
...rest,
72-
model: endpoint.providerModelId,
73-
input,
74-
});
75-
}
76-
77-
// Standard chat completions format for OpenAI models
60+
// Standard format - just pass through with correct model
7861
return JSON.stringify({
7962
...context.parsedBody,
8063
model: endpoint.providerModelId,

worker/src/lib/ai-gateway/SimpleAIGateway.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ export class SimpleAIGateway {
159159
});
160160
continue;
161161
}
162+
162163
if (
163164
attempt.authType === "ptb" &&
164-
this.requestWrapper.heliconeHeaders.gatewayConfig.bodyMapping !==
165-
"NO_MAPPING"
165+
this.requestWrapper.heliconeHeaders.gatewayConfig.bodyMapping ===
166+
"OPENAI"
166167
) {
167168
const validationResult = validateOpenAIChatPayload(finalBody);
168169
if (isErr(validationResult)) {

0 commit comments

Comments
 (0)