> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PromptChain

> Prompt_Chain utilities for data models and type definitions used throughout the maxim sdk.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/models/prompt_chain.py)

## [AgentCost](/sdk/python/references/models/prompt_chain)

```python theme={null}
class AgentCost(TypedDict)
```

Type definition for agent execution costs.

**Attributes**:

| Name     | Description            |
| -------- | ---------------------- |
| `input`  | Cost for input tokens  |
| `output` | Cost for output tokens |
| `total`  | Total execution cost   |

## [AgentUsage](/sdk/python/references/models/prompt_chain)

```python theme={null}
class AgentUsage(TypedDict)
```

Type definition for agent token usage statistics.

**Attributes**:

| Name                | Description                             |
| ------------------- | --------------------------------------- |
| `prompt_tokens`     | Number of tokens used in the prompt     |
| `completion_tokens` | Number of tokens used in the completion |
| `total_tokens`      | Total number of tokens used             |

## [AgentResponseMeta](/sdk/python/references/models/prompt_chain)

```python theme={null}
class AgentResponseMeta(TypedDict)
```

Type definition for agent response metadata.

**Attributes**:

| Name                       | Description                                  |
| -------------------------- | -------------------------------------------- |
| `cost`                     | Cost breakdown for the response              |
| `usage`                    | Token usage statistics                       |
| `bound_variable_responses` | Optional dictionary of bound variable values |
| `retrieved_context`        | Optional retrieved context string            |

## [AgentResponse](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class AgentResponse()
```

Represents a complete agent response with metadata.

This class encapsulates both the actual response content and associated
metadata including cost, usage statistics, and contextual information.

**Attributes**:

| Name       | Description                                                                                     |
| ---------- | ----------------------------------------------------------------------------------------------- |
| `response` | The actual response text from the agent                                                         |
| `meta`     | [Metadata](/sdk/python/references/models/metadata) about the response including costs and usage |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "AgentResponse"
```

