Home / Market / go-perplexity

go-perplexity

Unofficial Go client for the Perplexity REST API at https://api.perplexity.ai. Package perplexity (github.com/psyb0t/go-perplexity), generated with oapi-codegen from Perplexity's OpenAPI document, has one typed method per endpoint on the client from perplexity.NewClientWithResponses, covering Sonar chat completions (sync and async), web search, embeddings and contextualized embeddings, agents and their files, skills, decisions, models and usage analytics, with JSON bodies decoded into Go structs

skill★ 00 dlclawhubMIT-0Install in CosmosUpstream Source

Documentation & Preview

go-perplexity: setup and reference

Requirements

Install

go get github.com/psyb0t/go-perplexity

The package name is perplexity.

Client

Methods

Names come from the spec's operation IDs. Each has a ...WithResponse form, and endpoints with a body also have ...WithBodyWithResponse for a raw io.Reader body.

| Endpoint | Method | |---|---| | POST /v1/sonar | ChatCompletionsChatCompletionsPost | | POST / GET /v1/async/sonar | CreateAsyncChatCompletionsAsyncChatCompletionsPost, ListAsyncChatCompletionsAsyncChatCompletionsGet | | GET /v1/async/sonar/{api_request} | GetAsyncChatCompletionResponseAsyncChatCompletionsApiRequestGet | | POST /search | SearchSearchPost | | POST /v1/embeddings | EmbeddingsV1EmbeddingsPost | | POST /v1/contextualizedembeddings | ContextualizedEmbeddingsV1ContextualizedembeddingsPost | | GET /v1/models | ListModels (response type ListModelsResponse2) | | POST /v1/agent, GET /v1/agent/{id} | CreateAgent, RetrieveAgent | | POST /v1/agent/{id}/cancel | CancelAgentResponse | | GET /v1/agent/{id}/files, .../files/{file_id}/content | ListAgentFiles, DownloadAgentFile | | GET /v1/skills, /v1/skills/{skill_id} | ListSkills, GetSkill | | POST /v1/skills, PUT /v1/skills/{skill_id} | CreateSkillWithBody, UpdateSkillWithBody (raw body only) | | DELETE /v1/skills/{skill_id} | DeleteSkill | | POST /v1/decisions | DecisionsV1DecisionsPost | | GET /v1/analytics/computer/usage, /v2/... | GetComputerUsageAnalytics, GetComputerUsageAnalyticsV2 |

The full list is in client.gen.go under ClientWithResponsesInterface.

Responses

Each ...WithResponse method returns a struct with Body []byte, HTTPResponse *http.Response, StatusCode() and a JSON<status> field per status the spec documents with a JSON body, for example JSON200 and JSON422 (*HTTPValidationError) on the Sonar endpoint. Fields for other statuses stay nil; Body always holds the raw response.

Union types

Schemas with oneOf become structs with From<Variant>, As<Variant> and Merge<Variant> methods:

Errors