New feature / Improvement / Bug fix

Generative AI functions

· week 51 · 2025

Analyzing generative AI (GenAI) conversation data in your logs just got easier. Previously, extracting insights from AI conversation logs required complex queries to parse message structures, calculate token costs, and filter conversations by role or content.

We’ve added a comprehensive set of GenAI functions to APL that simplify working with conversation data from large language models and AI systems. These functions help you extract specific information like user prompts, assistant responses, and system prompts, calculate token costs and usage metrics, analyze conversation structure and flow, and detect truncation or tool calls in responses.

Function

Description

genai_concat_contents

Concatenates message contents from a conversation array

genai_conversation_turns

Counts the number of conversation turns

genai_cost

Calculates the total cost for input and output tokens

genai_estimate_tokens

Estimates the number of tokens in a text string

genai_extract_assistant_response

Extracts the assistant’s response from a conversation

genai_extract_function_results

Extracts function call results from messages

genai_extract_system_prompt

Extracts the system prompt from a conversation

genai_extract_tool_calls

Extracts tool calls from messages

genai_extract_user_prompt

Extracts the user prompt from a conversation

genai_get_content_by_index

Gets message content by index position

genai_get_content_by_role

Gets message content by role

genai_get_pricing

Gets pricing information for a specific model

genai_get_role

Gets the role of a message at a specific index

genai_has_tool_calls

Checks if messages contain tool calls

genai_input_cost

Calculates the cost for input tokens

genai_is_truncated

Checks if a response was truncated

genai_message_roles

Extracts all message roles from a conversation

genai_output_cost

Calculates the cost for output tokens

For more information, see the blog or the documentation.

More of our favorite changes

  • Added snow mode toggle to the theme selector for a festive winter interface

  • Added tooltip to Stream tab for metrics datasets to provide helpful context