Skip to main content

Sessions

The Expo layer owns a cross-platform session abstraction. A session keeps conversational state — natively where the provider supports it, emulated where it doesn't.

export type CreateSessionOptions = {
instructions?: string;
provider?: ExpoAIProvider;
fallback?: 'none' | 'cloud' | 'any';
temperature?: number;
maxOutputTokens?: number;
metadata?: Record<string, string>;
};

export type ExpoAISession = {
id: string;
provider: ExpoAIProvider;

generate(options: SessionGenerateOptions): Promise<GenerateResult>;
stream(options: SessionGenerateOptions): AsyncIterable<GenerateChunk>;
generateObject<T>(options: SessionGenerateObjectOptions): Promise<T>;

reset(): Promise<void>;
dispose(): Promise<void>;
};
const session = await ExpoAI.createSession({
instructions: 'You are a concise note-taking assistant.',
});
await session.generate({ prompt: 'Capture the action items from this meeting.' });
await session.dispose();

Native mapping

ConceptiOSAndroidCloud
SessionNative Foundation Models sessionNative or emulated sessionConversation / thread
InstructionsNative instructionsPrompt prefixSystem message
StreamingNative if availableNative or emulatedProvider stream
Structured outputNative if availableJSON prompt + validationJSON mode / tools
ToolsNative if availableEmulatedProvider tools