AI Providers
Configure Anthropic Claude, OpenAI-compatible, or Google Gemini
UND supports three AI provider backends, each implementing the same streaming interface. You can switch between providers at any time, use different providers for different agent profiles, or configure multiple profiles for the same provider with different models.
Provider Interface
All providers implement the IUNDProvider interface with two core methods:
- StreamRequest -- Sends a conversation (system prompt + messages + tool descriptors) to the AI model as a non-blocking SSE (Server-Sent Events) stream. Callbacks fire on the Game Thread.
- CancelRequest -- Cancels an in-flight request.
Every provider also reports IsConfigured() (API key present) and GetMaxContextTokens() (model context window size).
Streaming Callbacks
The provider delivers results through five callbacks:
| Callback | Description |
|---|---|
| OnTextDelta | Text streaming chunks as they arrive from the model |
| OnReasoningDelta | Reasoning/thinking content (supported by models like DeepSeek R1) |
| OnToolCallComplete | A fully accumulated tool call with name and JSON parameters |
| OnStreamFinished | The response is complete, includes token usage statistics |
| OnError | An unrecoverable error occurred |
All callbacks dispatch to the Game Thread via AsyncTask, so UI updates and tool execution happen safely without threading issues.
Lifetime Safety
Providers can be recreated mid-conversation when settings change (for example, switching models). To prevent use-after-free crashes, all three provider implementations use a shared validity flag pattern: a TSharedPtr<bool> set to false in the destructor. Async callbacks that captured the provider pointer check this flag before calling any member functions.
Anthropic Claude
The recommended provider for autonomous game prototyping. Anthropic's Claude models have the strongest tool-use capabilities and handle complex multi-step Blueprint creation workflows reliably.
API: Messages API with SSE streaming
Features:
- Full tool-use support with parallel tool calls
- Interleaved thinking (beta header
interleaved-thinking-2025-05-14) for transparent reasoning - Extended context windows (up to 200K tokens)
- Strong performance on code generation and UE5 API usage
SSE Events Handled: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop
Configuration: Set the ANTHROPIC_API_KEY environment variable. The key is read from the environment at runtime and is never stored in config files.
OpenAI-Compatible
A versatile provider that works with any endpoint implementing the OpenAI Chat Completions API. This covers a wide range of services and local models.
API: Chat Completions API with SSE streaming
Compatible Services:
- OpenAI (GPT-4, GPT-4o, o1, o3)
- OpenRouter (access to many models through one API)
- Ollama (local models)
- LM Studio (local models)
- Mistral
- Groq
- xAI (Grok)
- Any other OpenAI-compatible endpoint
Configuration: Set the appropriate environment variable for your service (e.g., OPENAI_API_KEY, OPENROUTER_API_KEY). Configure the base URL in the provider profile if using a non-OpenAI endpoint.
Google Gemini
Support for Google's Gemini models via the generateContent API.
API: generateContent with alt=sse for streaming
Configuration: Set the GEMINI_API_KEY environment variable.
Provider Configuration
API Keys
API keys are never stored in UE configuration files. UND provides two methods to supply keys at runtime:
Method 1 — apikeys.cfg (recommended): On first launch, UND creates a template file at {Project}/Saved/UND/apikeys.cfg. Edit it to add your keys in ENV_VAR_NAME=key format (one per line, # for comments). UND reads this file fresh on every request, so changes take effect immediately without restarting the editor. The file is inside Saved/, which is excluded from version control by default.
ANTHROPIC_API_KEY=sk-ant-your-key-here
OPENAI_API_KEY=sk-your-key-here
# GEMINI_API_KEY=your-key-hereMethod 2 — Environment variables: Set the variable on your system (e.g., ANTHROPIC_API_KEY=sk-ant-...) and restart the Unreal Editor. Environment variables are read at process start.
UND checks both sources in order: environment variable first, then apikeys.cfg as fallback. This lets you override the file with an env var in CI/CD environments while keeping the file method for local development.
Provider Profiles
Provider profiles are configured in UND Settings. Each profile specifies:
- Profile name -- A human-readable identifier
- Provider type -- Anthropic, OpenAI-Compatible, or Gemini
- Model name -- The specific model to use (e.g.,
claude-sonnet-4-20250514) - API key environment variable -- Which env var to read for the API key
- Base URL -- Custom endpoint URL (for OpenAI-compatible services)
- Max context tokens -- Override the default context window size
You can create multiple profiles and switch between them using the provider selector in the UND panel. Different agent profiles can also be configured to use different providers.
Provider Presets
UND ships with a built-in catalogue of provider presets grouped by brand. These presets pre-fill the profile configuration with correct base URLs, model names, and API key environment variable names for popular services. You can select a preset when creating a new provider profile to skip manual configuration.
SSE Streaming Architecture
All providers use the same underlying SSE streaming infrastructure:
-
FUNDSSEStream -- An
FArchivesubclass that receives raw HTTP response bytes on the HTTP thread. It batches incoming data and flushes to the Game Thread at approximately 60fps (every ~16ms or at a 4KB threshold) to prevent excessive async task creation. -
FUNDSSEParser -- A stateful line parser that processes the decoded text stream according to the SSE protocol. It accumulates lines and emits complete SSE events on blank-line boundaries.
-
Provider parser -- Each provider implementation interprets the SSE events according to its API format (Anthropic, OpenAI, or Gemini event schemas) and fires the appropriate callbacks.
This architecture ensures smooth streaming of AI responses in the chat UI without blocking the editor or dropping frames.
Choosing a Provider
| Consideration | Recommendation |
|---|---|
| Best tool-use accuracy | Anthropic Claude |
| Largest model selection | OpenAI-Compatible (via OpenRouter) |
| Local/offline usage | OpenAI-Compatible (via Ollama or LM Studio) |
| Budget-conscious | OpenAI-Compatible (via Groq or local models) |
| Google ecosystem | Google Gemini |
For autonomous game prototyping workflows where the AI needs to chain many tool calls reliably, Anthropic Claude models consistently produce the best results.