> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Generate AI output

> Generate text or typed structured data with an AI model.

The built-in `generate` action produces text or schema-validated structured data. Omit `account` to use the platform Vercel AI Gateway credential and consume one generation from the organization's monthly allowance. Customer-managed provider accounts do not consume this allowance. The default model is `openai/gpt-4.1-nano`.

## Example

```ts automations/recipe.automation.ts theme={null}
import { automation, generate } from "automate.ax"
import { z } from "zod"

export default automation("Create a recipe", () => {
  const recipe = generate({
    prompt: "Create a weeknight pasta recipe",
    schema: z.object({
      ingredients: z.string().array(),
      name: z.string(),
      steps: z.string().array(),
    }),
  })

  // recipe.output is Signal<{
  //   ingredients: string[]
  //   name: string
  //   steps: string[]
  // }>
})
```

## Inputs

| Input                                  | Type                                                 | Required                      | Description                                                                     |
| -------------------------------------- | ---------------------------------------------------- | ----------------------------- | ------------------------------------------------------------------------------- |
| `model`                                | `GenerateModelId`                                    | No                            | Gateway or provider-native model ID. Suggestions and defaults follow `account`. |
| `prompt`                               | `string`                                             | One of `prompt` or `messages` | Text prompt.                                                                    |
| `messages`                             | `{ role: "assistant" \| "user"; content: string }[]` | One of `prompt` or `messages` | Conversation messages.                                                          |
| `account`                              | Provider account reference                           | No                            | Customer-managed provider credentials. Omit for the platform gateway.           |
| `schema`                               | Standard Schema                                      | No                            | Constrains structured output and determines its TypeScript type.                |
| `schemaName`                           | `string`                                             | No                            | Provider-facing structured-output name.                                         |
| `schemaDescription`                    | `string`                                             | No                            | Additional structured-output guidance.                                          |
| `instructions` / `system`              | `string`                                             | No                            | Model instructions.                                                             |
| `maxOutputTokens`                      | `number`                                             | No                            | Maximum generated tokens.                                                       |
| `temperature` / `topP` / `topK`        | `number`                                             | No                            | Sampling settings.                                                              |
| `frequencyPenalty` / `presencePenalty` | `number`                                             | No                            | Repetition penalties.                                                           |
| `stopSequences`                        | `string[]`                                           | No                            | Sequences that stop generation.                                                 |
| `seed`                                 | `number`                                             | No                            | Provider-supported deterministic seed.                                          |
| `maxRetries`                           | `number`                                             | No                            | Maximum provider retries.                                                       |
| `timeout`                              | `number`                                             | No                            | Request timeout in milliseconds.                                                |
| `providerOptions`                      | `Record<string, Record<string, JSONValue>>`          | No                            | Provider-specific options.                                                      |

Generation fields accept compatible signals. The schema and account selection are static authoring inputs. Model suggestions use the selected account's provider enum while retaining a string fallback for newly released IDs.

## Output

Without a schema, `output` is `Signal<string>`. With a schema, `output` is a signal of that Standard Schema's inferred output type. The result also exposes generated `text`, token `usage`, `finishReason`, `rawFinishReason`, `reasoningText`, `warnings`, provider metadata, and response metadata.

## Provider accounts

Customer-managed API-key accounts are available for Anthropic, Cerebras, Cohere, DeepInfra, DeepSeek, Fireworks AI, Google Generative AI, Groq, Hugging Face, Mistral AI, OpenAI, OpenRouter, Perplexity, Together AI, Vercel AI Gateway, and xAI. Connect the credentials with `automate accounts`, then import the provider helper and pass a named account reference. API keys do not appear in automation code or signals.

```ts automations/provider-models.automation.ts theme={null}
import { automation, generate } from "automate.ax"
import { anthropicAccount } from "automate.ax/anthropic"
import { openaiAccount } from "automate.ax/openai"
import { openRouterAccount } from "automate.ax/openrouter"

export default automation("Compare providers", () => {
  generate({
    account: anthropicAccount("writing"),
    prompt: "Write a launch announcement",
  })

  generate({
    account: openaiAccount("classification"),
    model: "gpt-4.1-mini",
    prompt: "Classify this support request",
  })

  generate({
    account: openRouterAccount("routing"),
    prompt: "Choose an appropriate model and summarize this document",
  })
})
```

Omitting `model` uses the selected account's default:

| Account                       | Default model                                       |
| ----------------------------- | --------------------------------------------------- |
| Platform or Vercel AI Gateway | `openai/gpt-4.1-nano`                               |
| Anthropic                     | `claude-haiku-4-5`                                  |
| Cerebras                      | `llama3.1-8b`                                       |
| Cohere                        | `command-a-03-2025`                                 |
| DeepInfra                     | `meta-llama/Llama-3.3-70B-Instruct-Turbo`           |
| DeepSeek                      | `deepseek-chat`                                     |
| Fireworks AI                  | `accounts/fireworks/models/llama-v3p3-70b-instruct` |
| Google Generative AI          | `gemini-2.5-flash`                                  |
| Groq                          | `llama-3.1-8b-instant`                              |
| Hugging Face                  | `meta-llama/Llama-3.1-8B-Instruct`                  |
| Mistral AI                    | `mistral-small-latest`                              |
| OpenAI                        | `gpt-4.1-nano`                                      |
| OpenRouter                    | `openrouter/auto`                                   |
| Perplexity                    | `sonar`                                             |
| Together AI                   | `meta-llama/Llama-3.3-70B-Instruct-Turbo`           |
| xAI                           | `grok-latest`                                       |
