new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

perplexity/options

5 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Perplexity provider configuration options

The following optional settings are available when creating a Perplexity provider instance: baseURL (string, default 'https://api.perplexity.ai'), apiKey (string, defaults to PERPLEXITY_API_KEY environment variable), headers (Record<string,string>), and fetch (custom fetch implementation).

Perplexity provider language model options

The following provider-specific options are available for Perplexity language models: return_images (boolean, enables image responses for Tier-2 Perplexity users only) and search_recency_filter (string, filters search results by recency with possible values: 'hour', 'day', 'week', 'month', 'year', defaults to all time if not specified). Any other Perplexity API parameters can also be passed through providerOptions.perplexity.

Perplexity embedding provider options

The following optional provider options are available for Perplexity embedding models: dimensions (number, ranges from 128 up to the model's full size: 1024 for 0.6b models, 2560 for 4b models, for Matryoshka truncation of the output vector) and encodingFormat (string, 'base64_int8' or 'base64_binary', defaults to 'base64_int8').

Perplexity generateText example with provider options

Example code showing how to use provider options with Perplexity: ```ts import { perplexity, type PerplexityLanguageModelOptions, } from '@ai-sdk/perplexity'; import { generateText } from 'ai'; const result = await generateText({ model: perplexity('sonar-pro'), prompt: 'What are the latest developments in quantum computing?', providerOptions: { perplexity: { return_images: true, // Enable image responses (Tier-2 Perplexity users only) search_recency_filter: 'week', // Filter search results by recency } satisfies PerplexityLanguageModelOptions, }, }); console.log(result.providerMetadata); // Example output: // { // perplexity: { // usage: { citationTokens: 5286, numSearchQueries: 1 }, // images: [ // { imageUrl: "https://example.com/image1.jpg", originUrl: "https://elsewhere.com/page1", height: 1280, width: 720 }, // { imageUrl: "https://example.com/image2.jpg", originUrl: "https://elsewhere.com/page2", height: 1280, width: 720 } // ] // }, // } ``` This example demonstrates configuring provider options and accessing provider metadata.

Perplexity embedding with provider options example

Example code showing how to use provider options with Perplexity embeddings: ```ts const { embedding } = await embed({ model: perplexity.embedding('pplx-embed-v1-4b'), value: 'sunny day at the beach', providerOptions: { perplexity: { // Matryoshka truncation of the output vector (128 up to the model size). dimensions: 512, // Quantized encoding format. Defaults to 'base64_int8'. encodingFormat: 'base64_int8', }, }, }); ``` This example demonstrates configuring embedding-specific provider options.

Give your agent this brain