@quercle/ai-sdk
v0.1.3
Published
Quercle web tools for Vercel AI SDK
Maintainers
Readme
@quercle/ai-sdk
Quercle web tools for the Vercel AI SDK.
Provides quercleSearch and quercleFetch tools that integrate seamlessly with AI applications built on the Vercel AI SDK.
Installation
bun add @quercle/ai-sdknpm install @quercle/ai-sdkSetup
Set your Quercle API key as an environment variable:
export QUERCLE_API_KEY=qk_...Get your API key at quercle.dev.
Usage
With generateText
import { quercleSearch, quercleFetch } from "@quercle/ai-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const result = await generateText({
model: openai("gpt-4o"),
tools: { quercleSearch, quercleFetch },
prompt: "Search for the latest news about AI and summarize",
});With streamText
import { quercleSearch, quercleFetch } from "@quercle/ai-sdk";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
const stream = streamText({
model: openai("gpt-4o"),
tools: { quercleSearch, quercleFetch },
prompt: "Find information about TypeScript 5",
});
for await (const chunk of stream.textStream) {
console.log(chunk);
}With Custom API Key
import { createQuercleTools } from "@quercle/ai-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
const { quercleSearch, quercleFetch } = createQuercleTools({
apiKey: "qk_...",
});
const result = await generateText({
model: openai("gpt-4o"),
tools: { quercleSearch, quercleFetch },
prompt: "Search for TypeScript best practices",
});Tools
quercleSearch
Search the web and get AI-synthesized answers with citations.
Parameters:
query(string, required): The search queryallowedDomains(string[], optional): Only include results from these domainsblockedDomains(string[], optional): Exclude results from these domains
quercleFetch
Fetch a URL and analyze its content with AI.
Parameters:
url(string, required): The URL to fetchprompt(string, required): Instructions for how to analyze the content
License
MIT
