PlayKit.ai

API Reference

Complete API reference for the PlayKit Unreal SDK

API Reference

Complete reference for all PlayKit Unreal SDK classes and Blueprint nodes.

All client classes (UPlayKitChatClient, UPlayKitImageClient, etc.) are ActorComponents — add them to an Actor in the editor or via AddComponent. They are not created through factory functions. Results are delivered via Blueprint-assignable events, not callbacks.


UPlayKitBlueprintLibrary

Static utility functions accessible from any Blueprint or C++.

SDK State

FunctionReturnsDescription
IsReady()boolCheck if SDK is configured and ready
GetVersion()FStringGet current SDK version
IsAuthenticated()boolCheck if a valid auth token is present
GetAuthToken()FStringGet the current auth token
GetGameId()FStringGet the configured Game ID
GetBaseUrl()FStringGet the API base URL

NPC Setup

FunctionDescription
SetupNPC(NPCClient, ModelName)Initialize a UPlayKitNPCClient component with the given model

UPlayKitChatClient

UActorComponent for text generation. Stateless — it does not manage conversation history. Add to an Actor; bind events before calling methods.

Events

EventPayloadDescription
OnChatResponseFPlayKitChatResponseFired when a non-streaming response is complete
OnStreamChunkFString ChunkFired for each streaming text chunk
OnReasoningChunkFString ChunkFired for reasoning/thinking chunks
OnStreamCompleteFString FullTextFired when streaming finishes
OnErrorFString ErrorMessageFired on failure
OnStructuredResponseFString JsonStringFired when structured generation completes

Methods

MethodDescription
GenerateText(Prompt)Generate a response for a single prompt (uses SystemPrompt property)
GenerateTextAdvanced(Config: FPlayKitChatConfig)Generate with full message history and settings
GenerateTextStream(Prompt)Stream a response (fires OnStreamChunk + OnStreamComplete)
GenerateTextStreamAdvanced(Config)Stream with full config
GenerateStructured(Prompt, SchemaJson)Generate structured JSON output (fires OnStructuredResponse)
CancelRequest()Cancel the in-flight request
IsProcessing()Returns bool — whether a request is in flight

Configuration Properties

PropertyTypeDefaultDescription
ModelNameFString"default-chat"Model to use
Temperaturefloat0.7Response randomness (0.0–2.0)
MaxTokensint320Max tokens (0 = model default)
SystemPromptFStringSystem instruction for GenerateText shortcuts

C++ Example

// In Actor header:
UPROPERTY(VisibleAnywhere)
UPlayKitChatClient* ChatClient;

// In BeginPlay:
ChatClient->OnChatResponse.AddDynamic(this, &AMyActor::HandleResponse);
ChatClient->GenerateText(TEXT("Hello, who are you?"));

void AMyActor::HandleResponse(const FPlayKitChatResponse& Response)
{
    if (Response.bSuccess)
        UE_LOG(LogTemp, Log, TEXT("AI: %s"), *Response.Content);
    else
        UE_LOG(LogTemp, Error, TEXT("Error: %s"), *Response.ErrorMessage);
}

UPlayKitImageClient

UActorComponent for AI image generation. Results are delivered as FPlayKitGeneratedImage (Base64 PNG). Use Base64ToTexture2D to convert for engine use.

Events

EventPayloadDescription
OnImageGeneratedFPlayKitGeneratedImageFired when a single image is ready
OnImagesGeneratedTArray<FPlayKitGeneratedImage>Fired when a batch is ready
OnErrorFString ErrorMessageFired on failure

Methods

MethodDescription
GenerateImage(Prompt)Generate one image
GenerateImageWithSeed(Prompt, Seed)Generate with a fixed seed for reproducibility
GenerateImagesAdvanced(Prompt, Options: FPlayKitImageOptions)Generate with full options (count, size, seed, transparency)
CancelRequest()Cancel the in-flight request
IsProcessing()Returns bool
static Base64ToTexture2D(Base64Data)Convert Base64 string to UTexture2D*

Configuration Properties

PropertyTypeDefaultDescription
ModelNameFString"default-image"Model to use
ImageSizeFString"1024x1024"Default size string
QualityFString"standard""standard" or "hd"
ImageCountint321Default batch count (1–10)
Seedint32-1-1 = random

Supported Size Strings

"256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"

C++ Example

