Skip to main content

Inference Data Model

Inference manages three collections: providers, models, and requests. All entities use nanoid(8) identifiers and support both file-based and Convex storage backends.

InferenceProvider

A registered AI provider configuration.

interface InferenceProvider {
id: string; // nanoid(8)
name: string; // Unique name
type: ProviderType; // Provider implementation
baseUrl?: string; // Custom API base URL
defaultModel?: string; // Default model for this provider
envVar?: string; // Environment variable for API key
created: string; // ISO 8601
updated: string; // ISO 8601
}

type ProviderType = "anthropic" | "openai" | "google";

Default Environment Variables

TypeEnv Variable
anthropicANTHROPIC_API_KEY
openaiOPENAI_API_KEY
googleGEMINI_API_KEY

InferenceModel

A synced AI model with capability metadata.

interface InferenceModel {
id: string; // nanoid(8)
providerId: string; // Parent provider ID
modelId: string; // Provider's model identifier
name: string; // Display name
contextWindow?: number; // Max context length (tokens)
maxOutput?: number; // Max output length (tokens)
supportsStreaming: boolean; // SSE streaming support
supportsEmbeddings: boolean; // Text embedding support
supportsImageGeneration: boolean; // Image generation support
supportsTranscription: boolean; // Audio transcription support
created: string; // ISO 8601
}

InferenceRequest

A logged inference operation for usage tracking.

interface InferenceRequest {
id: string; // nanoid(8)
providerId: string; // Provider that handled the request
model: string; // Model used
type: RequestType; // Operation type
inputTokens: number; // Input token count
outputTokens: number; // Output token count
durationMs: number; // Request duration in milliseconds
status: "success" | "error";
error?: string; // Error message (on failure)
timestamp: string; // ISO 8601
}

type RequestType = "chat" | "embed" | "image" | "transcribe";

InferenceConfig

Service configuration.

interface InferenceConfig {
version: string;
defaultProvider?: string; // Default provider ID
defaultModel?: string; // Default model name
}

Storage

File-Based (SHIFT_STORAGE=file)

.inference/
config.json # InferenceConfig
providers/<id>.json # Provider records
models/<id>.json # Synced model records
requests/<id>.json # Request logs

Convex (SHIFT_STORAGE=convex)

Tables use the inference_ prefix:

TableDescription
inference_providersProvider configurations
inference_modelsSynced model metadata
inference_requestsRequest usage logs

Each record includes a sid field (shift ID) that maps to the application-level id.