llm-api-adapter-kimi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sergey Inozemtsev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ include README.md
2
+ include LICENSE
3
+ include src/llm_api_adapter_kimi/py.typed
4
+ recursive-include src/llm_api_adapter_kimi/registry/organizations *.json
5
+
6
+ global-exclude *.py[cod]
7
+ prune **/__pycache__
8
+ prune **/.pytest_cache
9
+ global-exclude *.egg-info
10
+ prune **/*.egg-info
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-api-adapter-kimi
3
+ Version: 0.1.0
4
+ Summary: Kimi / Moonshot package for llm-api-adapter
5
+ Author: Sergey Inozemtsev
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Sergey Inozemtsev
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/Inozem/llm_api_adapter/
29
+ Keywords: llm,kimi,moonshot,adapter,api
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.10
32
+ Classifier: Programming Language :: Python :: 3.11
33
+ Classifier: Programming Language :: Python :: 3.12
34
+ Classifier: Programming Language :: Python :: 3.13
35
+ Classifier: Programming Language :: Python :: 3.14
36
+ Classifier: Typing :: Typed
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: OS Independent
39
+ Requires-Python: >=3.10
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: llm-api-adapter<1.0.0,>=0.9.5
43
+ Provides-Extra: async
44
+ Requires-Dist: llm-api-adapter[async]<1.0.0,>=0.9.5; extra == "async"
45
+ Provides-Extra: httpx
46
+ Requires-Dist: llm-api-adapter[httpx]<1.0.0,>=0.9.5; extra == "httpx"
47
+ Dynamic: license-file
48
+
49
+ # llm-api-adapter-kimi
50
+
51
+ Official direct Kimi / Moonshot Chat Completions API support for
52
+ [llm-api-adapter](https://github.com/Inozem/llm_api_adapter/). The package uses
53
+ only `POST /v1/chat/completions`; it does not install the Kimi SDK or add
54
+ provider-specific public APIs.
55
+
56
+ ## Installation
57
+
58
+ Install through the Core package extra:
59
+
60
+ ```bash
61
+ pip install "llm-api-adapter[kimi]"
62
+ ```
63
+
64
+ Direct installation is also supported when Core is managed separately:
65
+
66
+ ```bash
67
+ pip install llm-api-adapter-kimi
68
+ ```
69
+
70
+ Async requests need HTTPX:
71
+
72
+ ```bash
73
+ pip install "llm-api-adapter[kimi,async]"
74
+ ```
75
+
76
+ Synchronous `requests` remains the default. To opt into HTTPX for sync
77
+ `chat()` and `stream_chat()`, install `"llm-api-adapter[kimi,httpx]"` and pass
78
+ `transport="httpx"`.
79
+
80
+ ## Quick start
81
+
82
+ ```python
83
+ import os
84
+
85
+ from llm_api_adapter.models.messages.chat_message import UserMessage
86
+ from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter
87
+
88
+ adapter = UniversalLLMAPIAdapter(
89
+ organization="kimi",
90
+ model="kimi-k3",
91
+ api_key=os.environ["KIMI_API_KEY"],
92
+ )
93
+
94
+ response = adapter.chat(
95
+ messages=[UserMessage("Explain retrieval-augmented generation.")],
96
+ max_tokens=128,
97
+ )
98
+ print(response.content)
99
+ ```
100
+
101
+ ## Supported models and capabilities
102
+
103
+ The package deliberately exposes fixed model IDs, not moving aliases:
104
+ `kimi-k3` and `kimi-k2.6`.
105
+
106
+ | Capability | Supported models |
107
+ | --- | --- |
108
+ | Text chat; sync/async streaming; application tools; portable JSON Schema/Pydantic output; image bytes and data URIs | Both models |
109
+ | Public `ImagePart` URLs and every `DocumentPart` PDF URL or byte | Unsupported; rejected before HTTP |
110
+
111
+ `reasoning_level` is resolved automatically from registry metadata. K3 cannot
112
+ disable reasoning, so `reasoning_level="none"` warns. K2.6 maps `"none"` to
113
+ disabled thinking and every other valid level to enabled thinking. When
114
+ omitted, no thinking control is sent and Kimi's native default is preserved.
115
+ Reasoning is never mixed into visible text; use
116
+ `capture_reasoning=True` for opt-in observability.
117
+
118
+ ## History, files, and pricing
119
+
120
+ Kimi Chat Completions is stateless: `previous_response` is accepted for the
121
+ shared API but is not serialized. Send the complete `messages` history on
122
+ each turn, including assistant tool calls and `ToolMessage` results.
123
+
124
+ Image bytes are encoded as data URIs. Public image URLs and every
125
+ `DocumentPart` are rejected before transport. Kimi's Files API provides
126
+ extracted text rather than a Chat Completions attachment, so the adapter does
127
+ not upload, retain, download, extract, or delete caller files.
128
+
129
+ Cost fields use registered standard USD rates. When Kimi reports
130
+ `usage.cached_tokens`, the adapter applies cache-hit and cache-miss input
131
+ rates; without that split, it retains the standard cache-miss estimate. This
132
+ does not enable Kimi context caching, and the result is not an invoice.
133
+
134
+ Kimi maps authentication/authorization (401/403), rate-limit (429), timeout
135
+ (408/504), documented token/quota, and server failures to the matching public
136
+ `LLMAPI*Error`; other client or SSE failures become `LLMAPIClientError`.
137
+
138
+ See the main [llm-api-adapter README](https://github.com/Inozem/llm_api_adapter/#readme)
139
+ for the shared API contract, error mapping, and E2E/release documentation.
@@ -0,0 +1,91 @@
1
+ # llm-api-adapter-kimi
2
+
3
+ Official direct Kimi / Moonshot Chat Completions API support for
4
+ [llm-api-adapter](https://github.com/Inozem/llm_api_adapter/). The package uses
5
+ only `POST /v1/chat/completions`; it does not install the Kimi SDK or add
6
+ provider-specific public APIs.
7
+
8
+ ## Installation
9
+
10
+ Install through the Core package extra:
11
+
12
+ ```bash
13
+ pip install "llm-api-adapter[kimi]"
14
+ ```
15
+
16
+ Direct installation is also supported when Core is managed separately:
17
+
18
+ ```bash
19
+ pip install llm-api-adapter-kimi
20
+ ```
21
+
22
+ Async requests need HTTPX:
23
+
24
+ ```bash
25
+ pip install "llm-api-adapter[kimi,async]"
26
+ ```
27
+
28
+ Synchronous `requests` remains the default. To opt into HTTPX for sync
29
+ `chat()` and `stream_chat()`, install `"llm-api-adapter[kimi,httpx]"` and pass
30
+ `transport="httpx"`.
31
+
32
+ ## Quick start
33
+
34
+ ```python
35
+ import os
36
+
37
+ from llm_api_adapter.models.messages.chat_message import UserMessage
38
+ from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter
39
+
40
+ adapter = UniversalLLMAPIAdapter(
41
+ organization="kimi",
42
+ model="kimi-k3",
43
+ api_key=os.environ["KIMI_API_KEY"],
44
+ )
45
+
46
+ response = adapter.chat(
47
+ messages=[UserMessage("Explain retrieval-augmented generation.")],
48
+ max_tokens=128,
49
+ )
50
+ print(response.content)
51
+ ```
52
+
53
+ ## Supported models and capabilities
54
+
55
+ The package deliberately exposes fixed model IDs, not moving aliases:
56
+ `kimi-k3` and `kimi-k2.6`.
57
+
58
+ | Capability | Supported models |
59
+ | --- | --- |
60
+ | Text chat; sync/async streaming; application tools; portable JSON Schema/Pydantic output; image bytes and data URIs | Both models |
61
+ | Public `ImagePart` URLs and every `DocumentPart` PDF URL or byte | Unsupported; rejected before HTTP |
62
+
63
+ `reasoning_level` is resolved automatically from registry metadata. K3 cannot
64
+ disable reasoning, so `reasoning_level="none"` warns. K2.6 maps `"none"` to
65
+ disabled thinking and every other valid level to enabled thinking. When
66
+ omitted, no thinking control is sent and Kimi's native default is preserved.
67
+ Reasoning is never mixed into visible text; use
68
+ `capture_reasoning=True` for opt-in observability.
69
+
70
+ ## History, files, and pricing
71
+
72
+ Kimi Chat Completions is stateless: `previous_response` is accepted for the
73
+ shared API but is not serialized. Send the complete `messages` history on
74
+ each turn, including assistant tool calls and `ToolMessage` results.
75
+
76
+ Image bytes are encoded as data URIs. Public image URLs and every
77
+ `DocumentPart` are rejected before transport. Kimi's Files API provides
78
+ extracted text rather than a Chat Completions attachment, so the adapter does
79
+ not upload, retain, download, extract, or delete caller files.
80
+
81
+ Cost fields use registered standard USD rates. When Kimi reports
82
+ `usage.cached_tokens`, the adapter applies cache-hit and cache-miss input
83
+ rates; without that split, it retains the standard cache-miss estimate. This
84
+ does not enable Kimi context caching, and the result is not an invoice.
85
+
86
+ Kimi maps authentication/authorization (401/403), rate-limit (429), timeout
87
+ (408/504), documented token/quota, and server failures to the matching public
88
+ `LLMAPI*Error`; other client or SSE failures become `LLMAPIClientError`.
89
+
90
+ See the main [llm-api-adapter README](https://github.com/Inozem/llm_api_adapter/#readme)
91
+ for the shared API contract, error mapping, and E2E/release documentation.
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "llm-api-adapter-kimi"
7
+ version = "0.1.0"
8
+ description = "Kimi / Moonshot package for llm-api-adapter"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {file = "LICENSE"}
12
+ authors = [{name = "Sergey Inozemtsev"}]
13
+ keywords = ["llm", "kimi", "moonshot", "adapter", "api"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
21
+ "Typing :: Typed",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ ]
25
+ dependencies = ["llm-api-adapter>=0.9.5,<1.0.0"]
26
+
27
+ [project.optional-dependencies]
28
+ async = ["llm-api-adapter[async]>=0.9.5,<1.0.0"]
29
+ httpx = ["llm-api-adapter[httpx]>=0.9.5,<1.0.0"]
30
+
31
+ [project.entry-points."llm_api_adapter.organizations"]
32
+ kimi = "llm_api_adapter_kimi.plugin:PLUGIN"
33
+
34
+ [project.urls]
35
+ Repository = "https://github.com/Inozem/llm_api_adapter/"
36
+
37
+ [tool.setuptools.package-dir]
38
+ "" = "src"
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["src"]
42
+ include = ["llm_api_adapter_kimi*"]
43
+ exclude = ["tests*", "*/tests*"]
44
+
45
+ [tool.setuptools]
46
+ include-package-data = true
47
+
48
+ [tool.setuptools.package-data]
49
+ "llm_api_adapter_kimi" = ["py.typed", "registry/organizations/*.json"]
50
+
51
+ [tool.pytest.ini_options]
52
+ markers = [
53
+ "unit: unit tests (no network, pure logic, mocks)",
54
+ "integration: integration tests (mocked HTTP, no real organizations)",
55
+ "e2e: end-to-end tests (real LLM organizations)",
56
+ "e2e_builtin: aggregate end-to-end tests for all built-in core organizations",
57
+ "e2e_openai: end-to-end tests for the built-in OpenAI organization",
58
+ "e2e_anthropic: end-to-end tests for the built-in Anthropic organization",
59
+ "e2e_google: end-to-end tests for the built-in Google organization",
60
+ "e2e_mistral: end-to-end tests for the external Mistral organization package",
61
+ "e2e_xai: end-to-end tests for the external xAI organization package",
62
+ "e2e_kimi: end-to-end tests for the external Kimi organization package",
63
+ "e2e_qwen: end-to-end tests for the external Qwen organization package",
64
+ "e2e_feature(name): capability required by a parametrized Core E2E scenario",
65
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Kimi / Moonshot support for :mod:`llm_api_adapter`."""
2
+
3
+ __all__: list[str] = []