Create an [AgentResponse](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                                    |
| ------ | ---------------------------------------------- |
| `data` | Dictionary containing response and meta fields |

**Returns**:

| Name                                                          | Description                                   |
| ------------------------------------------------------------- | --------------------------------------------- |
| `[AgentResponse](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptNode](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptNode()
```

[Node](/sdk/python/references/models/prompt_chain) containing a prompt in a prompt chain.

This node type wraps a [Prompt](/sdk/python/references/models/prompt) object and represents a step in the chain
that executes a prompt.

**Attributes**:

| Name     | Description                                                              |
| -------- | ------------------------------------------------------------------------ |
| `prompt` | The [Prompt](/sdk/python/references/models/prompt) object to be executed |

## [CodeBlockNode](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class CodeBlockNode()
```

[Node](/sdk/python/references/models/prompt_chain) containing executable code in a prompt chain.

This node type contains code that can be executed as part of the
prompt chain workflow.

**Attributes**:

| Name   | Description                    |
| ------ | ------------------------------ |
| `code` | The code string to be executed |

## [ApiParams](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class ApiParams()
```

Parameters for API node configuration.

**Attributes**:

| Name    | Description                         |
| ------- | ----------------------------------- |
| `id`    | Unique identifier for the parameter |
| `key`   | Parameter key name                  |
| `value` | Parameter value                     |

## [ApiNode](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class ApiNode()
```

[Node](/sdk/python/references/models/prompt_chain) containing API configuration in a prompt chain.

This node type wraps API configuration and represents a step in the chain
that makes an API call.

**Attributes**:

| Name  | Description                             |
| ----- | --------------------------------------- |
| `api` | Dictionary containing API configuration |

## [Node](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class Node()
```

Generic node in a prompt chain.

A [Node](/sdk/python/references/models/prompt_chain) represents a single step in a prompt chain and can contain
different types of content (prompt, code, or API configuration).

**Attributes**:

| Name      | Description                                                                                                                                                                                          |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `order`   | Execution order of this node in the chain                                                                                                                                                            |
| `content` | The actual content ([PromptNode](/sdk/python/references/models/prompt_chain), [CodeBlockNode](/sdk/python/references/models/prompt_chain), or [ApiNode](/sdk/python/references/models/prompt_chain)) |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "Node"
```

Create a [Node](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                                         |
| ------ | --------------------------------------------------- |
| `data` | Dictionary containing order and content type fields |

**Returns**:

| Name                                                 | Description                                   |
| ---------------------------------------------------- | --------------------------------------------- |
| `[Node](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChain](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChain()
```

Complete prompt chain with versioning information.

A [PromptChain](/sdk/python/references/models/prompt_chain) represents a complete workflow consisting of multiple
nodes that are executed in sequence. Each chain has versioning
information for tracking changes over time.

**Attributes**:

| Name              | Description                                 |
| ----------------- | ------------------------------------------- |
| `prompt_chain_id` | Unique identifier for the prompt chain      |
| `version`         | Version number of this chain                |
| `version_id`      | Unique identifier for this specific version |
| `nodes`           | List of nodes that make up the chain        |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "PromptChain"
```

Create a [PromptChain](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                             |
| ------ | --------------------------------------- |
| `data` | Dictionary containing prompt chain data |

**Returns**:

| Name                                                        | Description                                   |
| ----------------------------------------------------------- | --------------------------------------------- |
| `[PromptChain](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainVersionConfig](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainVersionConfig()
```

Configuration for a specific prompt chain version.

Contains the actual configuration data (nodes) for a particular
version of a prompt chain.

**Attributes**:

| Name    | Description                                 |
| ------- | ------------------------------------------- |
| `nodes` | List of nodes in this version configuration |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "PromptChainVersionConfig"
```

Create a [PromptChainVersionConfig](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                                      |
| ------ | ------------------------------------------------ |
| `data` | Dictionary containing version configuration data |

**Returns**:

| Name                                                                     | Description                                   |
| ------------------------------------------------------------------------ | --------------------------------------------- |
| `[PromptChainVersionConfig](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainVersion](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainVersion()
```

Specific version of a prompt chain with metadata.

Represents a particular version of a prompt chain including
its configuration, description, and timestamps.

**Attributes**:

| Name            | Description                                  |
| --------------- | -------------------------------------------- |
| `id`            | Unique identifier for this version           |
| `version`       | Version number                               |
| `promptChainId` | ID of the parent prompt chain                |
| `description`   | Optional description of this version         |
| `config`        | Optional configuration for this version      |
| `createdAt`     | Timestamp when this version was created      |
| `updatedAt`     | Timestamp when this version was last updated |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "PromptChainVersion"
```

Create a [PromptChainVersion](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                        |
| ------ | ---------------------------------- |
| `data` | Dictionary containing version data |

**Returns**:

| Name                                                               | Description                                   |
| ------------------------------------------------------------------ | --------------------------------------------- |
| `[PromptChainVersion](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainRuleType](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainRuleType()
```

Individual rule for prompt chain deployment logic.

Defines a single rule that can be used to determine which version
of a prompt chain should be deployed based on various conditions.

**Attributes**:

| Name          | Description                                                        |
| ------------- | ------------------------------------------------------------------ |
| `field`       | The field to evaluate in the rule                                  |
| `value`       | The value to compare against (can be various types including None) |
| `operator`    | The comparison operator to use                                     |
| `valueSource` | Optional source of the value                                       |
| `exactMatch`  | Optional flag for exact matching                                   |

#### value

adding None here

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [PromptChainRuleType](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                     |
| ----- | ------------------------------- |
| `obj` | Dictionary containing rule data |

**Returns**:

| Name                                                                | Description                                   |
| ------------------------------------------------------------------- | --------------------------------------------- |
| `[PromptChainRuleType](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainRuleGroupType](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainRuleGroupType()
```

Group of rules with a combinator for prompt chain deployment logic.

Allows grouping multiple rules together with logical operators
(AND/OR) to create complex deployment conditions.

**Attributes**:

| Name         | Description                                       |
| ------------ | ------------------------------------------------- |
| `rules`      | List of rules or nested rule groups               |
| `combinator` | Logical operator to combine rules ("and" or "or") |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [PromptChainRuleGroupType](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                           |
| ----- | ------------------------------------- |
| `obj` | Dictionary containing rule group data |

**Returns**:

| Name                                                                     | Description                                   |
| ------------------------------------------------------------------------ | --------------------------------------------- |
| `[PromptChainRuleGroupType](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainDeploymentRules](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainDeploymentRules()
```

Deployment rules for a specific prompt chain version.

Defines the conditions under which a particular version of a
prompt chain should be deployed or used.

**Attributes**:

| Name      | Description                                                |
| --------- | ---------------------------------------------------------- |
| `version` | The version number these rules apply to                    |
| `query`   | Optional rule group that defines the deployment conditions |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [PromptChainDeploymentRules](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                                 |
| ----- | ------------------------------------------- |
| `obj` | Dictionary containing deployment rules data |

**Returns**:

| Name                                                                       | Description                                   |
| -------------------------------------------------------------------------- | --------------------------------------------- |
| `[PromptChainDeploymentRules](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [VersionSpecificDeploymentConfig](/sdk/python/references/models/prompt)

```python theme={null}
@dataclass
class VersionSpecificDeploymentConfig()
```

Configuration for deploying a specific version.

Contains deployment configuration including rules, timestamps,
and fallback information for a particular version.

**Attributes**:

| Name         | Description                                         |
| ------------ | --------------------------------------------------- |
| `id`         | Unique identifier for this deployment configuration |
| `timestamp`  | When this configuration was created                 |
| `rules`      | The deployment rules for this configuration         |
| `isFallback` | Whether this is a fallback configuration            |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [VersionSpecificDeploymentConfig](/sdk/python/references/models/prompt) instance from a dictionary.

**Arguments**:

| Name  | Description                                         |
| ----- | --------------------------------------------------- |
| `obj` | Dictionary containing deployment configuration data |

**Returns**:

| Name                                                                      | Description                                   |
| ------------------------------------------------------------------------- | --------------------------------------------- |
| `[VersionSpecificDeploymentConfig](/sdk/python/references/models/prompt)` | New instance created from the dictionary data |

## [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainVersionsAndRules()
```

[Container](/sdk/python/references/logger/models/container) for prompt chain versions and their deployment rules.

Aggregates all versions of a prompt chain along with their associated
deployment rules and folder organization.

**Attributes**:

| Name              | Description                                                       |
| ----------------- | ----------------------------------------------------------------- |
| `folderId`        | ID of the folder containing this prompt chain                     |
| `rules`           | Dictionary mapping rule IDs to lists of deployment configurations |
| `versions`        | List of all available versions                                    |
| `fallbackVersion` | Optional fallback version to use when rules don't match           |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                                   |
| ----- | --------------------------------------------- |
| `obj` | Dictionary containing versions and rules data |

**Returns**:

| Name                                                                        | Description                                   |
| --------------------------------------------------------------------------- | --------------------------------------------- |
| `[PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class VersionAndRulesWithPromptChainId(PromptChainVersionsAndRules)
```

Extension of [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain) that includes the prompt chain ID.

Provides the same functionality as [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain) but also
includes the prompt chain identifier for complete context.

**Attributes**:

| Name            | Description                           |
| --------------- | ------------------------------------- |
| `promptChainId` | Unique identifier of the prompt chain |

Inherits all attributes from [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain)

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                                                     |
| ----- | --------------------------------------------------------------- |
| `obj` | Dictionary containing versions, rules, and prompt chain ID data |

**Returns**:

| Name                                                                             | Description                                   |
| -------------------------------------------------------------------------------- | --------------------------------------------- |
| `[VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [MaximApiPromptChainResponse](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class MaximApiPromptChainResponse()
```

Response wrapper for single prompt chain API calls.

Encapsulates the response from API calls that return information
about a single prompt chain, including error handling.

**Attributes**:

| Name    | Description                                       |
| ------- | ------------------------------------------------- |
| `data`  | The prompt chain versions and rules data          |
| `error` | Optional error information if the API call failed |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(data: Dict[str, Any]) -> "MaximApiPromptChainResponse"
```

Create a [MaximApiPromptChainResponse](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name   | Description                             |
| ------ | --------------------------------------- |
| `data` | Dictionary containing API response data |

**Returns**:

| Name                                                                        | Description                                   |
| --------------------------------------------------------------------------- | --------------------------------------------- |
| `[MaximApiPromptChainResponse](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [PromptChainWithId](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class PromptChainWithId(PromptChainVersionsAndRules)
```

[Prompt](/sdk/python/references/models/prompt) chain versions and rules with associated prompt chain ID.

Similar to [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain) but used in different contexts.
Contains all version and rule information along with the prompt chain identifier.

**Attributes**:

| Name            | Description                           |
| --------------- | ------------------------------------- |
| `promptChainId` | Unique identifier of the prompt chain |

Inherits all attributes from [PromptChainVersionsAndRules](/sdk/python/references/models/prompt_chain)

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(obj: Dict[str, Any])
```

Create a [PromptChainWithId](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name  | Description                                     |
| ----- | ----------------------------------------------- |
| `obj` | Dictionary containing prompt chain data with ID |

**Returns**:

| Name                                                              | Description                                   |
| ----------------------------------------------------------------- | --------------------------------------------- |
| `[PromptChainWithId](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |

## [VersionAndRulesWithPromptChainIdEncoder](/sdk/python/references/models/prompt_chain)

```python theme={null}
class VersionAndRulesWithPromptChainIdEncoder(json.JSONEncoder)
```

Custom JSON encoder for [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain) objects.

Provides serialization support for [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain)
instances by converting them to dictionaries.

#### default

```python theme={null}
def default(o)
```

Convert [VersionAndRulesWithPromptChainId](/sdk/python/references/models/prompt_chain) objects to dictionaries.

**Arguments**:

| Name | Description      |
| ---- | ---------------- |
| `o`  | Object to encode |

**Returns**:

| Name   | Description                                                      |
| ------ | ---------------------------------------------------------------- |
| `dict` | Dictionary representation of the object, or calls parent default |

## [MaximApiPromptChainsResponse](/sdk/python/references/models/prompt_chain)

```python theme={null}
@dataclass
class MaximApiPromptChainsResponse()
```

Response wrapper for multiple prompt chains API calls.

Encapsulates the response from API calls that return information
about multiple prompt chains, including error handling.

**Attributes**:

| Name    | Description                                         |
| ------- | --------------------------------------------------- |
| `data`  | List of prompt chains with their versions and rules |
| `error` | Optional error information if the API call failed   |

#### from\_dict

```python theme={null}
@staticmethod
def from_dict(incoming_data: Dict[str, Any]) -> "MaximApiPromptChainsResponse"
```

Create a [MaximApiPromptChainsResponse](/sdk/python/references/models/prompt_chain) instance from a dictionary.

**Arguments**:

| Name            | Description                                                 |
| --------------- | ----------------------------------------------------------- |
| `incoming_data` | Dictionary containing API response data for multiple chains |

**Returns**:

| Name                                                                         | Description                                   |
| ---------------------------------------------------------------------------- | --------------------------------------------- |
| `[MaximApiPromptChainsResponse](/sdk/python/references/models/prompt_chain)` | New instance created from the dictionary data |
