Skip to main content

AI API Reference

kittl.ai — AI generation and credit operations.

Scope: ai:credit:spend


spendCredits(options)

Prompts the user with a confirmation dialog before spending AI credits.

PropertyTypeRequiredDescription
amountnumberYesNumber of credits to spend
messagestringYesMessage shown to the user explaining the spend
onAccept() => voidNoCallback invoked when the user accepts
onDecline() => voidNoCallback invoked when the user declines

Returns: SdkResultAsync<SpendCreditsResult>

SpendCreditsResult

PropertyTypeDescription
successbooleanWhether the user confirmed the credit spend

startGeneration(generatorId, inputSettings, output)

Starts an AI generation (image or video).

ParameterTypeDescription
generatorIdstringUnique identifier for your generator
inputSettingsAIGenerationInputSettingsPrompt, model, and generation parameters
outputAIGenerationOutputSettingsDesired output dimensions

Returns: SdkResultAsync<StartGenerationResult>

StartGenerationResult

PropertyTypeDescription
generationIdstringUnique ID for the started generation

registerHandler(generatorId, onStatusUpdate)

Subscribes to generation status updates for a specific generator. The callback fires on every status transition.

ParameterTypeDescription
generatorIdstringThe generator to listen on (must match the ID passed to startGeneration)
onStatusUpdateOnGenerationStatusUpdateCallback invoked on each status change

Returns: SdkResultAsync<() => void> — the result contains an unsubscribe function. Call it to stop receiving updates.


Types

AIGenerationInputSettings

PropertyTypeRequiredDescription
promptstringYesThe text prompt for generation
model{ id: string }YesModel identifier
typeAIGenerationContentTypeYesContent type to generate
taskTypeAIGenerationModelTaskTypeNoSpecific task variant
promptStyleIdnumberNoStyle preset ID
additionalParamsRecord<string, unknown>NoExtra model-specific parameters

AIGenerationOutputSettings

PropertyTypeRequiredDescription
idstringNoOptional output target ID
dimensions{ width: number; height: number }YesDesired output dimensions in pixels

AIGenerationContentType

type AIGenerationContentType = 'image' | 'video';

AIGenerationModelTaskType

type AIGenerationModelTaskType =
| 'TEXT_TO_IMAGE'
| 'IMAGE_TO_IMAGE'
| 'IMAGE_INPAINT'
| 'IMAGE_TO_VIDEO';

OnGenerationStatusUpdate

type OnGenerationStatusUpdate = (update: GenerationStatusUpdate) => void | Promise<void>;

GenerationStatusUpdate

A discriminated union on the status field. Each variant carries different inputData and result shapes:

StatusinputDataresult
'CREATED'undefinedundefined
'STARTED'GenerationInputDataStartedGenerationResult
'COMPLETE'GenerationInputDataSuccessGenerationResult
'FAILED'GenerationInputData | undefinedErrorGenerationResult

All variants include generationId: string.

GenerationInputData

PropertyTypeDescription
promptstring?The prompt that was used
style{ id: number }?Style preset if any
model{ id: string }?Model that was used

StartedGenerationResult

ImageGenerationStartedResult | VideoGenerationStartedResult

PropertyTypeDescription
type'image' | 'video'Content type
generationEndsAtnumber?Estimated completion timestamp (ms)

SuccessGenerationResult

ImageGenerationResult | VideoGenerationResult

ImageGenerationResult

PropertyTypeDescription
type'image'Always 'image'
objectNamestringName of the generated image object on the canvas

VideoGenerationResult

PropertyTypeDescription
type'video'Always 'video'
status'PROCESSING' | 'READY' | 'FAILED'Video processing state
playbackIdstring?Playback identifier
durationnumber?Duration in seconds
aspectRatiostring?Aspect ratio (e.g. '16:9')
hostingProvider'MUX'?Hosting provider

ErrorGenerationResult

PropertyTypeDescription
type'error'Always 'error'
messagestringHuman-readable error message
codestring?Machine-readable error code

GenerationStatus

const GenerationStatus = {
CREATED: 'CREATED',
STARTED: 'STARTED',
COMPLETE: 'COMPLETE',
FAILED: 'FAILED',
} as const;