Skip to main content Switch to mobile version kiarina-agi-text 2.47.0 Chat and text embedding abstractions for AI agents
pip install kiarina-agi-text==2.47.0 Copy PIP instructions
Required Dependencies
Optional Dependencies
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.
openai-codex-cli-bin holds Codex itself (about 400 MB installed). The codex chat provider works without it: it runs, in order, the Codex that codex_bin of its settings points to, the bundled one when openai-codex-cli-bin is installed, and codex on PATH. To use the Codex installed on the machine, leave out the chat-provider-codex and all Extras and list the other Extras you need. CodexChatProvider.codex_bin returns the path it runs, so the caller can check it, for example with --version. The provider does not check the version.
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 proxy chat provider calls them. For example, a container can use codex and claude_code with the host's subscription logins without having them itself.
Text Embeddings Select a registered model and vectorize text through one API.
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.
The default aliases include one per model line, such as gpt-sol, claude-opus, codex-gpt-sol, and claude-code-opus, which point to the latest preset of that line. A chat model resolved from an alias is named after the preset. An alias names a preset, not another alias, and aliases given in settings replace the default ones.
kiarina.agi.chat_provider
The errors a chat model call raises, whichever provider serves it:
from kiarina.agi.chat_provider import ( MaxTokenError, SafetyError, TokenOverflowError, UsageLimitError, ) class TokenOverflowError(Exception): token_count: int limit: int | None class MaxTokenError(Exception): ... class SafetyError(Exception): category: str | None request_id: str | None class UsageLimitError(RuntimeError): kind: Literal["rate_limit", "usage_limit"] | None window: str | None resets_at: datetime | None UsageLimitError means the account behind the provider hit a limit of its plan, so the same request fails until the limit resets. The codex and claude_code providers raise it; before, the failure was a plain RuntimeError, which it still is.
kind: rate_limit for too many requests in a short time, usage_limit for a used-up allowance of the plan, None when the runtime did not say which.
window: the used-up window, such as five_hour or seven_day, when known.
resets_at: when the limit resets, timezone-aware, when the runtime reported it. Without it, retry after a pause of your choosing.
try: ai_message = await invoke_chat(messages, ...) except UsageLimitError as e: wait_until = e.resets_at # None: not reported 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, expire_chat_proxy_cache, find_missing_chat_proxy_files, 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 find_missing_chat_proxy_files( sha256s: list[str], *, run_context: RunContext ) -> list[str]: ... def expire_chat_proxy_cache( cache_dir: str | os.PathLike[str], ttl: int, *, now: float | None = None ) -> int: ... 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 cache_ttl: int = 86400 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", "usage_limit", "other"] error_type: str message: str category: str | None = None request_id: str | None = None token_count: int | None = None limit: int | None = None limit_kind: Literal["rate_limit", "usage_limit"] | None = None window: str | None = None resets_at: datetime | 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
The proxy keeps the files it receives in the app's user cache directory and deletes every file there not used for cache_ttl seconds (one day by default; 0 keeps them), at startup and hourly. Using a file, in a chat request or a /v1/files/missing check, touches it. A caller sends a deleted file again on its next request.
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. Before a request with files, the provider asks the proxy which hashes it lacks and sends contents only for those; it remembers nothing itself, so the proxy may purge its copies at any time. A 409 from the chat request (the proxy lost a file after the check) raises ChatProxyError. A media file the caller cannot read is sent as metadata only. Chat provider errors (SafetyError, MaxTokenError, TokenOverflowError, UsageLimitError) are raised again on the caller with their fields; other errors become ChatProxyError. A proxy and a caller of different versions do not share the usage_limit kind: update both.
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.
Released: Nov 29, 2026
Author/Maintainer: kiarina
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
all chat-provider-anthropic chat-provider-anthropic-vertex chat-provider-claude-code chat-provider-codex chat-provider-google chat-provider-mock chat-provider-openai chat-provider-proxy chat-proxy text-embedding-provider-google text-embedding-provider-mock text-embedding-provider-openai
agents ai chat embeddings
Development Status 4 - Beta
Intended Audience Developers
Operating System OS Independent
Programming Language Python :: 3
Topic Software Development :: Libraries :: Python Modules
Release files for kiarina-agi-text 2.47.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 317.8 kB
Release files / kiarina_agi_text-2.47.0.tar.gz
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 29, 2026.
Release files / kiarina_agi_text-2.47.0-py3-none-any.whl
Security for kiarina-agi-text 2.47.0
Both files in this release have been uploaded with provenance metadata.
With provenance kiarina_agi_text-2.47.0.tar.gz Nov 29, 2026
Attestation for kiarina_agi_text-2.47.0.tar.gz
A 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.
Release history Release notifications | RSS feed
Nov 29, 2026 2 release files Full provenance
Nov 18, 2026 2 release files Full provenance
Nov 16, 2026 2 release files Full provenance
Nov 15, 2026 2 release files Full provenance
Nov 9, 2026 2 release files Full provenance
Nov 7, 2026 2 release files Full provenance
Nov 6, 2026 2 release files Full provenance
Oct 7, 2026 2 release files Full provenance
Sep 24, 2026 2 release files Full provenance
Sep 5, 2026 2 release files Full provenance
Aug 16, 2026 2 release files Full provenance
Jul 27, 2026 2 release files Full provenance
Jul 25, 2026 2 release files Full provenance
Jul 8, 2026 2 release files Full provenance
Jul 6, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from fc0d8e6











