kiarina-agi-text
Dependencies
Required Dependencies
| Package | Version | License |
|---|---|---|
| kiarina-agi-base | >=2.6.0 |
MIT |
| kiarina-agi-data | >=2.36.0 |
MIT |
| kiarina-agi-file | >=2.6.0 |
MIT |
| kiarina-utils-app | >=2.4.0 |
MIT |
| kiarina-utils-common | >=2.3.0 |
MIT |
| kiarina-utils-file | >=2.3.1 |
MIT |
| Pydantic | >=2.11.7 |
MIT |
| pydantic-settings | >=2.10.1 |
MIT |
| pydantic-settings-manager | >=3.2.0 |
MIT |
Optional Dependencies
| Package | Version | License | Extras |
|---|---|---|---|
| anthropic | >=0.84.0,<2 |
MIT | chat-provider-anthropicchat-provider-anthropic-vertex |
| claude-agent-sdk | >=0.2.164 |
MIT | chat-provider-claude-code |
| FastAPI | >=0.162.0,<1 |
MIT | chat-proxy |
| google-genai | >=1.65.0,<3 |
Apache-2.0 | chat-provider-googletext-embedding-provider-google |
| HTTPX | >=0.28.1,<1 |
BSD-3-Clause | chat-provider-proxy |
| kiarina-lib-anthropic | >=2.3.1 |
MIT | chat-provider-anthropicchat-provider-anthropic-vertex |
| kiarina-lib-google | >=2.4.0 |
MIT | chat-provider-anthropic-vertexchat-provider-googletext-embedding-provider-google |
| kiarina-lib-openai | >=2.3.1 |
MIT | chat-provider-openaitext-embedding-provider-openai |
| NumPy | >=2.0 |
BSD-3-Clause | text-embedding-provider-googletext-embedding-provider-mocktext-embedding-provider-openai |
| openai | >=2.0.1,<4 |
Apache-2.0 | chat-provider-openaitext-embedding-provider-openai |
| openai-codex-cli-bin | >=0.160.1 |
Apache-2.0 | chat-provider-codex |
| tiktoken | >=0.13.0 |
MIT | text-embedding-provider-openai |
| ulid-py | >=1.1.0 |
Apache-2.0 | chat-provider-mock |
| Uvicorn | >=0.54.0,<1 |
BSD-3-Clause | chat-proxy |
The all Extra installs every optional dependency listed above except those of chat-proxy, so apps that use chat models do not get a web server.
Installation
pip install "kiarina-agi-text[all]"
Features
- Chat Models Select a model by name or alias and receive one response or a stream. Tool calls and image, audio, video, and PDF inputs and outputs are also supported.
- Chat Proxy
Run chat models on another machine over HTTP: the chat proxy serves its chat models, and the
proxychat provider calls them. For example, a container can usecodexandclaude_codewith the host's subscription logins without having them itself. - Text Embeddings Select a registered model and vectorize text through one API.
API Reference
kiarina.agi.chat_model
from kiarina.agi.chat_model import (
ChatModel,
ChatModelAlias,
ChatModelConfig,
ChatModelName,
ChatModelSettings,
ChatModelSpecifier,
ChatOptions,
chat_model_registry,
invoke_chat,
run_chat,
settings_manager,
stream_chat,
)
async def invoke_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AIMessage: ...
async def run_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
async def stream_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
class ChatModel:
def __init__(self, name: ChatModelName, config: ChatModelConfig) -> None: ...
@property
def provider_name(self) -> ChatProviderName: ...
@property
def provider_config(self) -> dict[str, Any]: ...
@property
def token_scale_factor(self) -> float: ...
@property
def provider(self) -> ChatProvider: ...
def get_capabilities(self) -> ChatCapabilities: ...
async def run(
self,
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
tool_choice: ToolChoice | None = None,
parallel_tool_calls: bool | None = None,
streaming: bool | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
class ChatModelConfig(BaseModel):
provider_name: ChatProviderName
provider_config: dict[str, Any] = {}
token_scale_factor: float = 1.0
visible: bool = True
class ChatOptions(TypedDict, total=False):
chat_model: ChatModel | ChatModelSpecifier | None
tool_choice: ToolChoice | None
parallel_tool_calls: bool | None
streaming: bool | None
ChatModelName: TypeAlias = str
ChatModelAlias: TypeAlias = str
ChatModelSpecifier: TypeAlias = ChatModelName | ChatModelAlias | str
chat_model_registry: ObjectRegistry[ChatModel, ChatModelConfig]
settings_manager: SettingsManager[ChatModelSettings]
ChatModelSettings is a Pydantic settings class with default, aliases, presets, and customs fields.
kiarina.agi.chat_proxy
from kiarina.agi.chat_proxy import (
ChatProxyError,
ChatProxyErrorInfo,
ChatProxyEvent,
ChatProxyFile,
ChatProxyMissingFilesError,
ChatProxyModelInfo,
ChatProxyRequest,
ChatProxySettings,
attach_chat_proxy_files,
collect_chat_proxy_files,
create_chat_proxy_app,
run_chat_proxy,
settings_manager,
)
def create_chat_proxy_app(settings: ChatProxySettings | None = None) -> FastAPI: ...
def run_chat_proxy(settings: ChatProxySettings | None = None) -> None: ...
async def collect_chat_proxy_files(
messages: list[Message],
*,
run_context: RunContext,
known_hashes: Container[str] = (),
) -> dict[str, ChatProxyFile]: ...
async def attach_chat_proxy_files(
messages: list[Message],
files: dict[str, ChatProxyFile],
*,
run_context: RunContext,
) -> list[Message]: ...
class ChatProxySettings(BaseSettings): # env prefix: KIARINA_AGI_CHAT_PROXY_
host: str = "127.0.0.1"
port: int = 8795
token: SecretStr | None = None
allowed_models: list[str] | None = None
max_concurrency: int = 4
class ChatProxyRequest(BaseModel):
model_name: str
messages: list[Message]
tool_infos: list[ToolInfo] | None = None
tool_choice: ToolChoice | None = None
parallel_tool_calls: bool | None = None
streaming: bool | None = None
run_context: RunContext
files: dict[str, ChatProxyFile] = {}
class ChatProxyFile(BaseModel):
mime_type: str
sha256: str
base64_data: str | None = None
class ChatProxyEvent(BaseModel):
type: Literal["chunk", "message", "cost", "error"]
message: AIMessageChunk | AIMessage | None = None
cost_record: CostRecord | None = None
error: ChatProxyErrorInfo | None = None
class ChatProxyErrorInfo(BaseModel):
kind: Literal["safety", "max_token", "token_overflow", "other"]
error_type: str
message: str
category: str | None = None
request_id: str | None = None
token_count: int | None = None
limit: int | None = None
@classmethod
def from_exception(cls, error: BaseException) -> Self: ...
def to_exception(self) -> Exception: ...
class ChatProxyModelInfo(BaseModel):
name: str
capabilities: ChatCapabilities
class ChatProxyError(Exception): ...
class ChatProxyMissingFilesError(ChatProxyError):
hashes: list[str]
settings_manager: SettingsManager[ChatProxySettings]
The chat proxy serves two endpoints, both requiring Authorization: Bearer <token> when token is set:
| Endpoint | Response |
|---|---|
GET /v1/chat-models/{model_name} |
ChatProxyModelInfo |
POST /v1/chat with a ChatProxyRequest |
NDJSON lines of ChatProxyEvent: chunks, the final message, then cost records, or an error. 409 with {"missing": [<sha256>, ...]} when a file sent without contents is not on the proxy |
Run it with the kiarina-chat-proxy command (pip install "kiarina-agi-text[chat-proxy]" plus the extras of the chat providers it serves). Callers use the proxy chat provider (pip install "kiarina-agi-text[chat-provider-proxy]"):
ChatModelConfig(
provider_name="proxy",
provider_config={
"base_url": "http://host.docker.internal:8795",
"model_name": "codex",
"token": "...",
},
)
ProxyChatProviderSettings (env prefix KIARINA_AGI_CHAT_PROVIDER_IMPL_PROXY_) has base_url, model_name, token, and timeout. The provider reads the chat model's capabilities from the proxy once. Media files are read where the caller runs and sent with their SHA-256; the proxy stores them in its asset repository under that hash. The provider sends a file's contents only until the proxy has taken them once, and sends them again if the proxy answers 409. A media file the caller cannot read is sent as metadata only. Chat provider errors (SafetyError, MaxTokenError, TokenOverflowError) are raised again on the caller with their fields; other errors become ChatProxyError.
kiarina.agi.text_embedding_model
from kiarina.agi.text_embedding_model import (
TextEmbeddingModel,
TextEmbeddingModelAlias,
TextEmbeddingModelConfig,
TextEmbeddingModelName,
TextEmbeddingModelSettings,
TextEmbeddingModelSpecifier,
TextEmbeddingOptions,
embed_text,
settings_manager,
text_embedding_model_registry,
)
async def embed_text(
text: str,
*,
text_embedding_options: TextEmbeddingOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> Embedding: ...
class TextEmbeddingModel:
def __init__(
self, name: TextEmbeddingModelName, config: TextEmbeddingModelConfig
) -> None: ...
@property
def provider_name(self) -> TextEmbeddingProviderName: ...
@property
def provider_config(self) -> dict[str, Any]: ...
@property
def provider(self) -> TextEmbeddingProvider: ...
def get_space(self) -> EmbeddingSpace: ...
async def embed(
self,
text: str,
*,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> Embedding: ...
class TextEmbeddingModelConfig(BaseModel):
provider_name: TextEmbeddingProviderName
provider_config: dict[str, Any] = {}
visible: bool = True
class TextEmbeddingOptions(TypedDict, total=False):
text_embedding_model: TextEmbeddingModel | TextEmbeddingModelSpecifier | None
TextEmbeddingModelName: TypeAlias = str
TextEmbeddingModelAlias: TypeAlias = str
TextEmbeddingModelSpecifier: TypeAlias = (
TextEmbeddingModelName | TextEmbeddingModelAlias | str
)
text_embedding_model_registry: ObjectRegistry[
TextEmbeddingModel, TextEmbeddingModelConfig
]
settings_manager: SettingsManager[TextEmbeddingModelSettings]
TextEmbeddingModelSettings has default, aliases, presets, and customs fields.
Metadata
Release files for kiarina-agi-text 2.37.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kiarina_agi_text-2.37.0.tar.gz | 136.9 kB | With provenance | Details for kiarina_agi_text-2.37.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kiarina_agi_text-2.37.0-py3-none-any.whl | Python 3 | none | any | Details for kiarina_agi_text-2.37.0-py3-none-any.whl |
Total release size: 291.5 kB
Release files / kiarina_agi_text-2.37.0.tar.gz
| Download URL | kiarina_agi_text-2.37.0.tar.gz |
|---|---|
| Size | 136.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26a373fb0e848989279037419fb2c882e22eddfe075e96a5c357d843546e7b8d
|
|
BLAKE2b-256 checksum How to use checksums |
c84255c3acf1e6e4f825e47f5bf5237a2c820a5154391a97587c51fb8202cc67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logRelease files / kiarina_agi_text-2.37.0-py3-none-any.whl
| Download URL | kiarina_agi_text-2.37.0-py3-none-any.whl |
|---|---|
| Size | 154.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d93f76de9aaf6a92b62bc2d5b31b0c715f4b19e84052b936fe103f61085fd580
|
|
BLAKE2b-256 checksum How to use checksums |
bfab16c502dbc1500fee34acae8d8ee49646f6d186ee95b5228188e91f41215d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logSecurity for kiarina-agi-text 2.37.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kiarina_agi_text-2.37.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.