Mika Scraper / GeminiCanvas
Function: GeminiCanvas()
GeminiCanvas
(prompt
, base64Image
, mimeType
, apiKey
): `Promise<{
imageBuffer?:
Buffer<
ArrayBufferLike>;
textResponse?:
string`; }>
Defined in: src/gemini/gemini.ts:12
Generates an image and text response from the Gemini API using the provided prompt and base64-encoded image.
Parameters
prompt
string
A textual prompt that influences the image generation.
base64Image
string
Base64-encoded image data to be used as input for the image generation.
mimeType
string
The MIME type of the image. Common types include "image/png"
and "image/jpeg"
.
apiKey
string
The API key required to authenticate the request to the Gemini service.
Returns
`Promise<{
imageBuffer?:
Buffer<
ArrayBufferLike>;
textResponse?:
string`; }>
A promise that resolves to an object containing the following properties:
imageBuffer
(optional): ABuffer
representing the generated image data.textResponse
(optional): A string containing related textual information from the Gemini API.
Example
import { GeminiCanvas } from "mika-scraper";
const prompt = "A futuristic city skyline at sunset";
const base64Image = "data:image/png;base64,..."; // Base64 image data
const mimeType = "image/png";
const apiKey = "your_api_key_here";
GeminiCanvas(prompt, base64Image, mimeType, apiKey)
.then((result) => {
if (result.imageBuffer) {
// Handle the image buffer
}
if (result.textResponse) {
// Handle the text response
}
})
.catch((error) => {
// Handle error
});