@tpmjs/tools-fetch-text
Fetch a URL and return plain text content. Automatically strips HTML tags and returns clean text with metadata including content type, length, and status code. Useful for extracting text from web pages.
Test @tpmjs/tools-fetch-text (fetchTextTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-fetch-textpnpm add @tpmjs/tools-fetch-textyarn add @tpmjs/tools-fetch-textbun add @tpmjs/tools-fetch-textdeno add npm:@tpmjs/tools-fetch-textimport { fetchTextTool } from '@tpmjs/tools-fetch-text';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { fetchTextTool } from '@tpmjs/tools-fetch-text';
const result = await generateText({
model: openai('gpt-4o'),
tools: { fetchTextTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
urlstringThe URL to fetch (must be http or https)
Schema extracted: 1/1/2026, 8:17:56 AM
Fetch a URL and return plain text content with metadata.
npm install @tpmjs/tools-fetch-text
import { fetchTextTool } from '@tpmjs/tools-fetch-text'; // Use with AI SDK const result = await fetchTextTool.execute({ url: 'https://example.com', }); console.log(result.text); // Plain text content console.log(result.contentType); // 'text/html; charset=utf-8' console.log(result.contentLength); // 12345 console.log(result.metadata); // { fetchedAt, statusCode, redirected, finalUrl }
url (string, required): The URL to fetch (must be http or https)Returns a FetchTextResult object:
{ text: string; // Plain text content (HTML stripped if applicable) url: string; // Original URL contentLength: number; // Length of raw content in bytes contentType: string; // Content-Type header value metadata: { fetchedAt: string; // ISO timestamp of when content was fetched statusCode: number; // HTTP status code redirected: boolean; // Whether the request was redirected finalUrl: string; // Final URL after redirects }; }
MIT
Downloads/month
0
Quality Score