Right now, the primary way to access PromptLayer is through our Python wrapper library that can be installed with pip install promptlayer
.
The Python library is a wrapper over our REST API. If you use another language, like Javascript, just interact directly with the API.
Here is an example request below:
import requests
request_response = requests.post(
"<https://api.promptlayer.com/track-request>",
json={
"function_name": "openai.Completion.create",
"args": [],
"kwargs": {"engine": "text-ada-001", "prompt": "My name is"},
"tags": ["hello", "world"],
"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"}]},
"request_start_time": 1673987077.463504,
"request_end_time": 1673987077.463504,
"api_key": "pl_<YOUR API KEY>",
},
)
Remember, when using Javascript, timestamps are 1000x bigger than those in Python (what we expect). You will need to divide whatever the JS timestamp by 1000.
👋 Contact us at [email protected] if you run into any problems