API reference
API reference
Select your platform
No SDKs available
No versions available

AIProviderBase Class

Extends ScriptableObject
Base class for AI providers (cloud or device).
Centralizes capability flags, shared validation, and common utilities used by concrete providers like OpenAIProvider and UnityInferenceEngineProvider. See the "AI Building Blocks" guide for usage patterns.
Guide: AI Building Blocks Overview Providers advertise supported execution via SupportedInferenceTypes and DefaultSupportedTypes; editor tooling reads these to enable/disable features.

Properties

abstract InferenceType DefaultSupportedTypes[Get]
InferenceType SupportedInferenceTypes[Get]

Protected Functions

Validates provider configuration parameters and throws descriptive exceptions if invalid.
Consolidates duplicate validation logic from all providers.
Parameters
apiKey
API key to validate (required).
endpoint
Endpoint URL to validate (optional).
model
Model ID to validate (optional).
Exceptions
InvalidOperationException
Thrown when required parameters are missing.
Prepares a ChatRequest by processing images (inline or redirect resolution).
Consolidates duplicate image prep loop that appears in OpenAI, Llama, HuggingFace providers.

Object Data for protected-static-func

Escapes string for safe JSON encoding.
Consolidates duplicate Esc() methods from multiple providers.
Parameters
s
String to escape.
Returns
JSON-safe escaped string.
Normalizes endpoint URLs by ensuring proper /v1 suffix for OpenAI-compatible APIs.
Consolidates endpoint normalization logic.
Parameters
endpoint
Endpoint URL to normalize.
defaultEndpoint
Default endpoint if input is empty.
Returns
Normalized endpoint URL.
Converts an ImageInput to a data URI string for use in API payloads.
If the image has bytes, encodes them as base64 with the appropriate MIME type. If the image has a URL, returns it as-is. Consolidates duplicate conversion logic from OpenAI, Llama, HuggingFace providers.
Parameters
img
Image input to convert.
defaultMime
Default MIME type to use if not specified (default: "image/png").
Returns
Data URI string or URL.