Skip to content

Types Reference

TypeDescriptionExamples
textString value"hello", 'world'
numberNumeric value42, -3.14
booleanBoolean valuetrue, false
jsonObject or array{ key: "value" }
promptPrompt stringSame as text
nullNull valuenull
TypeDescription
modelAI model configuration (always immutable)

Define custom types with the type keyword:

type Result {
valid: boolean
message: text
count: number
}
type TypeName {
fieldName: fieldType
// ... more fields
}

Fields can be separated by commas, newlines, or both:

// Comma-separated
type Point { x: number, y: number }
// Newline-separated
type Config {
timeout: number
retries: number
}
// Mixed
type Mixed { a: text, b: number
c: boolean
}

Reference other types or use inline nested objects:

type Inner { value: number }
type Outer {
inner: Inner // Reference named type
metadata: { // Inline nested object
timestamp: number
source: text
}
}
type Player { name: text, score: number }
type Team { players: Player[] }
let team: Team = do "Create a team with 3 players" model

Use named types in:

// Variable declarations
let result: Result = do "Validate input" model
// Function parameters
function process(data: Result): text {
return data.message
}
// Function return types
function check(): Result {
return { valid: true, message: "OK", count: 1 }
}
// Arrays
let results: Result[] = []

Accessing fields on typed variables returns the field’s type:

type Status { active: boolean, count: number }
let s: Status = do "Get status" model
// s.active is boolean (can use in if conditions)
if s.active {
print("Active")
}
// s.count is number
let doubled = s.count * 2

Append [] to any type:

TypeDescription
text[]Array of strings
number[]Array of numbers
boolean[]Array of booleans
json[]Array of objects
let matrix: number[][] = [[1, 2], [3, 4]]
let nested: text[][][] = [[["a", "b"]], [["c"]]]
let name: text = "Alice"
let age: number = 30
let active: boolean = true
let config: json = { timeout: 5000 }
let items: text[] = ["a", "b", "c"]
function greet(name: text, times: number): text {
// ...
}
function getItems(): text[] {
return ["a", "b", "c"]
}
function getConfig(): json {
return { key: "value" }
}

Types are inferred when not specified:

let name = "Alice" // text
let count = 42 // number
let active = true // boolean
let items = [1, 2, 3] // number[]
let config = { a: 1 } // json

Specify return type for AI expressions:

// Without type - returns text
let result = do "How many?"
// With type - returns parsed value
let count: number = do "How many planets?"
let valid: boolean = do "Is this correct?"
let items: text[] = do "List 5 items"
let data: json = do "Return structured data"

Variables can hold null:

let maybe: text = null
let result = null

text and prompt are interchangeable:

let message: text = "Hello"
let prompt: prompt = message // OK

json accepts objects and arrays:

let obj: json = { name: "Alice" }
let arr: json = [1, 2, 3]
let nested: json = { items: [1, 2, 3] }

Models are always const:

model myModel = {
name: "claude-sonnet-4-20250514",
provider: "anthropic",
apiKey: env("API_KEY")
}
// Cannot reassign
// myModel = { ... } // Error

Vibe does not perform automatic type coercion:

let num = 42
let str = "The answer is: "
// Must explicitly convert
let message = str + num // Error: cannot add text and number
// Use ts block for conversion
let message = ts(str, num) {
return str + num.toString();
}

Conditions must be boolean:

let count = 5
// This works
if count > 0 { }
if count == 0 { }
// This does NOT work
// if count { } // Error: condition must be boolean
// if "string" { } // Error