Parse custom headers, adding x-custom- prefix
(raw?: string)
| 78 | |
| 79 | /** Parse custom headers, adding x-custom- prefix */ |
| 80 | function parseCustomHeaders(raw?: string): Record<string, string> { |
| 81 | if (!raw) return {}; |
| 82 | const headers: Record<string, string> = {}; |
| 83 | for (const line of raw.split('\n')) { |
| 84 | const trimmed = line.trim(); |
| 85 | if (!trimmed) continue; |
| 86 | const idx = trimmed.indexOf(':'); |
| 87 | if (idx > 0) { |
| 88 | const key = trimmed.slice(0, idx).trim().toLowerCase(); |
| 89 | const val = trimmed.slice(idx + 1).trim(); |
| 90 | headers[`x-custom-${key}`] = val; |
| 91 | } |
| 92 | } |
| 93 | return headers; |
| 94 | } |
| 95 | |
| 96 | export async function generateImage( |
| 97 | prompt: string, |
no outgoing calls
no test coverage detected