PerplexityProvider
Namespace: Vercel.AI.Perplexity
public sealed class PerplexityProvider : OpenAICompatibleProvider, IDecisionProviderPerplexity provider. Language generation uses the Agent API at {base}/v1/agent.
Embeddings use {base}/v1/embeddings. Preset ids are
fast, low, medium, high, and xhigh; any other id is sent as a model id.
Legacy Sonar model ids are not aliased and Sonar provider options are not translated.
Sonar PDF input, video input, and image or video results have no Agent API equivalent.
Inheritance: object → ProviderBase → OpenAICompatibleProvider
Implements: IDecisionProvider
Constructors
Section titled “Constructors”PerplexityProvider(HttpClient, OpenAICompatibleOptions?)
Section titled “PerplexityProvider(HttpClient, OpenAICompatibleOptions?)”public PerplexityProvider(HttpClient httpClient, OpenAICompatibleOptions? options = null)Creates a provider.
Parameters
| Name | Type | Description |
|---|---|---|
httpClient |
HttpClient | |
options |
OpenAICompatibleOptions |
Fields
Section titled “Fields”AgentPath
Section titled “AgentPath”public const string AgentPath = "v1/agent"Relative Agent API path.
Value: string
ApiKeyVariable
Section titled “ApiKeyVariable”public const string ApiKeyVariable = "PERPLEXITY_API_KEY"Environment variable for the API key.
Value: string
DefaultBaseUrl
Section titled “DefaultBaseUrl”public const string DefaultBaseUrl = "https://api.perplexity.ai"Default API origin. Language calls append /v1/agent.
Value: string
DefaultIntegration
Section titled “DefaultIntegration”public const string DefaultIntegration = "vercel-ai-sdk"Default IntegrationHeader value.
Value: string
IntegrationHeader
Section titled “IntegrationHeader”public const string IntegrationHeader = "X-Pplx-Integration"Header Perplexity uses to attribute SDK requests.
Value: string
ProviderId
Section titled “ProviderId”public const string ProviderId = "perplexity"Provider id.
Value: string
Methods
Section titled “Methods”AgentUri()
Section titled “AgentUri()”public Uri AgentUri()Agent API URL. A custom base URL is prefixed to v1/agent.
Returns: Uri
Create(OpenAICompatibleOptions?, HttpMessageHandler?)
Section titled “Create(OpenAICompatibleOptions?, HttpMessageHandler?)”public static PerplexityProvider Create(OpenAICompatibleOptions? options = null, HttpMessageHandler? handler = null)Creates a provider. Pass a handler from tests.
Parameters
| Name | Type | Description |
|---|---|---|
options |
OpenAICompatibleOptions | |
handler |
HttpMessageHandler |
Returns: PerplexityProvider
DecisionModel(string)
Section titled “DecisionModel(string)”public PerplexityDecisionModel DecisionModel(string modelId)Decision model. Uses the Decisions API at {base}/v1/decisions. The provider id is perplexity.decision.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: PerplexityDecisionModel
EmbeddingModel(string)
Section titled “EmbeddingModel(string)”public override IEmbeddingModel EmbeddingModel(string modelId)Returns an embedding model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: IEmbeddingModel
LanguageModel(string)
Section titled “LanguageModel(string)”public override ILanguageModel LanguageModel(string modelId)Returns a language model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string |
Returns: ILanguageModel
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product