ImageClient->OnImageGenerated.AddDynamic(this, &AMyActor::HandleImage);
ImageClient->GenerateImage(TEXT("A dragon flying over mountains"));

void AMyActor::HandleImage(const FPlayKitGeneratedImage& Image)
{
    if (Image.bSuccess)
    {
        UTexture2D* Texture = UPlayKitImageClient::Base64ToTexture2D(Image.ImageBase64);
        MyMesh->GetMaterial(0)->SetTextureParameterValue(TEXT("Base"), Texture);
    }
}

UPlayKitSTTClient

UActorComponent for transcribing audio files or raw audio data. For real-time microphone recording, use UPlayKitSTTComponent.

Events

EventPayloadDescription
OnTranscriptionCompleteFPlayKitTranscriptionResultFired when transcription succeeds
OnErrorFString ErrorMessageFired on failure

Methods

MethodDescription
TranscribeFile(FilePath)Transcribe a local audio file
TranscribeFileWithLanguage(FilePath, Language)Transcribe with explicit language hint
TranscribeAudioData(AudioData, FileName)Transcribe raw PCM bytes
SetModelName(ModelName)Change the transcription model
SetLanguage(Language)Set default language code (e.g. "en", "zh")
CancelRequest()Cancel in-flight request
IsProcessing()Returns bool

UPlayKitSTTComponent

UActorComponent for real-time microphone recording and transcription. Pairs StartRecording/StopRecording with automatic transcription dispatch.

Events

EventPayloadDescription
OnPlayKitTranscriptionRespondedFPlayKitTranscriptionResultFired when transcription is ready
OnPlayKitTranscriptionErrorFString ErrorMessageFired on failure

Methods

MethodDescription
StartRecording()Begin microphone capture
StopRecording()Stop capture (transcription starts automatically)
StartTranscription(Request: FPlayKitTranscriptionRequest)Transcribe with explicit options
StartTranscriptionSimple()Transcribe the last recording with default settings
GetLastSavedFilePath()Returns the path of the last saved recording

Configuration Properties

PropertyTypeDescription
ModelNameFStringTranscription model to use

UPlayKit3DClient

UActorComponent for text-to-3D generation. Generation is asynchronous; the SDK polls the task until completion.

Events

EventPayloadDescription
OnCompletedFPlayKit3DTaskFired when the 3D model is ready
OnProgressint32 PercentFired during generation with progress (0–100)
OnStatusChangedEPlayKit3DTaskStatusFired when task status changes
OnErrorFString ErrorMessageFired on failure

Methods

MethodDescription
Generate3D(Prompt)Generate a 3D model from a text prompt
Generate3DWithNegative(Prompt, NegativePrompt)Generate with negative guidance
Generate3DAdvanced(Config: FPlayKit3DConfig)Full configuration
CancelTask()Cancel the current task
QueryTaskStatus(TaskId)Poll a task by ID
IsProcessing()Returns bool
GetCurrentTaskId()Returns FString
GetCurrentStatus()Returns EPlayKit3DTaskStatus
GetCurrentProgress()Returns int32 (0–100)

Configuration Properties

PropertyTypeDefaultDescription
ModelNameFString"default-3d-model"Model to use
ModelVersionFString"v2.5-20250123"Version string
DefaultTextureQualityEPlayKit3DQualityStandardStandard or Detailed
DefaultGeometryQualityEPlayKit3DQualityStandard
bDefaultPBRbooltrueGenerate PBR materials
DefaultFaceLimitint3250000Max polygon count (0–200000)

UPlayKitNPCClient

UActorComponent for NPC conversations. Automatically manages conversation history, memory, and reply predictions. Initialize via UPlayKitBlueprintLibrary::SetupNPC.

Events

EventPayloadDescription
OnResponseFString TextFired when NPC reply is ready
OnStreamChunkFString ChunkFired for each streaming chunk
OnStreamCompleteFString FullTextFired when streaming finishes
OnActionTriggeredFNPCActionCallArgsFired when NPC triggers a registered action
OnReplyPredictionsGeneratedTArray<FString>Fired with suggested player responses
OnErrorFString ErrorMessageFired on failure

Conversation Methods

MethodDescription
Talk(Message)Send a message; fires OnResponse
TalkStream(Message)Send with streaming; fires OnStreamChunk + OnStreamComplete
IsTalking()Returns bool — whether a request is in flight

Character & Memory

