## Examples

### 1. Basic Text Generation

```typescript
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'

async function generateRecipe() {
const { text } = await generateText({
  model: openai('gpt-4o'),
  prompt: 'Write a recipe for a vegetarian lasagna.',
})

console.log(text)
}

generateRecipe()
```

### 2. Interactive Chat Application

```typescript
import { streamText } from 'ai'
import { openai } from '@ai-sdk/openai'

function chatBot() {
const result = streamText({
  model: openai('gpt-4o'),
  prompt: 'You are a helpful assistant. User: How can I improve my productivity?',
  onChunk: ({ chunk }) => {
    if (chunk.type === 'text-delta') {
      process.stdout.write(chunk.text)
    }
  },
})

result.text.then(fullText => {
  console.log('\n\nFull response:', fullText)
})
}

chatBot()
```

### 3. Summarization with System Prompt

```typescript
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'

async function summarizeArticle(article: string) {
const { text } = await generateText({
  model: openai('gpt-4o'),
  system: 'You are a professional summarizer. Provide concise summaries.',
  prompt: `Summarize the following article in 3 sentences: ${article}`,
})

console.log('Summary:', text)
}

const article = `
Artificial Intelligence (AI) has made significant strides in recent years, 
transforming various industries and aspects of daily life. From healthcare 
to finance, AI-powered solutions are enhancing efficiency, accuracy, and 
decision-making processes. However, the rapid advancement of AI also raises 
ethical concerns and questions about its impact on employment and privacy.
`

summarizeArticle(article)
```

These examples demonstrate the versatility and ease of use of the AI SDK, showcasing text generation, interactive streaming, and summarization tasks using OpenAI models.

---