Quercle web tools for Vercel AI SDK
npm install @quercle/ai-sdkQuercle web tools for the Vercel AI SDK.
Provides quercleSearch and quercleFetch tools that integrate seamlessly with AI applications built on the Vercel AI SDK.
``bash`
bun add @quercle/ai-sdk
`bash`
npm install @quercle/ai-sdk
Set your Quercle API key as an environment variable:
`bash`
export QUERCLE_API_KEY=qk_...
Get your API key at quercle.dev.
`typescript
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",
});
`
`typescript
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);
}
`
`typescript
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",
});
`
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
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
-
MIT