Logs
Create log
POST
Create log
This guide shows you how to log any type of LLM request to Keywords AI using the universal input/output design that supports all span types.
Input/Output
Keywords AI uses universalinput and output fields across all span types.
- Chat completions: Messages arrays
- Embeddings: Text strings or arrays
- Transcriptions: Audio metadata → text
- Speech: Text → audio
- Workflows/Tasks: Any custom data structure
- Agent operations: Complex nested objects
- You provide
inputandoutputfields in any structure (string, object, array, etc.) - Set
log_typeto indicate span type ("chat","embedding","workflow", etc.) - Keywords AI automatically extracts type-specific fields for backward compatibility
- Your data is stored efficiently and retrieved with both universal and type-specific fields
log_type specifications, see log types.
Request body
Core fields
string | object | array
Universal input field for the span. Structure depends on
log_type:- Chat: JSON string of messages array or messages array directly
- Embedding: Text string or array of strings
- Workflow/Task: Any JSON-serializable structure
- Transcription: Audio file reference or metadata object
- Speech: Text string or TTS configuration object
Example for Chat
Example for Chat
Example for Embedding
Example for Embedding
Example for Workflow
Example for Workflow
string | object | array
Universal output field for the span. Structure depends on
log_type:- Chat: JSON string of completion message or message object directly
- Embedding: Array of vector embeddings
- Workflow/Task: Any JSON-serializable result structure
- Transcription: Transcribed text string
- Speech: Audio file reference or base64 audio data
Example for Chat
Example for Chat
Example for Embedding
Example for Embedding
string
default:"chat"
Type of span being logged. Determines how
input and output are parsed.Supported types:"chat"- Chat completion requests (default)"completion"- Legacy completion requests"response"- OpenAI Response API"embedding"- Embedding generation"transcription"- Speech-to-text"speech"- Text-to-speech"workflow"or"agent"- Workflow/agent execution"task"or"tool"- Task/tool execution"function"- Function call"generation"- Generation span"handoff"- Agent handoff"guardrail"- Safety check"custom"- Custom span type
Default Behavior
Default Behavior
If not specified, defaults to
"chat". For chat types, the system automatically extracts prompt_messages and completion_message from input and output for backward compatibility.For complete specifications of each type, see log types.string
The model used for the inference. Optional but recommended for chat/completion/embedding types.
Example
Example
Telemetry
Performance metrics and cost tracking for monitoring LLM efficiency.object
Token usage information for the request.
float
Cost of the inference in US dollars. If not provided, will be calculated automatically based on model pricing.
float
Total request latency in seconds (replaces deprecated
generation_time).Previously called
generation_time. For backward compatibility, both field names are supported.float
Time to first token (TTFT) in seconds. Useful for streaming responses and voice AI applications.
Previously called
ttft. Both field names are supported.float
Generation speed in tokens per second.
Metadata
Custom tracking and identification parameters for advanced analytics and filtering.object
You can add any key-value pair to this metadata field for your reference. Useful for custom analytics and filtering.
Example
Example
string
An identifier for the customer that invoked this request. Helps with visualizing user activities. See customer identifier details.
Example
Example
object
string
A unique identifier for the conversation thread. Useful for multi-turn conversations.
string
Same functionality as
metadata, but indexed for faster querying.Example
Example
string
Group identifier. Use to group related logs together.
Workflow & tracing
Parameters for distributed tracing and workflow tracking.string
Unique identifier for the trace. Used to link multiple spans together in distributed tracing.
string
Name of the workflow this span belongs to.
string
Name of this specific span/task within the workflow.
string
ID of the parent span. Used to build the trace hierarchy.
Advanced parameters
Tool calls and function calling
array
A list of tools the model may call. Currently, only functions are supported as a tool.
string | object
Controls which (if any) tool is called by the model. Can be
"none", "auto", or an object specifying a specific tool.Example
Example
Response configuration
object
Setting to
{ "type": "json_schema", "json_schema": {...} } enables Structured Outputs.Possible types
Possible types
- Text:
{ "type": "text" }- Default response format - JSON Schema:
{ "type": "json_schema", "json_schema": {...} }- Structured outputs - JSON Object:
{ "type": "json_object" }- Legacy JSON format
Model configuration
number
default:1
Controls randomness in the output (0-2). Higher values produce more random responses.
number
default:1
Nucleus sampling parameter. Alternative to temperature.
number
Penalizes tokens based on their frequency in the text so far.
number
Penalizes tokens based on whether they appear in the text so far.
integer
Maximum number of tokens to generate.
array[string]
Stop sequences where generation will stop.
Error handling and status
integer
default:200
The HTTP status code for the request. Default is 200 (success).
Supported status codes
Supported status codes
All valid HTTP status codes are supported:
200, 201, 400, 401, 403, 404, 429, 500, 502, 503, 504, etc.string
Error message if the request failed. Default is empty string.
string | object
Any warnings that occurred during the request.
string
Request status. Common values:
"success", "error".Additional configuration
boolean
default:false
Whether the response was streamed.
string
ID of the prompt template used. See Prompts documentation.
string
Name of the prompt template.
boolean
default:false
Whether the prompt is a custom prompt. Set to
true if using custom prompt_id.string
ISO 8601 timestamp when the request completed.
Example
Example
string
ISO 8601 timestamp when the request started.
object
The full request object. Useful for logging additional configuration parameters.
Tool calls and other nested objects will be automatically extracted from
full_request.object
The full response object from the model provider.
Pricing configuration
number
Custom price per 1M prompt tokens. Used for self-hosted or fine-tuned models.
Example
Example
number
Custom price per 1M completion tokens. Used for self-hosted or fine-tuned models.
Example
Example
API controls
object
Control the behavior of the Keywords AI logging API.
Properties
Properties
boolean
default:true
If
false, the server immediately returns initialization status without waiting for log completion.Example
Example
boolean
Whether the user liked the output.
true means positive feedback.Create log