
# Generate Text with Image Prompt

Some language models that support vision capabilities accept images as part of the prompt. Here are some of the different [formats](/docs/reference/ai-sdk-core/generate-text#content-image) you can use to include images as input.

## URL

```ts file='index.ts'
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';

const result = await generateText({
  model: openai('gpt-4-turbo'),
  maxTokens: 512,
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'what are the red things in this image?',
        },
        {
          type: 'image',
          image: new URL(
            'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3e/2024_Solar_Eclipse_Prominences.jpg/720px-2024_Solar_Eclipse_Prominences.jpg',
          ),
        },
      ],
    },
  ],
});

console.log(result);
```

## File Buffer

```ts file='index.ts'
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import fs from 'fs';

const result = await generateText({
  model: openai('gpt-4-turbo'),
  maxTokens: 512,
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'what are the red things in this image?',
        },
        {
          type: 'image',
          image: fs.readFileSync('./node/attachments/eclipse.jpg'),
        },
      ],
    },
  ],
});

console.log(result);
```


## Navigation

- [Generate Text](/v4/cookbook/node/generate-text)
- [Retrieval Augmented Generation](/v4/cookbook/node/retrieval-augmented-generation)
- [Generate Text with Chat Prompt](/v4/cookbook/node/generate-text-with-chat-prompt)
- [Generate Text with Image Prompt](/v4/cookbook/node/generate-text-with-image-prompt)
- [Stream Text](/v4/cookbook/node/stream-text)
- [Stream Text with Chat Prompt](/v4/cookbook/node/stream-text-with-chat-prompt)
- [Stream Text with Image Prompt](/v4/cookbook/node/stream-text-with-image-prompt)
- [Stream Text with File Prompt](/v4/cookbook/node/stream-text-with-file-prompt)
- [Generate Object with a Reasoning Model](/v4/cookbook/node/generate-object-reasoning)
- [Generate Object](/v4/cookbook/node/generate-object)
- [Stream Object](/v4/cookbook/node/stream-object)
- [Stream Object with Image Prompt](/v4/cookbook/node/stream-object-with-image-prompt)
- [Record Token Usage After Streaming Object](/v4/cookbook/node/stream-object-record-token-usage)
- [Record Final Object after Streaming Object](/v4/cookbook/node/stream-object-record-final-object)
- [Call Tools](/v4/cookbook/node/call-tools)
- [Call Tools in Parallel](/v4/cookbook/node/call-tools-in-parallel)
- [Call Tools with Image Prompt](/v4/cookbook/node/call-tools-with-image-prompt)
- [Call Tools in Multiple Steps](/v4/cookbook/node/call-tools-multiple-steps)
- [Model Context Protocol (MCP) Tools](/v4/cookbook/node/mcp-tools)
- [Web Search Agent](/v4/cookbook/node/web-search-agent)
- [Embed Text](/v4/cookbook/node/embed-text)
- [Embed Text in Batch](/v4/cookbook/node/embed-text-batch)
- [Intercepting Fetch Requests](/v4/cookbook/node/intercept-fetch-requests)
- [Local Caching Middleware](/v4/cookbook/node/local-caching-middleware)


[Full Sitemap](/sitemap.md)
