Documentation Index
Fetch the complete documentation index at: https://docs.keywordsai.co/llms.txt
Use this file to discover all available pages before exploring further.
In this guide, we will walk you through the process of creating a new prompt in Keywords AI and how to collaborate with your team.
Create a prompt in the API
You can also create a prompt in the API. Here are the 2 endpoints you need to use to create a prompt:
https://api.keywordsai.co/api/prompts/ - Create a new prompt.
https://api.keywordsai.co/api/prompts/<prompt_id>/versions/ - Create a new version of a prompt.
1. Create a new prompt
You can use the POST /prompts/ endpoint to create a new prompt. You need to provide the name, and description of the prompt.
import requests
url = "https://api.keywordsai.co/api/prompts/"
api_key = "YOUR_KEYWORDS_AI_API_KEY" # Replace with your actual Keywords AI API key
data = {
"name": "Your Prompt Name",
"description": "Your Prompt Description"
}
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
2. Find the prompt ID
Once you have created a prompt, you can find the prompt ID in the response, or you can go to the Prompts page and find the prompt ID in the prompt details.
3. Create a new version of the prompt
You can use the POST /api/prompts/<prompt_id>/versions/ endpoint to create a new version of a prompt. You need to provide the content of the prompt.
import requests
url = "https://api.keywordsai.co/api/prompts/<prompt_id>/versions/"
api_key = "YOUR_KEYWORDS_AI_API_KEY" # Replace with your actual Keywords AI API key
data = {
"description": "A description of the prompt version",
"messages": [
{"role": "system", "content": "You are a helpful {{role}}."},
{"role": "user", "content": "Hello, how are you?"}
],
"model": "gpt-3.5-turbo",
"stream": false,
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1.0,
"frequency_penalty": 0.0,
"presence_penalty": 0.0,
"variables": {},
}
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
You just finished creating your first prompt in the code!