MethodDescription
SetCharacterDesign(Design)Set the NPC's personality system prompt
GetCharacterDesign()Returns current character design
SetMemory(Name, Content)Set a named memory entry
GetMemory(Name)Get a named memory entry
GetMemoryNames()Returns TArray<FString> of all memory names
ClearMemories()Remove all memories

History Management

MethodReturnsDescription
GetHistory()TArray<FNPCMessage>Get full conversation history
GetHistoryLength()int32Number of messages
ClearHistory()Reset the conversation
RevertHistory()boolUndo the last exchange
RevertChatMessages(Count)int32Undo the last N messages
AppendChatMessage(Role, Content)Manually append to history
SaveHistory()FStringSerialize history to JSON
LoadHistory(SaveData)boolLoad from JSON

Reply Predictions

MethodDescription
GenerateReplyPredictions(Count)Generate suggested player responses (fires OnReplyPredictionsGenerated)

Action Results

MethodDescription
ReportActionResult(CallId, Result)Report the result of a single action
ReportActionResults(Results)Report results of multiple actions (TMap<FString, FString>)

Configuration Properties

PropertyTypeDefaultDescription
Temperaturefloat0.7Response randomness (0.0–2.0)
bAutoGenerateReplyPredictionsboolfalseAuto-generate predictions after each reply
PredictionCountint323Number of predictions to generate (2–6)

UPlayKitPlayerClient

UGameInstanceSubsystem for player info and credits. Access via UPlayKitPlayerClient::Get(WorldContextObject) or UPlayKitBlueprintLibrary::GetPlayerClient(WorldContextObject).

Events

EventPayloadDescription
OnPlayerInfoUpdatedFPlayKitPlayerInfoFired when player info is refreshed
OnPlayerTokenReceivedFString TokenFired when a new player token arrives
OnDailyCreditsRefreshedFPlayKitDailyCreditsResultFired when daily credits are added
OnErrorFString ErrorMessageFired on failure

Methods

MethodReturnsDescription
static Get(WorldContextObject)UPlayKitPlayerClient*Get the subsystem instance
HasValidToken()boolCheck if a player token is present
GetCachedPlayerInfo()FPlayKitPlayerInfoGet last-fetched player info
GetCredits()floatShorthand for cached credits
GetNickname()FStringShorthand for cached nickname
GetPlayerInfo()Async fetch; fires OnPlayerInfoUpdated
SetNickname(Nickname)Update the player's display name
RefreshDailyCredits()Trigger a daily credit refresh
ExchangeJWT(JWT)Exchange a backend JWT for a player token
SetPlayerToken(Token)Set a token directly
ClearPlayerToken()Remove the current token

UPlayKitDeviceAuthFlow

UObject for the player device authentication flow. Create via CreateDeviceAuthFlow(WorldContextObject).

Events

EventPayloadDescription
OnAuthUrlReadyFString URLFired when the auth URL is ready to display
OnStatusChangedEDeviceAuthStatusFired on status transitions
OnAuthSuccessFDeviceAuthResultFired when authentication succeeds
OnAuthErrorFString ErrorMessageFired on failure

Methods

MethodDescription
static CreateDeviceAuthFlow(WorldContextObject)Create a new flow object
StartAuthFlow(GameId, Scope)Begin the flow (Scope defaults to "player:play")
CancelAuthFlow()Cancel
GetStatus()Returns EDeviceAuthStatus
GetAuthUrl()Returns FString — the URL to show the player
GetUserCode()Returns FString — the user code (if applicable)
IsActive()Returns bool

EDeviceAuthStatus

Idle, Pending, Polling, Success, Expired, Cancelled, Error


UPlayKitNPCActionsModule

UActorComponent that registers actions an NPC can trigger during conversation. Add alongside UPlayKitNPCClient on the same Actor.

Methods

MethodDescription
RegisterAction(Action, Handler)Register an action by FNPCAction + FOnActionExecute delegate
RegisterActionBinding(Binding)Register via FNPCActionBinding (useful for Blueprint)
UnregisterAction(ActionName)Remove an action
GetEnabledActions()Returns TArray<FNPCAction>
HasEnabledActions()Returns bool
ExecuteAction(Args)Manually execute an action
GetActionsAsJsonSchema()Returns actions as JSON schema string

UPlayKitNPCActionLibrary (Helper Functions)

