Log Azure OpenAI requests

Monitor your Azure OpenAI API calls by logging requests and responses asynchronously. Track metrics like cost, duration, and performance for Azure-hosted OpenAI models.
import requests

url = "https://api.keywordsai.co/api/request-logs/create/"
payload = {
    "model": "gpt-4o",
    "prompt_messages": [
        {
            "role": "user",
            "content": "Analyze this business proposal"
        }
    ],
    "completion_message": {
        "role": "assistant",
        "content": "Based on the proposal, here are the key strengths and areas for improvement..."
    },
    "cost": 0.0012,
    "generation_time": 3.5,
    "customer_params": {
        "customer_identifier": "user_505"
    }
}
headers = {
    "Authorization": "Bearer YOUR_KEYWORDS_AI_API_KEY",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json=payload)

Get Started with Logging

Learn how to set up comprehensive logging for all your LLM requests