Create Transformer
POSThttps://api.confident-ai.com/v2/transformers
Creates a transformer in your Confident AI project and returns its id. Test the code against a sample before attaching the transformer to anything.
curl -X POST "https://api.confident-ai.com/v2/transformers" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "Extract nested answer",
"description": "Pulls the answer out of a nested envelope.",
"codeDefinition": {
"code": "def transform(input_data):\n return input_data[\"data\"][\"answer\"]",
"language": "PYTHON"
}
}'{
"success": true,
"data": {
"id": "<TRANSFORMER-ID>"
},
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Request body
namestringRequiredThe name of the transformer, unique within the project.
descriptionstring | nullWhat the transformer extracts. Send null to leave it unset.
codeDefinitionobjectRequiredThe code a transformer runs, with the language it is written in.
Show 2 propertiesHide 2 properties
codestringRequiredThe source of the transformer. It defines a
transformfunction that takes the value being transformed and returns the value to use in its place.languageenumRequiredThe language a transformer's code is written in.
Show 1 enum valueHide 1 enum value
PYTHON
Response
Create Transformer succeeded.
successbooleanIndicates if the request was successful.
dataobjectA reference to a transformer by its id.
Show 1 propertyHide 1 property
idstringThe id of the transformer, generated by Confident AI.
deprecatedbooleanIndicates if this endpoint is deprecated.