aixplain.v2.model
Model resource for v2 API.
Message Objects
@dataclass_json
@dataclass
class Message()
Message structure from the API response.
Detail Objects
@dataclass_json
@dataclass
class Detail()
Detail structure from the API response.
Usage Objects
@dataclass_json
@dataclass
class Usage()
Usage structure from the API response.
ModelResult Objects
@dataclass_json
@dataclass
class ModelResult(Result)
Result for model runs with specific fields from the backend response.
InputsProxy Objects
class InputsProxy()
Proxy object that provides both dict-like and dot notation access to model parameters.
__init__
def __init__(model)
Initialize InputsProxy with a model instance.
__getitem__
def __getitem__(key: str)
Dict-like access: inputs['temperature'].
__setitem__
def __setitem__(key: str, value)
Dict-like assignment: inputs['temperature'] = 0.7.
__getattr__
def __getattr__(name: str)
Dot notation access: inputs.temperature.
__setattr__
def __setattr__(name: str, value)
Dot notation assignment: inputs.temperature = 0.7.
__contains__
def __contains__(key: str) -> bool
Check if parameter exists: 'temperature' in inputs.
__len__
def __len__() -> int
Number of parameters.
__iter__
def __iter__()
Iterate over parameter names.
keys
def keys()
Get parameter names.
values
def values()
Get parameter values.
items
def items()
Get parameter name-value pairs.
get
def get(key: str, default=None)
Get parameter value with default.
update
def update(**kwargs)
Update multiple parameters at once.
clear
def clear()
Reset all parameters to backend defaults.
copy
def copy()
Get a copy of current parameter values.
has_parameter
def has_parameter(param_name: str) -> bool
Check if a parameter exists.
get_parameter_names
def get_parameter_names() -> list
Get a list of all available parameter names.
get_required_parameters
def get_required_parameters() -> list
Get a list of required parameter names.
get_parameter_info
def get_parameter_info(param_name: str)
Get information about a specific parameter.
get_all_parameters
def get_all_parameters() -> dict
Get all current parameter values.
reset_parameter
def reset_parameter(param_name: str)
Reset a parameter to its backend default value.
reset_all_parameters
def reset_all_parameters()
Reset all parameters to their backend default values.
__repr__
def __repr__()
Return string representation of InputsProxy.
find_supplier_by_id
def find_supplier_by_id(supplier_id: Union[str, int]) -> Optional[Supplier]
Find supplier enum by ID.
find_function_by_id
def find_function_by_id(function_id: str) -> Optional[Function]
Find function enum by ID.
Attribute Objects
@dataclass_json
@dataclass
class Attribute()
Common attribute structure from the API response.
Parameter Objects
@dataclass_json
@dataclass
class Parameter()
Common parameter structure from the API response.
Version Objects
@dataclass_json
@dataclass
class Version()
Version structure from the API response.
Pricing Objects
@dataclass_json
@dataclass
class Pricing()
Pricing structure from the API response.
VendorInfo Objects
@dataclass_json
@dataclass
class VendorInfo()
Supplier information structure from the API response.
ModelSearchParams Objects
class ModelSearchParams(BaseSearchParams)
Search parameters for model queries.
q
Search query parameter as per Swagger spec
host
Filter by host (e.g., "openai", "aiXplain")
developer
Filter by developer (e.g., "OpenAI")
path
Filter by path prefix (e.g., "openai/gpt-4")
ModelRunParams Objects
class ModelRunParams(BaseRunParams)
Parameters for running models.
This class is intentionally empty to allow dynamic validation based on each model's specific parameters from the backend.
Model Objects
@dataclass_json
@dataclass(repr=False)
class Model(BaseResource, SearchResourceMixin[ModelSearchParams, "Model"],
GetResourceMixin[BaseGetParams, "Model"],
RunnableResourceMixin[ModelRunParams, ModelResult], ToolableMixin)
Resource for models.
__post_init__
def __post_init__()
Initialize dynamic attributes based on backend parameters.
__setattr__
def __setattr__(name: str, value)
Handle bulk assignment to inputs.
build_run_url
def build_run_url(**kwargs: Unpack[ModelRunParams]) -> str
Build the URL for running the model.
mark_as_deleted
def mark_as_deleted() -> None
Mark the model as deleted by setting status to DELETED and calling parent method.
get
@classmethod
def get(cls: type["Model"], id: str,
**kwargs: Unpack[BaseGetParams]) -> "Model"
Get a model by ID.
search
@classmethod
def search(cls: type["Model"],
query: Optional[str] = None,
**kwargs: Unpack[ModelSearchParams]) -> Page["Model"]
Search with optional query and filtering.
Arguments:
query- Optional search query string**kwargs- Additional search parameters (functions, suppliers, etc.)
Returns:
Page of items matching the search criteria
run
def run(**kwargs: Unpack[ModelRunParams]) -> ModelResult
Run the model with dynamic parameter validation and default handling.
as_tool
def as_tool() -> ToolDict
Serialize this model as a tool for agent creation.
This method converts the model into a dictionary format that can be used as a tool when creating agents. The format matches what the agent factory expects for model tools.
Returns:
dict- A dictionary representing this model as a tool with the following structure:- id: The model's ID
- name: The model's name
- description: The model's description
- supplier: The supplier code
- parameters: Current parameter values
- function: The model's function type
- type: Always "model"
- version: The model's version
- assetId: The model's ID (same as id)
Example:
model = aix.Model.get("some-model-id") agent = aix.Agent(..., tools=[model.as_tool()])
get_parameters
def get_parameters() -> List[dict]
Get current parameter values for this model.
Returns:
List[dict]- List of parameter dictionaries with current values