API reference
ai.llm(options) creates a Workers AI model wrapper for calling Cloudflare Workers AI from a Layeron backend.
Import
Section titled “Import”import { ai } from "@layeron/modules"ai.llm
Section titled “ai.llm”Create a Workers AI LLM wrapper.
TypeSpec operation: llm.
ai.llm(options: AiLlmOptions): AiLlmModuleAiLlmOptions
Section titled “AiLlmOptions”Options accepted by ai.llm(options).
| Field | Type | Description |
|---|---|---|
name | string | Stable AI instance name inside the Layeron app. |
namespace | string | undefined | Platform namespace for the instance. Defaults to default. |
model | string | Cloudflare Workers AI model identifier, for example @cf/meta/llama-3.1-8b-instruct. |
AiLlmRunInput
Section titled “AiLlmRunInput”Input accepted by assistant.run(input).
| Field | Type | Description |
|---|---|---|
prompt | string | Prompt text sent to the configured Workers AI model. |
options | Record<unknown> | undefined | Additional Workers AI options forwarded to AI.run. |
AiLlmPromptOptions
Section titled “AiLlmPromptOptions”Options accepted by assistant.prompt(prompt, options).
| Field | Type | Description |
|---|---|---|
options | Record<unknown> | undefined | Additional Workers AI options forwarded to AI.run. |
AiLlmModuleConfig
Section titled “AiLlmModuleConfig”Normalized AI LLM module configuration.
| Field | Type | Description |
|---|---|---|
kind | ”ai” | Module config kind. |
name | string | Stable AI instance name inside the Layeron app. |
namespace | string | Platform namespace for the instance. Defaults to default. |
model | string | Cloudflare Workers AI model identifier. |
binding | ”AI” | Workers AI binding name used by the AI product worker. |
AiLlmModule
Section titled “AiLlmModule”Layeron AI module returned by ai.llm(options).
| Field | Type | Description |
|---|---|---|
name | ”ai” | Module name. |
config | AiLlmModuleConfig | Normalized module configuration. |
Operations
Section titled “Operations”assistant.run
Section titled “assistant.run”Run the configured Workers AI model with a prompt and optional Workers AI options.
TypeSpec operation: aiLlmRun.
assistant.run(input: AiLlmRunInput): unknownassistant.prompt
Section titled “assistant.prompt”Run the configured Workers AI model with a prompt string.
TypeSpec operation: aiLlmPrompt.
assistant.prompt(prompt: string, options?: AiLlmPromptOptions): unknown