Add /v1/responses endpoint for direct OpenAI forwarding

Features:
- Add new /v1/responses endpoint for transparent request/response forwarding
- Only supports openai type endpoints (rejects anthropic with 400 error)
- No request transformation - forwards original request body as-is
- No response transformation - streams and non-streaming responses forwarded directly
- /v1/chat/completions keeps original behavior with format conversion

Differences between endpoints:
- /v1/chat/completions: Converts formats for all endpoint types (anthropic, openai)
- /v1/responses: Direct proxy for openai endpoints only, zero transformation
This commit is contained in:
1e0n
2025-10-07 05:14:58 +08:00
parent 3aebe7e723
commit 79616ba3b9
2 changed files with 117 additions and 5 deletions

View File

@@ -29,7 +29,8 @@ app.get('/', (req, res) => {
description: 'OpenAI Compatible API Proxy',
endpoints: [
'GET /v1/models',
'POST /v1/chat/completions'
'POST /v1/chat/completions',
'POST /v1/responses'
]
});
});
@@ -86,7 +87,8 @@ app.use((req, res, next) => {
timestamp: errorInfo.timestamp,
availableEndpoints: [
'GET /v1/models',
'POST /v1/chat/completions'
'POST /v1/chat/completions',
'POST /v1/responses'
]
});
});
@@ -118,6 +120,7 @@ app.use((err, req, res, next) => {
logInfo('Available endpoints:');
logInfo(' GET /v1/models');
logInfo(' POST /v1/chat/completions');
logInfo(' POST /v1/responses');
})
.on('error', (err) => {
if (err.code === 'EADDRINUSE') {