If you have already built your prompts outside of Keywords AI, you can still log & monitor them in Keywords AI without migrating them to the platform.

Steps

Step 1: Set up Logging

To use Keywords AI observability features, you need to set up logging first. You should send an API request to us each time you call the prompt.

import requests

url = "https://api.keywordsai.co/api/request-logs/create/"
payload = {
    "model": "claude-3-5-sonnet-20240620",
    "prompt_messages": [
        {
            "role": "user",
            "content": "Hi"
        },
    ],
    "completion_message": {
        "role": "assistant",
        "content": "Hi, how can I assist you today?"
    },
    "generation_time": 5.7
}
headers = {
    "Authorization": "Bearer YOUR_KEYWORDS_AI_API_KEY",
    "Content-Type": "application/json"
}

response = requests.request("POST", url, headers=headers, json=payload)

Step 2: Log the prompt

To log the prompt, you should pass 2 more parameters to in the API payload:

  • prompt_id: The ID of the prompt. You can set this to any string.
  • is_custom_prompt: Set this to true, this will tell Keywords AI that this is a custom prompt.

Step 3: Monitor the prompt

Once you have logged the prompt, you can monitor it in the Keywords AI Dashboard.