AIML Syntax
Learn about the core syntax features of AIML
AIML Syntax
AIML combines markdown with XML/JSX-style elements to create a powerful yet familiar syntax for building AI agents.
File Structure
An AIML file consists of these main components:
Frontmatter
The frontmatter section defines file-level settings:
Prop | Type | Default |
---|---|---|
name | string | - |
model? | string | account/fireworks/model/deepseek-v3 |
temperature? | number | 0.7 |
maxTokens? | number | 1000 |
topP? | number | 0.9 |
topK? | number | 100 |
System Prompts
Top level text is interpreted as a system prompt and a step in the workflow.
Comments
Comments use JSX-style syntax and are completely ignored but provide annotations for the developer within traces, in the editor and in the UI:
Elements
Elements are XML/JSX-style tags that define specific behaviors:
Basic Element Structure
Dynamic Attributes
Attributes can be dynamic using JavaScript expressions:
Dynamic Attributes / Context Access
Anywhere in the file, you can access the context of the current step, input variables, output from the previous step, and the state of the workflow using function syntax:
Attributes likewise can be dynamic using the same syntax:
Nested Elements
Elements can be nested to create complex behaviors:
State Management
AIML provides built-in state management:
Control Flow
Control flow elements help manage the execution flow:
Document Order Execution
AIML prompts are executed sequentially from top to bottom, making it intuitive to build complex prompt pipelines. Each text section, and element (along with it's children) is processed in order, allowing you to create sophisticated workflows while maintaining readability.
Circular Logic
To create circular logic, AIML supports <state>
elements. States, along with <transition>
elements allow you to create loops, or to create more complex conditional logic by tying one or more states together.
This will create a conditional loop that can be visualized as a flow chart like this:
Next Steps
- Learn about Core Elements
- Explore State Management
- See Examples