Skip to content

Images

(llm.images)

Overview

Available Operations

createImage

Create AI-generated images from text descriptions using state-of-the-art image generation models including DALL-E 2, DALL-E 3, GPT-Image, and Google Imagen. Supports extensive customization options: generate 1-10 images per request (DALL-E 2 only supports n>1), choose from multiple sizes (256x256, 512x512, 1024x1024, 1792x1024, 1024x1792), select quality levels (standard or HD for DALL-E 3), and control artistic style (vivid for dramatic/hyper-real or natural for realistic images). Returns either URLs to generated images (valid for 1 hour) or base64-encoded image data for immediate use. Automatically handles provider-specific parameter mappings and optimizations.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.images.createImage({
    prompt: "<value>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmImagesCreateImage } from "@meetkai/mka1/funcs/llmImagesCreateImage.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmImagesCreateImage(sdk, {
    prompt: "<value>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmImagesCreateImage failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmImagesCreateImageMutation
} from "@meetkai/mka1/react-query/llmImagesCreateImage.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateImageRequestBody✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateImageResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*