{"id":17645571,"url":"https://github.com/sgaunet/perplexity-go","last_synced_at":"2026-03-07T05:33:10.526Z","repository":{"id":246740672,"uuid":"821328595","full_name":"sgaunet/perplexity-go","owner":"sgaunet","description":"A comprehensive Go client library for the Perplexity AI API with support for chat completions, async jobs, streaming, multimodal messages, structured outputs, and web search integration","archived":false,"fork":false,"pushed_at":"2026-03-01T19:54:05.000Z","size":344,"stargazers_count":27,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2026-03-01T21:57:07.393Z","etag":null,"topics":["ai","api-client","async","go","golang","library","multimodal","perplexity","perplexity-ai","streaming","structured-output","web-search"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgaunet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["sgaunet"]}},"created_at":"2024-06-28T09:45:39.000Z","updated_at":"2026-03-01T19:54:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d121848-2d3d-4538-9283-a3e8d16a03b2","html_url":"https://github.com/sgaunet/perplexity-go","commit_stats":null,"previous_names":["sgaunet/perplexity-go"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/sgaunet/perplexity-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fperplexity-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fperplexity-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fperplexity-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fperplexity-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgaunet","download_url":"https://codeload.github.com/sgaunet/perplexity-go/tar.gz/refs/heads/v2","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgaunet%2Fperplexity-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30208731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T05:23:27.321Z","status":"ssl_error","status_checked_at":"2026-03-07T05:00:17.256Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api-client","async","go","golang","library","multimodal","perplexity","perplexity-ai","streaming","structured-output","web-search"],"created_at":"2024-10-23T10:57:28.833Z","updated_at":"2026-03-07T05:33:10.492Z","avatar_url":"https://github.com/sgaunet.png","language":"Go","funding_links":["https://github.com/sponsors/sgaunet"],"categories":[],"sub_categories":[],"readme":"# Perplexity API Go Client\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/sgaunet/perplexity-go)](https://goreportcard.com/report/github.com/sgaunet/perplexity-go)\n![coverage](https://raw.githubusercontent.com/wiki/sgaunet/perplexity-go/coverage-badge.svg)\n[![GoDoc](https://godoc.org/github.com/sgaunet/perplexity-go/v2?status.svg)](https://godoc.org/github.com/sgaunet/perplexity-go/v2)\n\nA lightweight Go library for interacting with the [Perplexity AI API](https://docs.perplexity.ai/reference/post_chat_completions), focusing on the chat completion endpoint.\n\nFeatures\n\n    Simple and easy-to-use interface for making chat completion requests\n    Supports all Perplexity models, including online LLMs\n    Handles authentication and API key management\n    Provides convenient methods for common operations\n\nIf you need a **CLI tool** to interact with the API, check out the [pplx](https://github.com/sgaunet/pplx) project.\n\nDue to AI models that change regulary, only the default model will be handled for version \u003e=2.5.0. Using the `WithModel`, you're able to specify the model you want to use. The default model will always be maintained up to date.\nNow the library should be stable.\n\n**If you have access to the beta version of the API** I'm interesred to get some informations to hanle image generation. Please contact me.\n\n## Installation\n\nTo install the library, use go get:\n\n```sh\ngo get github.com/sgaunet/perplexity-go/v2\n```\n\n## Usage\n\nHere's a quick example of how to use the library:\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"os\"\n\n  \"github.com/sgaunet/perplexity-go/v2\"\n)\n\nfunc main() {\nclient := perplexity.NewClient(os.Getenv(\"PPLX_API_KEY\"))\n  msg := []perplexity.Message{\n    {\n      Role:    \"user\",\n      Content: \"Wat's the capital of France?\",\n    },\n  }\n  req := perplexity.NewCompletionRequest(perplexity.WithMessages(msg), perplexity.WithReturnImages(true))\n  err := req.Validate()\n  if err != nil {\n    fmt.Printf(\"Error: %v\\n\", err)\n    os.Exit(1)\n  }\n\n  res, err := client.SendCompletionRequest(req)\n  if err != nil {\n    fmt.Printf(\"Error: %v\\n\", err)\n    os.Exit(1)\n  }\n\n  fmt.Println(res.GetLastContent())\n}\n```\n\n## Documentation\n\nFor detailed documentation and more examples, please refer to the GoDoc page.\n\n## Max Tokens\n\n* **General Use Cases**: For most general-purpose applications, setting max_tokens to 4000 is a good starting point. This is because many Perplexity models, like the default sonar model, can generate responses up to this limit (It's the default value in this library).\n\n* **Long-Form Content**: If you are working with long-form content or need more extensive responses, you might consider models like sonar-pro, which can handle larger outputs. However, the maximum output tokens for such models might still be capped at 8,000 tokens.\n\n* **Model-Specific Limits**: Ensure that your chosen model supports the max_tokens value you set. For example, some models might have a maximum context window or output limit that you should not exceed.\n\n* **Performance Considerations**: Higher max_tokens values can increase response time and computational resources. Therefore, balance between the need for detailed responses and performance efficiency.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgaunet%2Fperplexity-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgaunet%2Fperplexity-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgaunet%2Fperplexity-go/lists"}