> For the complete documentation index, see [llms.txt](https://deusai.gitbook.io/agent-catalyst/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://deusai.gitbook.io/agent-catalyst/ai-generations-in-agent-catalyst.md).

# AI Generations in Agent Catalyst

Agent Catalyst integrates powerful AI models into workflows, enabling seamless text generation, structured data extraction, and reasoning tasks. This functionality empowers users to create dynamic, AI-driven processes tailored to their needs.

***

#### Text Generation

Text generation allows users to create various types of content, such as summaries, narratives, or creative texts, using large language models (LLMs).

**Example: Generating a Scientific Abstract**

```yaml
yaml <GenText  
  as="abstract"  
  model="openai:gpt-4"  
  message="Based on the following research paper, create a concise and detailed scientific abstract summarizing the findings: {research}" />  
```

**Attributes for `<GenText />`**

| **Attribute** | **Type** | **Description**                               | **Required** |
| ------------- | -------- | --------------------------------------------- | ------------ |
| `as`          | string   | Unique variable name to store the result.     | ✅            |
| `model`       | string   | AI provider and model name.                   | ✅            |
| `stream`      | boolean  | Enables response streaming (default: `true`). | ❌            |
| `tools`       | array    | List of tools the LLM can use.                | ❌            |
| `options`     | object   | LLM-specific options for fine-tuning.         | ❌            |

The generated text is stored in the specified variable (e.g., `abstract`) and can be reused in later steps.

***

#### Structured Data Generation

Structured data generation ensures that AI outputs conform to specific formats, making it ideal for extracting reliable, programmatic data.

**Example: Extracting Conference Speakers**

```yaml
yaml <GenObject  
  as="speakers"  
  model="openai:gpt-4"  
  output="array"  
  schema={{  
    $.z.object({  
      name: $.z.string().describe('Full name of the speaker'),  
      company: $.z.string().describe('Company name'),  
      twitter: $.z.string().describe('Twitter profile').optional(),  
    })  
  }}  
  message="Extract all conference speakers and their details from the given webpage: {url}" />  
```

**Attributes for `<GenObject />`**

| **Attribute**       | **Type** | **Description**                                    | **Required**                       |
| ------------------- | -------- | -------------------------------------------------- | ---------------------------------- |
| `as`                | string   | Unique variable name to store the result.          | ✅                                  |
| `model`             | string   | AI provider and model name.                        | ✅                                  |
| `output`            | string   | Type of output: object, array, enum, or no-schema. | ✅                                  |
| `schema`            | ZodType  | Schema defining the data structure.                | ✅ (if `output` is object or array) |
| `enum`              | array    | List of possible values (if `output` is enum).     | ✅ (if `output` is enum)            |
| `schemaDescription` | string   | Additional guidance for the AI model.              | ❌                                  |
| `tools`             | array    | List of tools the LLM can use.                     | ❌                                  |

**Schema Validation**: Ensures the output adheres to the specified structure, making it reliable for automated workflows.

***

#### Example Workflow: Generate Tweets for Conference Speakers

```yaml
yaml <Loop  
  as="messages"  
  until={$.index === speakers.filter(s => !!s.twitter).length}  
  provide={{ speaker: speakers.filter(s => !!s.twitter)[$.index] }}>  

  Write a tweet thanking the speaker for their presentation. Make it fun, humorous, and use plenty of emojis.  

  Speaker: {speaker.name}  
  Company: {speaker.company}  
  Twitter: {speaker.twitter}  

  <GenText as="tweet" model="openai:gpt-4" />  
</Loop>
```

***

#### AI Providers

Agent Catalyst supports multiple AI providers through integrations with SDKs like OpenAI, Anthropic, and Google. It also works with local open-source models using tools like Ollama.

**Provider Configuration Example**

```javascript
javascript import { defineConfig } from '@agentsystem/core';  
import { openai } from '@ai-sdk/openai';  
import { anthropic } from '@ai-sdk/anthropic';  

export default defineConfig({  
  providers: {  
    openai,  
    anthropic,  
  },  
});
```

**Custom Provider Setup**

For custom configurations, you can create provider instances:

```javascript
javascript import { createOpenAI } from '@ai-sdk/openai';  

export default defineConfig({  
  providers: {  
    openai: createOpenAI({  
      apiKey: process.env.OPENAI_API_KEY,  
      compatibility: 'strict',  
    }),  
    anotherProvider: createOpenAI({  
      apiKey: process.env.ANOTHER_API_KEY,  
      baseURL: 'https://api.example.com',  
    }),  
  },  
});
```

***

#### Specifying Models

When using `<GenText />` or `<GenObject />`, the model must be specified in the format `providerId:modelId`.

**Example**

```yaml
yaml <GenText  
  as="outline"  
  model="openai:gpt-4"  
  message="Write an outline for a futuristic space adventure novel." />  
```

***
