Class: ElevenlabsClient::Endpoints::AgentsPlatform::LlmUsage

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/agents_platform/llm_usage.rb

Overview

LLM Usage endpoint - refactored for better maintainability

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ LlmUsage

Returns a new instance of LlmUsage.



8
9
10
# File 'lib/elevenlabs_client/endpoints/agents_platform/llm_usage.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#calculate(prompt_length:, number_of_pages:, rag_enabled:) ⇒ Hash Also known as: calculate_usage

POST /v1/convai/llm-usage/calculate Returns a list of LLM models and the expected cost for using them based on the provided values Documentation: https://elevenlabs.io/docs/api-reference/convai/llm-usage/calculate

Parameters:

  • prompt_length (Integer)

    Length of the prompt in characters (required)

  • number_of_pages (Integer)

    Pages of content in PDF documents or URLs in the agent's knowledge base (required)

  • rag_enabled (Boolean)

    Whether RAG is enabled (required)

Returns:

  • (Hash)

    JSON response containing list of LLM models with pricing information



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/elevenlabs_client/endpoints/agents_platform/llm_usage.rb', line 20

def calculate(prompt_length:, number_of_pages:, rag_enabled:)
  validate_required!(:prompt_length, prompt_length)
  validate_required!(:number_of_pages, number_of_pages) 
  validate_required!(:rag_enabled, rag_enabled)

  body = {
    prompt_length: prompt_length,
    number_of_pages: number_of_pages,
    rag_enabled: rag_enabled
  }

  @client.post("/v1/convai/llm-usage/calculate", body)
end