Skip to main content
Version: 0.0.8

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.


unregisterHandler(generatorId)​

Unsubscribes from generation status updates for a specific generator. Use this as an alternative to calling the unsubscribe function returned by registerHandler.

ParameterTypeDescription
generatorIdstringThe generator to stop listening on

Returns: SdkResultAsync<void>


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
actionOriginAIGenerationActionOriginNoOrigin of the generation action

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
subtitlestringSecondary message (shorter description)
status'warning' | 'error'Severity level of the failure

GenerationMeta​

PropertyTypeDescription
generationEndsAtnumber?Estimated completion timestamp (ms)
pendingGenerationIdstringID of the pending generation
operationGenerationOperation?The operation type (e.g. inpaint)

GenerationOperation​

const GenerationOperation = {
INPAINT: 'inpaint',
} as const;

type GenerationOperation = (typeof GenerationOperation)[keyof typeof GenerationOperation];

GenerationStatus​

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