{"id":23967333,"url":"https://github.com/magnivorg/prompt-layer-library","last_synced_at":"2025-09-12T23:31:04.602Z","repository":{"id":77365942,"uuid":"581656211","full_name":"MagnivOrg/prompt-layer-library","owner":"MagnivOrg","description":"🍰 PromptLayer - Maintain a log of your prompts and OpenAI API requests. Track, debug, and replay old completions.","archived":false,"fork":false,"pushed_at":"2024-12-31T18:16:07.000Z","size":556,"stargazers_count":534,"open_issues_count":22,"forks_count":48,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-31T19:21:21.496Z","etag":null,"topics":["gpt","machine-learning","openai","prompt","prompt-engineering","python"],"latest_commit_sha":null,"homepage":"https://www.promptlayer.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MagnivOrg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-23T21:18:26.000Z","updated_at":"2024-12-30T14:31:13.000Z","dependencies_parsed_at":"2023-09-22T02:32:11.257Z","dependency_job_id":"3f7f2320-2400-427c-855e-b21666223b88","html_url":"https://github.com/MagnivOrg/prompt-layer-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnivOrg%2Fprompt-layer-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnivOrg%2Fprompt-layer-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnivOrg%2Fprompt-layer-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnivOrg%2Fprompt-layer-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MagnivOrg","download_url":"https://codeload.github.com/MagnivOrg/prompt-layer-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232797483,"owners_count":18577981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["gpt","machine-learning","openai","prompt","prompt-engineering","python"],"created_at":"2025-01-06T23:00:33.846Z","updated_at":"2025-09-12T23:31:04.586Z","avatar_url":"https://github.com/MagnivOrg.png","language":"Python","funding_links":[],"categories":["Prompts"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# 🍰 PromptLayer\n\n**The first platform built for \u003cspan style=\"background-color: rgb(219, 234, 254);\"\u003eprompt engineers\u003c/span\u003e**\n\n\u003ca href=\"https://www.python.org/\"\u003e\u003cimg alt=\"Python\" src=\"https://img.shields.io/badge/-Python 3.8+-blue?style=for-the-badge\u0026logo=python\u0026logoColor=white\"\u003e\u003c/a\u003e\n\u003ca href=\"https://docs.promptlayer.com\"\u003e\u003cimg alt=\"Docs\" src=\"https://custom-icon-badges.herokuapp.com/badge/docs-PL-green.svg?logo=cake\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.loom.com/share/196c42e43acd4a369d75e9a7374a0850\"\u003e\u003cimg alt=\"Demo with Loom\" src=\"https://img.shields.io/badge/Demo-loom-552586.svg?logo=loom\u0026style=for-the-badge\u0026labelColor=gray\"\u003e\u003c/a\u003e\n\n---\n\n\u003cdiv align=\"left\"\u003e\n\n[PromptLayer](https://promptlayer.com/) is the first platform that allows you to track, manage, and share your GPT prompt engineering. PromptLayer acts a middleware between your code and OpenAI’s python library.\n\nPromptLayer records all your OpenAI API requests, allowing you to search and explore request history in the PromptLayer dashboard.\n\nThis repo contains the Python wrapper library for PromptLayer.\n\n## Quickstart ⚡\n\n### Install PromptLayer\n\n```bash\npip install promptlayer\n```\n\n### Installing PromptLayer Locally\n\nUse `pip install .` to install locally.\n\n### Using PromptLayer\n\nTo get started, create an account by clicking “*Log in*” on [PromptLayer](https://promptlayer.com/). Once logged in, click the button to create an API key and save this in a secure location ([Guide to Using Env Vars](https://towardsdatascience.com/the-quick-guide-to-using-environment-variables-in-python-d4ec9291619e)).\n\nOnce you have that all set up, [install PromptLayer using](https://pypi.org/project/promptlayer/) `pip`.\n\nIn the Python file where you use OpenAI APIs, add the following. This allows us to keep track of your requests without needing any other code changes.\n\n```python\nfrom promptlayer import PromptLayer\n\npromptlayer = PromptLayer(api_key=\"\u003cYOUR PromptLayer API KEY pl_xxxxxx\u003e\")\nopenai = promptlayer.openai\n```\n\n**You can then use `openai` as you would if you had imported it directly.**\n\n\u003caside\u003e\n💡 Your OpenAI API Key is **never** sent to our servers. All OpenAI requests are made locally from your machine, PromptLayer just logs the request.\n\u003c/aside\u003e\n\n### Adding PromptLayer tags: `pl_tags`\n\nPromptLayer allows you to add tags through the `pl_tags` argument. This allows you to track and group requests in the dashboard.\n\n*Tags are not required but we recommend them!*\n\n```python\nopenai.Completion.create(\n  engine=\"text-ada-001\",\n  prompt=\"My name is\",\n  pl_tags=[\"name-guessing\", \"pipeline-2\"]\n)\n```\n\nAfter making your first few requests, you should be able to see them in the PromptLayer dashboard!\n\n## Using the REST API\n\nThis Python library is a wrapper over PromptLayer's REST API. If you use another language, like Javascript, just interact directly with the API.\n\nHere is an example request below:\n\n```python\nimport requests\nrequest_response = requests.post(\n  \"https://api.promptlayer.com/track-request\",\n  json={\n    \"function_name\": \"openai.Completion.create\",\n    \"args\": [],\n    \"kwargs\": {\"engine\": \"text-ada-001\", \"prompt\": \"My name is\"},\n    \"tags\": [\"hello\", \"world\"],\n    \"request_response\": {\"id\": \"cmpl-6TEeJCRVlqQSQqhD8CYKd1HdCcFxM\", \"object\": \"text_completion\", \"created\": 1672425843, \"model\": \"text-ada-001\", \"choices\": [{\"text\": \" advocacy\\\"\\n\\nMy name is advocacy.\", \"index\": 0, \"logprobs\": None, \"finish_reason\": \"stop\"}]},\n    \"request_start_time\": 1673987077.463504,\n    \"request_end_time\": 1673987077.463504,\n    \"api_key\": \"pl_\u003cYOUR API KEY\u003e\",\n  },\n)\n```\n\n## Contributing\n\nWe welcome contributions to our open source project, including new features, infrastructure improvements, and better documentation. For more information or any questions, contact us at [hello@promptlayer.com](mailto:hello@promptlayer.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnivorg%2Fprompt-layer-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnivorg%2Fprompt-layer-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnivorg%2Fprompt-layer-library/lists"}