Tokens used by open AI

Is there a way to know within AP how many tokens a specific OpenAI step?

Hi Davide,

Unfortunately, the OpenAI piece in Activepieces doesn’t directly provide the token usage information. However, there’s a workaround using the HTTP request step. When you use an HTTP request to interact with OpenAI’s API, the response includes details about the number of tokens used.

Here’s an example of how this step would look:

Gives this output:

  "body": {
    "id": "chatcmpl-xxxxxxxxxx",
    "model": "gpt-3.5-turbo-0613",
    "usage": {
      "total_tokens": 87,
      "prompt_tokens": 26,
      "completion_tokens": 61
    "object": "chat.completion",
    "choices": [
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "Activepieces is a technology company that provides software solutions for human resources and workforce management. They offer a comprehensive suite of tools and platforms designed to optimize employee scheduling, time tracking, absence management, and other HR processes. With Activepieces, organizations can improve productivity, streamline operations, and better manage their workforce."
        "logprobs": null,
        "finish_reason": "stop"
    "created": 1704700890,
    "system_fingerprint": null
  "status": 200,
  "headers": {
    "date": "Mon, 08 Jan 2024 08:01:33 GMT",
    "cf-ray": "8422e9b37d3b65c2-FRA",
    "server": "cloudflare",
    "alt-svc": "h3=\":443\"; ma=86400",
    "connection": "close",
    "set-cookie": "__cf_bm=.vSwkwkuHg63ol8xxxxxNLkV_Lqy6xRm.Koul3qVnTg-1704700893-1-AYf55Ho4e+0+Uwv26tYUF2NTYqbJt0P66M/MdV6y6RyU2F02mP7OTeHD84HphfebA9s3t3aBAkLXqyMos8yR5ZA=; path=/; expires=Mon, 08-Jan-24 08:31:33 GMT;; HttpOnly; Secure; SameSite=None, _cfuvid=jUolKhbFa2j.ZAR9sA6oGg7iYKiIYSMidckcJnkU4as-1704700893932-0-604800000; path=/;; HttpOnly; Secure; SameSite=None",
    "content-type": "application/json",
    "openai-model": "gpt-3.5-turbo-0613",
    "x-request-id": "db49de93b111xxxb4be663431xx",
    "cache-control": "no-cache, must-revalidate",
    "openai-version": "2020-10-01",
    "cf-cache-status": "DYNAMIC",
    "transfer-encoding": "chunked",
    "openai-organization": "user-lybjgxxxxxcbg1udmx",
    "openai-processing-ms": "3597",
    "x-ratelimit-limit-tokens": "60000",
    "x-ratelimit-reset-tokens": "37ms",
    "strict-transport-security": "max-age=15724800; includeSubDomains",
    "x-ratelimit-limit-requests": "10000",
    "x-ratelimit-reset-requests": "8.64s",
    "access-control-allow-origin": "*",
    "x-ratelimit-remaining-tokens": "59963",
    "x-ratelimit-remaining-requests": "9999",
    "x-ratelimit-limit-tokens_usage_based": "60000",
    "x-ratelimit-reset-tokens_usage_based": "37ms",
    "x-ratelimit-remaining-tokens_usage_based": "59963"

Thanks Dennis, that helps! it would be nice to have access to this data using the Open AI piece, though

Hi Davide,

I partly agree that including token usage in the OpenAI piece could be helpful. However, for most people, this might overcomplicate the interface. Those needing detailed data can access it through the API directly, keeping the main tool streamlined for general users.

I see your point, I agree one making the platform as userfriendly as possible. I’ll move to an HTTP request.
In your example “Bearer sk-xxxxxxx” I’m guessing I’ll enter my API key instead of the xxxxxx part correct?

Yes, that’s right!‎‎‎‎‎‎‎‎‎‎