Add codex to image providers

This commit is contained in:
decolua
2026-04-25 17:01:40 +07:00
parent 14ff69bf90
commit 83418e8a9d
4 changed files with 102 additions and 31 deletions
+4
View File
@@ -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,