Creating Plot Twists
    Preparing search index...

    Interface AIRequest<TOOLS, SCHEMA>

    Request parameters for AI text generation, matching Vercel AI SDK's generateText() function.

    interface AIRequest<TOOLS extends AIToolSet, SCHEMA extends TSchema = never> {
        model: ModelPreferences;
        system?: string;
        prompt?: string;
        messages?: AIMessage[];
        tools?: TOOLS;
        toolChoice?: ToolChoice<TOOLS>;
        outputSchema?: SCHEMA;
        maxOutputTokens?: number;
        temperature?: number;
        topP?: number;
        webSearch?: boolean | { maxUses?: number };
        maxSteps?: number;
    }

    Type Parameters

    • TOOLS extends AIToolSet
    • SCHEMA extends TSchema = never
    Index

    Properties

    Model selection preferences based on desired speed and cost characteristics. Plot will automatically select the best available model matching these preferences.

    // Fast and cheap - good for simple tasks
    model: { speed: "fast", cost: "low" }
    // Balanced performance - general purpose
    model: { speed: "balanced", cost: "medium" }
    // Maximum capability - complex reasoning
    model: { speed: "capable", cost: "high" }
    // With a specific model hint
    model: { speed: "balanced", cost: "medium", hint: "anthropic/claude-sonnet-4-6" }
    system?: string

    System instructions to guide the model's behavior.

    prompt?: string

    The user's input prompt. Can be a simple string or an array of messages for multi-turn conversations.

    messages?: AIMessage[]

    Conversation messages for multi-turn interactions. Replaces 'prompt' for more complex conversations.

    tools?: TOOLS

    Tools that the model can call during generation. Each tool definition includes a description, input schema, and optional execute function.

    toolChoice?: ToolChoice<TOOLS>

    Controls which tools the model can use.

    • "auto": Model decides whether to use tools
    • "none": Model cannot use tools
    • "required": Model must use at least one tool
    • { type: "tool", toolName: string }: Model must use specific tool
    outputSchema?: SCHEMA

    Structured output schema using Typebox. Typebox schemas are JSON Schema objects that provide full TypeScript type inference.

    maxOutputTokens?: number

    Maximum number of tokens to generate.

    temperature?: number

    Temperature for controlling randomness (0-2). Higher values make output more random, lower values more deterministic.

    topP?: number

    Top P sampling parameter (0-1). Controls diversity by limiting to top probability tokens.

    webSearch?: boolean | { maxUses?: number }

    Enable provider-native web search so the model can retrieve up-to-date information from the web. The search is executed server-side by the provider and any pages used are returned in AIResponse.sources.

    Only available on web-search-capable providers (Anthropic and Google). Check AICapabilities.webSearch via available() before relying on it; on unsupported providers the flag is ignored.

    Pass true for defaults, or an object to cap the number of searches.

    maxSteps?: number

    Maximum number of sequential generation steps for agentic tool use. When the model calls a tool, its result is fed back and the model is called again, up to maxSteps times, until it produces a final answer.

    Defaults to 1 (single step — tool calls are returned but not looped), preserving prior behavior. Set higher (e.g. 6) to let the model chain tool calls into a final answer.