Models
Models are the foundation of intelligence in the aiXplain ecosystem. They encapsulate capabilities such as language understanding, translation, summarization, speech processing, and more. Models can be directly used or integrated as tools into agents.
Key Concepts:
-
Models are callable assets that accept text, audio, or other modalities.
-
They support multiple functions: generation, translation, classification, etc.
-
Models can be run synchronously, asynchronously, or in streaming mode.
-
Streaming responses yield results incrementally while
status=IN_PROGRESS
.
Listing Models
To explore all accessible models for your team:
from aixplain.factories import ModelFactory
models = ModelFactory.list(
function=Function.TRANSLATION,
source_languages=[Language.ENGLISH],
target_languages=[Language.FRENCH]
)
for model in model_list:
print(model.id, model.name, model.supplier)
Alternatively, browse models and other assets in the marketplace.
Parameters
Parameter | Type | Description |
---|---|---|
function | Function | Filter by model function (e.g., TEXT_GENERATION, TRANSLATION, SUMMARIZATION). |
query | str | Optional keyword to search by name or description. |
suppliers | Supplier or List[Supplier] | Filter by model supplier (e.g., OPENAI, HUGGINGFACE). |
source_languages | Language or List[Language] | Accepted source/input language(s). |
target_languages | Language or List[Language] | Output language(s), applicable to translation models. |
is_finetunable | bool | Whether the model supports fine-tuning. |
ownership | Tuple[OwnershipType, List[OwnershipType]] | Ownership filter: OWNER, SUBSCRIBED, PUBLIC. |
sort_by | SortBy | Attribute to sort by (e.g., NAME, CREATED_AT). |
sort_order | SortOrder | ASCENDING or DESCENDING. |
page_number | int | Page number for paginated results. |
page_size | int | Maximum number of results to return (default: 20). |
model_ids | List[str] | Specific model IDs to retrieve. Cannot be used with other filters. |
api_key | str | Optional API key override for authorization. |
Running a Model
You can run a model by calling run()
with the desired input:
model = ModelFactory.get("65c51c556eb563350f6e1bb1")
response = model.run("Latest news about AI agents")
print(response.data.output)
Streaming Output for LLMs
To receive tokens incrementally for LLMs:
response = model.run("Explain LLMs", stream=True)
for chunk in response:
print(chunk)
Each chunk is a ModelResponse object with:
-
status:
IN_PROGRESS
orCOMPLETED
-
data: Partial output (if available)
-
details: Full content generated so far
You can also use a loop with next(response)
until status is COMPLETE
.
response = model.run("Explain how to change a light bulb", max_tokens=512, stream=True)
while response.status == ResponseStatus.IN_PROGRESS:
content = next(response)
print(content)