Metadata-Version: 2.4
Name: llm-api-adapter-zai
Version: 0.1.0
Summary: Official Z.ai GLM API package for llm-api-adapter
Author: Sergey Inozemtsev
License: MIT License
        
        Copyright (c) 2026 Sergey Inozemtsev
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/Inozem/llm_api_adapter/
Keywords: llm,zai,glm,adapter,api
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: llm-api-adapter<1.0.0,>=0.9.7
Provides-Extra: async
Requires-Dist: llm-api-adapter[async]<1.0.0,>=0.9.7; extra == "async"
Provides-Extra: httpx
Requires-Dist: llm-api-adapter[httpx]<1.0.0,>=0.9.7; extra == "httpx"
Dynamic: license-file

# llm-api-adapter-zai

Official direct Z.ai / GLM Chat Completions API support for
[llm-api-adapter](https://github.com/Inozem/llm_api_adapter/). The package
targets Core `>=0.9.7,<1.0.0` and does not install a provider SDK.

## Installation

Install through the Core package extra:

```bash
pip install "llm-api-adapter[zai]"
```

Direct installation is also supported when Core is managed separately:

```bash
pip install llm-api-adapter-zai
```

Async requests need HTTPX:

```bash
pip install "llm-api-adapter[zai,async]"
```

Synchronous requests use `requests` by default. To opt into HTTPX for sync
`chat()` and `stream_chat()`, install `"llm-api-adapter[zai,httpx]"` and pass
`transport="httpx"`.

## Quick start

```python
import os

from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter

adapter = UniversalLLMAPIAdapter(
    organization="zai",
    model="glm-5.3-flash",
    api_key=os.environ["ZAI_API_KEY"],
)

response = adapter.chat(
    messages=[UserMessage("Explain retrieval-augmented generation.")],
    max_tokens=128,
)
print(response.content)
```

## Supported model and capabilities

The package deliberately exposes one exact, verified model ID:
`glm-5.3-flash`.

| Capability | `glm-5.3-flash` |
| --- | --- |
| Text chat; sync/async streaming | Supported through the official Chat Completions endpoint |
| Application function tools | `tool_choice="auto"` only; at most 128 declarations |
| Reasoning | Core `reasoning_level` is mapped to Z.ai effort; kept separate from visible text |
| Image input | User-message URL, bytes, and data-URL forms |
| Usage | Valid provider usage only; missing or malformed usage is unavailable |
| Portable JSON Schema / Pydantic output | Unsupported; rejected before HTTP |
| Documents and generic files | Unsupported; rejected before HTTP |
| Deployments, uploads, OCR, retries, continuation, and video | Unsupported |

Unknown, retired, aliased, or unverified model IDs are not inferred. Unsupported
tool choices, parallel-tool control, provider-built-in tools, and every
`DocumentPart` URL or byte form fail locally before the transport is called.
The adapter accepts only the official endpoint and the `ZAI_API_KEY` bearer
credential.

See the main [llm-api-adapter README](https://github.com/Inozem/llm_api_adapter/#readme)
for the shared API contract and transport behavior.
