Class: Telnyx::Resources::WebSearch::Research

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/web_search/research.rb,
sig/telnyx/resources/web_search/research.rbs

Overview

Deep research with citations and async task polling.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Research

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Research.

Parameters:



80
81
82
# File 'lib/telnyx/resources/web_search/research.rb', line 80

def initialize(client:)
  @client = client
end

Instance Method Details

#create(query:, background: nil, max_sources: nil, research_effort: nil, request_options: {}) ⇒ Telnyx::Models::WebSearch::ResearchCreateResponse

Some parameter documentations has been truncated, see Models::WebSearch::ResearchCreateParams for more details.

Starts a deep research task that runs multiple searches, reads sources, and synthesizes an answer with citations.

Synchronous mode (default)

When background is false or omitted, the request blocks until the research completes and returns the answer with citations. This can take up to 120 seconds depending on research_effort.

Asynchronous mode

When background is true, the request returns immediately with a task_id and status: pending. Poll GET /web_search/research/{task_id} to check when the research completes and retrieve the answer.

Parameters:

  • query (String)

    The research question or topic.

  • background (Boolean)

    When true, the research runs asynchronously. The response returns a task_id

  • max_sources (Integer)

    Maximum number of sources to use.

  • research_effort (Symbol, Telnyx::Models::WebSearch::ResearchCreateParams::ResearchEffort)

    Research depth level. lite is fastest, deep is most thorough.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/telnyx/resources/web_search/research.rb', line 41

def create(params)
  parsed, options = Telnyx::WebSearch::ResearchCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "web_search/research",
    body: parsed,
    model: Telnyx::Models::WebSearch::ResearchCreateResponse,
    options: options
  )
end

#retrieve(task_id, request_options: {}) ⇒ Telnyx::Models::WebSearch::ResearchRetrieveResponse

Some parameter documentations has been truncated, see Models::WebSearch::ResearchRetrieveParams for more details.

Polls the status of a previously started asynchronous research task. When the status is completed, the response includes the answer and citations. When the status is failed, the response includes an error message.

Parameters:

  • task_id (String)

    The research task ID returned by POST /web_search/research with `background: t

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



68
69
70
71
72
73
74
75
# File 'lib/telnyx/resources/web_search/research.rb', line 68

def retrieve(task_id, params = {})
  @client.request(
    method: :get,
    path: ["web_search/research/%1$s", task_id],
    model: Telnyx::Models::WebSearch::ResearchRetrieveResponse,
    options: params[:request_options]
  )
end