@tpmjs/tools-fetch-text
Fetch a URL and return plain text content with metadata
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);(url: string) => Promise<unknown>Available configuration options
urlstringThe URL to fetch
Schema extracted: 3/1/2026, 4:26:14 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
8
GitHub Stars
0
Quality Score