Compile-Time Schemas with Prompt.ask<T>
Attach '' LLM hints directly to record fields. SPL emits JSON Schema + runtime decoders at compile time.
1import llm from "std/llm"2
3'' Historical figure profile returned by the model.4type Person = struct {5 firstName: Str '' Given name, e.g. Ada6 lastName: Str '' Family name, e.g. Lovelace7 age: Int '' Age in years8 profession: Str '' Primary occupation9}10
11// Defaults to provider: "openai_responses", model: "gpt-6-luna", and ~/.spl/credentials.json (`spl login`).12// Automatically sends type_schema<Person>() and validates the JSON response!13let ada = @{14 Generate a profile for Ada Lovelace.15}.ask<Person>()?16
17print("${ada.firstName} ${ada.lastName} (${ada.age}) — ${ada.profession}")SPLX17 lines
Spaces: 4UTF-8LF