mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Add codex to image providers
This commit is contained in:
@@ -27,8 +27,10 @@ export async function handleImageGeneration(request) {
|
||||
return errorResponse(HTTP_STATUS.BAD_REQUEST, "Invalid JSON body");
|
||||
}
|
||||
|
||||
const url = new URL(request.url);
|
||||
const preferredConnectionId = request.headers.get("x-connection-id") || null;
|
||||
const wantsStream = (request.headers.get("accept") || "").includes("text/event-stream");
|
||||
const binaryOutput = url.searchParams.get("response_format") === "binary";
|
||||
const modelStr = body.model;
|
||||
|
||||
const apiKey = extractApiKey(request);
|
||||
@@ -53,6 +55,7 @@ export async function handleImageGeneration(request) {
|
||||
body,
|
||||
modelInfo: { provider, model },
|
||||
credentials: null,
|
||||
binaryOutput,
|
||||
});
|
||||
if (result.success) return result.response;
|
||||
return errorResponse(result.status || HTTP_STATUS.BAD_GATEWAY, result.error || "Image generation failed");
|
||||
@@ -85,6 +88,7 @@ export async function handleImageGeneration(request) {
|
||||
modelInfo: { provider, model },
|
||||
credentials: refreshedCredentials,
|
||||
streamToClient: wantsStream,
|
||||
binaryOutput,
|
||||
onCredentialsRefreshed: async (newCreds) => {
|
||||
await updateProviderCredentials(credentials.connectionId, {
|
||||
accessToken: newCreds.accessToken,
|
||||
|
||||
Reference in New Issue
Block a user