Creates one or more logs associated to a project. Logs are
LLM-call-level data that might depend on other variables.
If a context is specified and it is versioned, all logs will be versioned
and mutable. The context version will be incremented automatically when
logs are added, updated, or removed.
The context parameter can be:
- A string: Uses the string as the context name with default values (description=None, is_versioned=False)
- An object: Uses the object’s name, description, and is_versioned properties
An “explicit_types” dictionary can be passed as part of the entries.
If present, any matching key inside this dictionary will override the
inferred type of that particular entry. The explicit_types dictionary
can also specify if a field is mutable via a ‘mutable’ boolean flag
and if a field is unique via a ‘unique’ boolean flag:
{
"field_name": {
"type": "str",
"mutable": false, # Makes the field immutable
"unique": true # Makes the field unique
}
}
By default, all fields are immmutable unless specified otherwise.
Once a field is marked as mutable, only then can it be modified through
the update endpoint.
Response includes:
log_event_ids: List of created log event IDs
row_ids: Object with names (unique key column names) and ids (nested list of values)
auto_counting: Dictionary mapping auto-counting column names to their generated/provided values.
Empty dict {} when no auto-counting is configured.
This method returns the ids of the new stored logs along with any auto-counting values.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Name of the project the stored entries will be associated to.
Optional context path to update for the logs. Can use ’/’ for nested contexts (e.g. ‘training/batch1’). Can be a string (which will be interpreted with description=None and is_versioned=False) or a ContextCreateRequest object.
params
object | array
default:"{}"
Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Values must be JSON serializable. If a explicit_types dictionary is present, its values will override the inferred types of the entries. The explicit_types dictionary can also specify if a field is mutable via a ‘mutable’ boolean flag, or unique via a ‘unique’ boolean flag. For enum types, use the EnumType model with ‘values’ list and optional ‘restrict’ flag. Omit ‘values’ to create an open enum (auto-seeding). For contexts with nested unique IDs, parent ID values for the leftmost N-1 unique columns can be supplied as normal param keys. The rightmost column is always auto-incremented. For example, if unique columns are [‘user’, ‘session’, ‘step’], you can provide ‘user’ and ‘session’ values in params, and ‘step’ will be auto-generated.
entries
object | array
default:"{}"
Dictionary containing one or more key:value pairs that will be logged into the platform. Can be either a single dictionary or a list of dictionaries for batch processing. When using lists for both params and entries, their lengths must match. Values must be JSON serializable. If a explicit_types dictionary is present, its values will override the inferred types of the entries. The explicit_types dictionary can also specify if a field is mutable via a ‘mutable’ boolean flag, or unique via a ‘unique’ boolean flag. For enum types, use the EnumType model with ‘values’ list and optional ‘restrict’ flag. Omit ‘values’ to create an open enum (auto-seeding). For contexts with nested unique IDs, parent ID values for the leftmost N-1 unique columns can be supplied as normal entry keys. The rightmost column is always auto-incremented. For example, if unique columns are [‘user’, ‘session’, ‘step’], you can provide ‘user’ and ‘session’ values in entries, and ‘step’ will be auto-generated.
curl --request POST \
--url 'https://api.unify.ai/v0/logs' \
--header "Authorization: Bearer $UNIFY_KEY" \
--header 'Content-Type: application/json' \
--data '{
"project": "eval-project",
"context": "experiment1/trial1"
}'
{
"info": "Logs created successfully!",
"log_event_ids": [
101,
102,
103
],
"row_ids": {
"names": [
"row_id"
],
"ids": [
[
0
],
[
1
],
[
2
]
]
},
"auto_counting": {
"row_id": [
0,
1,
2
],
"exchange_id": [
0,
1,
2
]
}
}