FunctionDescription
GetActionString(Args, ParamName)Extract a string parameter from action call args
GetActionNumber(Args, ParamName)Extract a float parameter
GetActionInt(Args, ParamName)Extract an int32 parameter
GetActionBool(Args, ParamName)Extract a bool parameter
ActionHasParam(Args, ParamName)Check if parameter exists
CreateAction(Name, Description)Build a FNPCAction
AddStringParameter(Action, Name, Desc, bRequired)Add a string parameter to an action
AddNumberParameter(Action, Name, Desc, bRequired)Add a number parameter
AddBoolParameter(Action, Name, Desc, bRequired)Add a bool parameter
AddEnumParameter(Action, Name, Desc, Options, bRequired)Add an enum parameter

UPlayKitAIContextManager

UGameInstanceSubsystem that tracks global player context and manages NPC conversation compaction. Access via UPlayKitAIContextManager::Get(WorldContextObject).

Player Description

MethodDescription
SetPlayerDescription(Description)Set a global player context string injected into all NPC prompts
GetPlayerDescription()Returns FString
ClearPlayerDescription()Remove the player description

NPC Tracking & Compaction

MethodDescription
RegisterNPC(NPC)Track an NPC for auto-compaction
UnregisterNPC(NPC)Stop tracking
RecordConversation(NPC)Mark that a conversation occurred (resets idle timer)
EnableAutoCompact(TimeoutSeconds, MinMessages)Enable automatic history summarization
DisableAutoCompact()Disable
IsEligibleForCompaction(NPC)Returns bool
CompactConversation(NPC)Manually compact one NPC's history
CompactAllEligible()Compact all eligible NPCs; returns int32 count

Data Types

FPlayKitChatConfig

USTRUCT(BlueprintType)
struct FPlayKitChatConfig
{
    TArray<FPlayKitChatMessage> Messages;
    float Temperature;     // 0.0–2.0
    int32 MaxTokens;       // 0 = model default
    bool bEnableThinking;
    EPlayKitThinkingEffort ThinkingEffort; // Minimal, Low, Medium, High, Max
};

FPlayKitChatResponse

USTRUCT(BlueprintType)
struct FPlayKitChatResponse
{
    bool bSuccess;
    FString Content;
    FString FinishReason;
    TArray<FPlayKitToolCall> ToolCalls;
    FString ErrorMessage;
    int32 PromptTokens;
    int32 CompletionTokens;
    int32 TotalTokens;
    FString Reasoning;     // Populated when thinking is enabled
};

FPlayKitGeneratedImage

USTRUCT(BlueprintType)
struct FPlayKitGeneratedImage
{
    bool bSuccess;
    FString ImageBase64;   // Base64-encoded PNG — convert with Base64ToTexture2D
    FString OriginalPrompt;
    FString RevisedPrompt;
    FDateTime GeneratedAt;
    FString ErrorMessage;
};

FPlayKitImageOptions

USTRUCT(BlueprintType)
struct FPlayKitImageOptions
{
    FString Size;          // e.g. "1024x1024"
    int32 Count;           // 1–10
    int32 Seed;            // -1 = random
    bool bTransparent;
};

FPlayKitTranscriptionResult

USTRUCT(BlueprintType)
struct FPlayKitTranscriptionResult
{
    bool bSuccess;
    FString Text;
    FString Language;
    float DurationSeconds;
    TArray<FPlayKitTranscriptionSegment> Segments;
    FString ErrorMessage;
};

FPlayKitPlayerInfo

USTRUCT(BlueprintType)
struct FPlayKitPlayerInfo
{
    FString UserId;
    float Credits;
    FString Nickname;
};

FNPCMessage

USTRUCT(BlueprintType)
struct FNPCMessage
{
    FString Role;     // "system", "user", "assistant"
    FString Content;
};

UPlayKitSettings

Project settings at Edit > Project Settings > Plugins > PlayKit SDK.

SettingTypeDescription
GameIdFStringApplication ID from the dashboard
DefaultChatModelFStringDefault model for UPlayKitChatClient
DefaultImageModelFStringDefault model for UPlayKitImageClient
DefaultTranscriptionModelFStringDefault model for STT
Default3DModelFStringDefault model for UPlayKit3DClient
FastModelFStringFast model used for context compaction
bEnableAutoCompactboolEnable auto-compaction globally
AutoCompactTimeoutSecondsfloatIdle time before compaction eligibility
AutoCompactMinMessagesint32Minimum messages required for compaction
bEnableDebugLoggingboolEnable SDK debug output