# `Jido.AI.Actions.Reasoning.Analyze`
[🔗](https://github.com/agentjido/jido_ai/blob/v2.4.0/lib/jido_ai/actions/reasoning/analyze.ex#L1)

A Jido.Action for performing deep analysis of text/data with structured output.

This action uses ReqLLM directly with specialized system prompts for different
types of analysis: sentiment, topics, entities, summary, or custom.

## Parameters

* `model` (optional) - Model alias (e.g., `:reasoning`) or direct spec
* `input` (required) - The text or data to analyze
* `analysis_type` (optional) - Type of analysis: `:sentiment`, `:topics`, `:entities`, `:summary`, `:custom`
* `custom_prompt` (optional) - Custom analysis instructions (when `analysis_type: :custom`)
* `max_tokens` (optional) - Maximum tokens to generate (default: `2048`)
* `temperature` (optional) - Sampling temperature (default: `0.3`)
* `timeout` (optional) - Request timeout in milliseconds

## Examples

    # Sentiment analysis
    {:ok, result} = Jido.Exec.run(Jido.AI.Actions.Reasoning.Analyze, %{
      input: "I absolutely loved the movie! The acting was superb.",
      analysis_type: :sentiment
    })

    # Topic extraction
    {:ok, result} = Jido.Exec.run(Jido.AI.Actions.Reasoning.Analyze, %{
      input: article_text,
      analysis_type: :topics
    })

    # Custom analysis
    {:ok, result} = Jido.Exec.run(Jido.AI.Actions.Reasoning.Analyze, %{
      input: data,
      analysis_type: :custom,
      custom_prompt: "Analyze this data for trends and anomalies."
    })

# `__action_metadata__`

Returns the Action metadata. Alias for to_json/0.

# `category`

Returns the category of the Action.

# `description`

Returns the description of the Action.

# `name`

Returns the name of the Action.

# `on_after_run`

Lifecycle hook called after Action execution.

# `on_after_validate_output`

Lifecycle hook called after output validation.

# `on_after_validate_params`

Lifecycle hook called after parameter validation.

# `on_before_validate_output`

Lifecycle hook called before output validation.

# `on_before_validate_params`

Lifecycle hook called before parameter validation.

# `on_error`

Lifecycle hook called when an error occurs.

# `output_schema`

Returns the output schema of the Action.

# `run`

Executes the analyze action.

## Returns

* `{:ok, result}` - Successful response with `result`, `analysis_type`, `model`, and `usage` keys
* `{:error, reason}` - Error from ReqLLM or validation

## Result Format

    %{
      result: "The analysis result text",
      analysis_type: :sentiment,
      model: "anthropic:claude-sonnet-4-20250514",
      usage: %{
        input_tokens: 100,
        output_tokens: 250,
        total_tokens: 350
      }
    }

# `schema`

Returns the input schema of the Action.

# `tags`

Returns the tags associated with the Action.

# `to_json`

Returns the Action metadata as a JSON-serializable map.

# `to_tool`

Converts the Action to an LLM-compatible tool format.

# `validate_output`

```elixir
@spec validate_output(map()) :: {:ok, map()} | {:error, String.t()}
```

Validates the output result for the Action.

## Examples

    iex> defmodule ExampleAction do
    ...>   use Jido.Action,
    ...>     name: "example_action",
    ...>     output_schema: [
    ...>       result: [type: :string, required: true]
    ...>     ]
    ...> end
    ...> ExampleAction.validate_output(%{result: "test", extra: "ignored"})
    {:ok, %{result: "test", extra: "ignored"}}

    iex> ExampleAction.validate_output(%{extra: "ignored"})
    {:error, "Invalid output for Action: Required key :result not found"}

# `validate_params`

```elixir
@spec validate_params(map()) :: {:ok, map()} | {:error, String.t()}
```

Validates the input parameters for the Action.

## Examples

    iex> defmodule ExampleAction do
    ...>   use Jido.Action,
    ...>     name: "example_action",
    ...>     schema: [
    ...>       input: [type: :string, required: true]
    ...>     ]
    ...> end
    ...> ExampleAction.validate_params(%{input: "test"})
    {:ok, %{input: "test"}}

    iex> ExampleAction.validate_params(%{})
    {:error, "Invalid parameters for Action: Required key :input not found"}

# `vsn`

Returns the version of the Action.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
