import requests
url = "https://api.keywordsai.co/api/request-logs/create/"
headers = {
"Authorization": "Bearer YOUR_KEYWORDS_AI_API_KEY",
"Content-Type": "application/json"
}
payload = {
"model": "gpt-4",
"prompt_messages": [
{
"role": "user",
"content": "What's the weather like in Boston?"
},
{
"role": "assistant",
"content": None,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": '{"location": "Boston, MA"}'
}
}
]
}
],
"completion_message": {
"role": "assistant",
"content": "The current weather in Boston is 72°F and sunny."
},
"tool_choice": {
"type": "function",
"function": {
"name": "get_current_weather"
}
},
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
}
],
"customer_params": {
"customer_identifier": "customer_123"
},
"prompt_tokens": 25,
"completion_tokens": 12,
"cost": 0.00037,
"timestamp": "2024-04-15T08:30:37.721313Z"
}
response = requests.post(url, headers=headers, json=payload)