MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / backgroundGenerate

Method backgroundGenerate

integrations/openai/src/images.ts:95–151  ·  view source on GitHub ↗
(
    key: IntegrationTaskKey,
    params: Prettify<OpenAI.Images.ImageGenerateParams>,
    options: OpenAIRequestOptions = {},
    fetchOptions: { retries?: FetchRetryOptions; timeout?: FetchTimeoutOptions } = {}
  )

Source from the content-addressed store, hash-verified

93 }
94
95 backgroundGenerate(
96 key: IntegrationTaskKey,
97 params: Prettify<OpenAI.Images.ImageGenerateParams>,
98 options: OpenAIRequestOptions = {},
99 fetchOptions: { retries?: FetchRetryOptions; timeout?: FetchTimeoutOptions } = {}
100 ): Promise<OpenAI.Images.ImagesResponse> {
101 return this.runTask(
102 key,
103 async (client, task, io) => {
104 const url = createBackgroundFetchUrl(
105 client,
106 "/images/generations",
107 this.options.defaultQuery,
108 options
109 );
110
111 const response = await io.backgroundFetchResponse<OpenAI.Images.ImagesResponse>(
112 "background",
113 url,
114 {
115 method: options.method ?? "POST",
116 headers: createBackgroundFetchHeaders(
117 client,
118 task.idempotencyKey,
119 this.options.defaultHeaders,
120 options
121 ),
122 body: JSON.stringify(params),
123 },
124 {
125 retry: fetchOptions?.retries ?? backgroundTaskRetries,
126 timeout: fetchOptions?.timeout,
127 }
128 );
129
130 task.outputProperties = createImageTaskOutputProperties(
131 response.data,
132 new Headers(response.headers)
133 );
134
135 return response.data;
136 },
137 {
138 name: "Background Image Generate",
139 params,
140 properties: [
141 {
142 label: "model",
143 text: params.model ?? "unknown",
144 },
145 ],
146 retry: {
147 limit: 0,
148 },
149 }
150 );
151 }
152

Callers 1

backgroundCreateMethod · 0.95

Calls 4

createBackgroundFetchUrlFunction · 0.90
runTaskMethod · 0.45

Tested by

no test coverage detected