(
key: IntegrationTaskKey,
params: CreateImageVariationRequest,
options: OpenAIRequestOptions = {}
)
| 242 | } |
| 243 | |
| 244 | createVariation( |
| 245 | key: IntegrationTaskKey, |
| 246 | params: CreateImageVariationRequest, |
| 247 | options: OpenAIRequestOptions = {} |
| 248 | ): Promise<OpenAI.Images.ImagesResponse> { |
| 249 | let properties = []; |
| 250 | |
| 251 | if (typeof params.model === "string") { |
| 252 | properties.push({ |
| 253 | label: "model", |
| 254 | text: params.model, |
| 255 | }); |
| 256 | } |
| 257 | |
| 258 | if (params.n) { |
| 259 | properties.push({ |
| 260 | label: "Number of images", |
| 261 | text: params.n.toString(), |
| 262 | }); |
| 263 | } |
| 264 | |
| 265 | if (params.size) { |
| 266 | properties.push({ |
| 267 | label: "Size", |
| 268 | text: params.size, |
| 269 | }); |
| 270 | } |
| 271 | |
| 272 | if (params.response_format) { |
| 273 | properties.push({ |
| 274 | label: "Response format", |
| 275 | text: params.response_format, |
| 276 | }); |
| 277 | } |
| 278 | |
| 279 | if (typeof params.image === "string") { |
| 280 | properties.push({ |
| 281 | label: "Image URL", |
| 282 | text: params.image, |
| 283 | url: params.image, |
| 284 | }); |
| 285 | } |
| 286 | |
| 287 | return this.runTask( |
| 288 | key, |
| 289 | async (client, task) => { |
| 290 | const file = typeof params.image === "string" ? await fetch(params.image) : params.image; |
| 291 | |
| 292 | const { data, response } = await client.images |
| 293 | .createVariation( |
| 294 | { |
| 295 | image: file, |
| 296 | n: params.n, |
| 297 | size: params.size, |
| 298 | response_format: params.response_format, |
| 299 | user: params.user, |
| 300 | model: params.model, |
| 301 | }, |
no test coverage detected