iflow-search-openapi 0.1.0a0__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,47 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ .coverage.*
12
+ htmlcov/
13
+ *.egg-info/
14
+ *.egg
15
+
16
+ # Build artifacts
17
+ build/
18
+ dist/
19
+ *.whl
20
+ *.tar.gz
21
+
22
+ # Virtual environments
23
+ .venv/
24
+ venv/
25
+ env/
26
+ ENV/
27
+
28
+ # Editor / OS
29
+ .vscode/
30
+ .idea/
31
+ .DS_Store
32
+ *.swp
33
+
34
+ # Secrets — never commit
35
+ .env
36
+ .env.*
37
+ *.pem
38
+ *.key
39
+ api-keys.env
40
+
41
+ # uv
42
+ .uv/
43
+ uv.lock
44
+
45
+ # Local Claude Code working instructions — not for the public repo
46
+ CLAUDE.md
47
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 iFlow Search SDK contributors
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,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: iflow-search-openapi
3
+ Version: 0.1.0a0
4
+ Summary: OpenAPI 3.1 tool server for iFlow Search (心流搜索) — drop-in for Open WebUI, Coze, and other platforms that consume OpenAPI tool catalogues.
5
+ Project-URL: Homepage, https://platform.iflow.cn/
6
+ Project-URL: Documentation, https://platform.iflow.cn/docs/
7
+ Project-URL: Repository, https://github.com/zhengyanglsun/iflow-search-py
8
+ Project-URL: Issues, https://github.com/zhengyanglsun/iflow-search-py/issues
9
+ Author: iFlow Search SDK contributors
10
+ License: MIT License
11
+
12
+ Copyright (c) 2026 iFlow Search SDK contributors
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: ai,coze,iflow,llm,open-webui,openapi,search,tools
33
+ Classifier: Development Status :: 3 - Alpha
34
+ Classifier: Framework :: FastAPI
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Topic :: Internet :: WWW/HTTP
45
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
46
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
47
+ Classifier: Typing :: Typed
48
+ Requires-Python: >=3.10
49
+ Requires-Dist: fastapi<1.0,>=0.115
50
+ Requires-Dist: iflow-search<0.2,>=0.1.0a0
51
+ Requires-Dist: pydantic<3.0,>=2.7
52
+ Requires-Dist: uvicorn<1.0,>=0.30
53
+ Provides-Extra: dev
54
+ Requires-Dist: httpx<1.0,>=0.27; extra == 'dev'
55
+ Requires-Dist: mypy>=1.10; extra == 'dev'
56
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
57
+ Requires-Dist: pytest>=8; extra == 'dev'
58
+ Requires-Dist: ruff>=0.4; extra == 'dev'
59
+ Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'dev'
60
+ Description-Content-Type: text/markdown
61
+
62
+ # iflow-search-openapi
63
+
64
+ OpenAPI 3.1 tool server for **iFlow Search (心流搜索)** — exposes `iflow_web_search`, `iflow_image_search`, and `iflow_web_fetch` over plain HTTP so platforms that consume OpenAPI tool catalogues (Open WebUI, Coze, …) can wire them in directly.
65
+
66
+ - **Core SDK:** [`iflow-search`](https://pypi.org/project/iflow-search/) — this package wraps it; do not skip installing it (it is a transitive dependency, so `pip install` handles it).
67
+ - **Sibling adapters:** [`iflow-search-mcp`](https://pypi.org/project/iflow-search-mcp/) (MCP stdio server), [`iflow-search-langchain`](https://pypi.org/project/iflow-search-langchain/) (LangChain tools).
68
+ - **API docs:** <https://platform.iflow.cn/docs/>
69
+ - **Status:** alpha pre-release (`0.1.0a0`). Requires `pip install --pre`.
70
+
71
+ ## Install
72
+
73
+ ```bash
74
+ pip install --pre iflow-search-openapi
75
+ ```
76
+
77
+ `--pre` is required while the version is still a PEP 440 prerelease.
78
+
79
+ ## Run
80
+
81
+ ```bash
82
+ export IFLOW_API_KEY="your-iflow-api-key"
83
+ iflow-search-openapi
84
+ ```
85
+
86
+ Output (stderr):
87
+
88
+ ```
89
+ [iflow-search-openapi] v0.1.0a0 listening on http://127.0.0.1:8787 — bearer auth DISABLED (open mode)
90
+ ```
91
+
92
+ By default the server binds **`127.0.0.1:8787`** — local-only. Set `IFLOW_OPENAPI_HOST=0.0.0.0` to expose it to a LAN or a container network. See [Configuration](#configuration) for the full env list.
93
+
94
+ ## Endpoints
95
+
96
+ | Method | Path | Description |
97
+ |---|---|---|
98
+ | `GET` | `/health` | Liveness probe — `{"ok": true, "version": "..."}` |
99
+ | `GET` | `/openapi.json` | OpenAPI 3.1 schema (auto-generated from Pydantic models) |
100
+ | `POST` | `/tools/iflow_web_search` | `{"query": "...", "count": 3}` |
101
+ | `POST` | `/tools/iflow_image_search` | `{"query": "...", "count": 3}` |
102
+ | `POST` | `/tools/iflow_web_fetch` | `{"url": "https://example.com"}` |
103
+
104
+ ### Success envelope
105
+
106
+ ```json
107
+ {
108
+ "ok": true,
109
+ "data": {
110
+ "query": "latest LLM benchmarks",
111
+ "results": [
112
+ {"title": "...", "url": "https://...", "snippet": "...", "position": 1}
113
+ ],
114
+ "took_ms": 142
115
+ }
116
+ }
117
+ ```
118
+
119
+ Field names are **snake_case**. The core SDK's `raw` (upstream envelope) is excluded by default — it bloats LLM context for fields the model cannot act on.
120
+
121
+ ### Error envelope
122
+
123
+ ```json
124
+ {
125
+ "ok": false,
126
+ "error": {
127
+ "code": "business_rate_limited",
128
+ "message": "Rate limit exceeded.",
129
+ "status_code": 429
130
+ }
131
+ }
132
+ ```
133
+
134
+ `code` is a stable string; switch on it (not on HTTP status alone) for retry/backoff decisions. The full code table is in [`docs/design/python-openapi-design.md` §8.3](https://github.com/zhengyanglsun/iflow-search-py/blob/main/docs/design/python-openapi-design.md).
135
+
136
+ ## Use with Open WebUI
137
+
138
+ 1. Run `iflow-search-openapi` somewhere Open WebUI can reach (`http://your-host:8787`).
139
+ 2. In Open WebUI → **Workspace → Tools → Add Tool** (the "OpenAPI Servers" entry), paste `http://your-host:8787/openapi.json`.
140
+ 3. If you set `IFLOW_OPENAPI_AUTH_TOKEN`, Open WebUI will prompt for it when importing.
141
+ 4. Open WebUI imports the three tools; assign them to a model/conversation as usual.
142
+
143
+ If Open WebUI runs in a browser on a different origin from this server, set `IFLOW_OPENAPI_CORS_ORIGIN=https://your-open-webui-host`.
144
+
145
+ ## Use with Coze
146
+
147
+ 1. Run `iflow-search-openapi` somewhere Coze can reach.
148
+ 2. Coze → **Plugins → Create plugin → Import from OpenAPI** → URL `http://your-host:8787/openapi.json`.
149
+ 3. Provide the bearer token (`IFLOW_OPENAPI_AUTH_TOKEN`) when prompted.
150
+ 4. The three tools appear as plugin actions; attach to a bot as usual.
151
+
152
+ ## Authentication
153
+
154
+ Two distinct credentials:
155
+
156
+ | Credential | Direction | Source |
157
+ |---|---|---|
158
+ | `IFLOW_API_KEY` | this server → iFlow API | env, required |
159
+ | `IFLOW_OPENAPI_AUTH_TOKEN` | external client → this server | env, optional |
160
+
161
+ When `IFLOW_OPENAPI_AUTH_TOKEN` is **unset**, the server is open: any caller that can reach the socket can invoke the tools. Intended for local dev or behind a private network / reverse proxy.
162
+
163
+ When **set**, all routes except `/health` require `Authorization: Bearer <token>`. The compare is constant-time. `/openapi.json` is also gated so the schema (which advertises the server as an iFlow proxy) stays behind the bearer.
164
+
165
+ `IFLOW_API_KEY` is **never** echoed in any response, log line, OpenAPI schema, or startup banner — only its *presence* is implied by the server having started successfully.
166
+
167
+ ## Configuration
168
+
169
+ All configuration is via environment variables. **No `.env` loader. No CLI flags. No config file.**
170
+
171
+ | Variable | Required | Default | Notes |
172
+ |---|---|---|---|
173
+ | `IFLOW_API_KEY` | yes | — | iFlow API key. Read once at startup, never echoed. |
174
+ | `IFLOW_BASE_URL` | no | core default | Override iFlow API base URL (staging/proxy). |
175
+ | `IFLOW_TIMEOUT_MS` | no | `30000` | Per-request timeout in milliseconds. |
176
+ | `IFLOW_OPENAPI_HOST` | no | `127.0.0.1` | Bind address. Use `0.0.0.0` for LAN/container exposure. |
177
+ | `IFLOW_OPENAPI_PORT` | no | `8787` | Bind port. |
178
+ | `IFLOW_OPENAPI_AUTH_TOKEN` | no | unset (open mode) | Bearer token required from external callers when set. |
179
+ | `IFLOW_OPENAPI_CORS_ORIGIN` | no | unset (no CORS) | `*` or an exact origin (`https://host[:port]`). |
180
+ | `IFLOW_OPENAPI_CLIENT` | no | unset | Free-form host name (e.g. `open-webui`). Banner only — not on the wire. |
181
+
182
+ ### Heroku / App Engine / fly.io — bridging `PORT`
183
+
184
+ This package uses `IFLOW_OPENAPI_PORT` instead of the generic `PORT` so a platform's auto-injected port can't silently take over the bind. If your platform requires `PORT`, bridge it in your start command:
185
+
186
+ ```bash
187
+ IFLOW_OPENAPI_PORT="$PORT" IFLOW_OPENAPI_HOST=0.0.0.0 iflow-search-openapi
188
+ ```
189
+
190
+ ## CORS
191
+
192
+ `IFLOW_OPENAPI_CORS_ORIGIN`:
193
+
194
+ - **unset** — no CORS headers; server is intended for same-origin or server-to-server use.
195
+ - `*` — wildcard allow-origin.
196
+ - `http(s)://host[:port]` — exact-origin allow.
197
+
198
+ Anything with a path, query, fragment, or non-printable character is rejected at startup with `ConfigError` and exit code 1 — header-injection guard.
199
+
200
+ Preflight (`OPTIONS`) short-circuits to 204 before the bearer check, so browser-side tool importers (Open WebUI) can complete preflight without a token.
201
+
202
+ `Access-Control-Allow-Headers` is `Content-Type, Authorization, X-Session-Id`. `X-Session-Id` is allowed for Open WebUI compatibility; the adapter does not read it.
203
+
204
+ ## Attribution
205
+
206
+ The adapter does not construct any `Authorization`, `IFlow-*`, or `User-Agent` header itself — that's the core SDK's job. Outbound requests to iFlow carry:
207
+
208
+ | Header | Value |
209
+ |---|---|
210
+ | `Authorization` | `Bearer <IFLOW_API_KEY>` |
211
+ | `IFlow-Source` | `openapi` |
212
+ | `IFlow-Integration` | `iflow-search-openapi` |
213
+ | `IFlow-Integration-Version` | this package's `__version__` |
214
+ | `User-Agent` | `iflow-search-openapi/<version>` |
215
+
216
+ `IFLOW_OPENAPI_CLIENT` is **not** forwarded as a wire header (that namespace belongs to MCP transports). It appears in the startup banner only.
217
+
218
+ ## What's not included in v0.1.0a0
219
+
220
+ - TLS termination — put a reverse proxy in front.
221
+ - Streaming / SSE / WebSocket — iFlow Search is request/response.
222
+ - Per-platform packages (no `iflow-search-open-webui`, no `iflow-search-coze`).
223
+ - A public Python embedding API (`build_app(...)` is underscore-prefixed and not part of the contract).
224
+ - `.env` file loading, a CLI flag for the API key, or any config file.
225
+ - Per-request access logs — operators put a reverse proxy in front for those.
226
+
227
+ ## Public Python surface
228
+
229
+ ```python
230
+ from iflow_search_openapi import __version__
231
+ ```
232
+
233
+ That is the only supported import in MVP. Internal modules (`_app`, `_routes`, `_auth`, etc.) are underscore-prefixed; they may be reorganised without notice. The stable contract is the **HTTP surface**, not the Python surface.
234
+
235
+ ## Local development
236
+
237
+ From `packages/iflow-search-openapi/`:
238
+
239
+ ```bash
240
+ python -m pip install -e ".[dev]"
241
+ python -m pytest -q
242
+ python -m ruff check .
243
+ python -m mypy src/iflow_search_openapi
244
+ python -m build
245
+ ```
246
+
247
+ ## Real-API smoke
248
+
249
+ ```bash
250
+ cd packages/iflow-search-openapi
251
+ export IFLOW_API_KEY="your-api-key"
252
+ export IFLOW_OPENAPI_SMOKE=1
253
+ python scripts/smoke_real_api.py
254
+ ```
255
+
256
+ The script:
257
+
258
+ - Is **opt-in** — without `IFLOW_OPENAPI_SMOKE=1` it refuses to call the live API.
259
+ - Reads `IFLOW_API_KEY` from the environment only — never from disk.
260
+ - Redacts the key in all log output.
261
+ - Does not write any file.
262
+
263
+ ## License
264
+
265
+ [MIT](./LICENSE)
@@ -0,0 +1,204 @@
1
+ # iflow-search-openapi
2
+
3
+ OpenAPI 3.1 tool server for **iFlow Search (心流搜索)** — exposes `iflow_web_search`, `iflow_image_search`, and `iflow_web_fetch` over plain HTTP so platforms that consume OpenAPI tool catalogues (Open WebUI, Coze, …) can wire them in directly.
4
+
5
+ - **Core SDK:** [`iflow-search`](https://pypi.org/project/iflow-search/) — this package wraps it; do not skip installing it (it is a transitive dependency, so `pip install` handles it).
6
+ - **Sibling adapters:** [`iflow-search-mcp`](https://pypi.org/project/iflow-search-mcp/) (MCP stdio server), [`iflow-search-langchain`](https://pypi.org/project/iflow-search-langchain/) (LangChain tools).
7
+ - **API docs:** <https://platform.iflow.cn/docs/>
8
+ - **Status:** alpha pre-release (`0.1.0a0`). Requires `pip install --pre`.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pip install --pre iflow-search-openapi
14
+ ```
15
+
16
+ `--pre` is required while the version is still a PEP 440 prerelease.
17
+
18
+ ## Run
19
+
20
+ ```bash
21
+ export IFLOW_API_KEY="your-iflow-api-key"
22
+ iflow-search-openapi
23
+ ```
24
+
25
+ Output (stderr):
26
+
27
+ ```
28
+ [iflow-search-openapi] v0.1.0a0 listening on http://127.0.0.1:8787 — bearer auth DISABLED (open mode)
29
+ ```
30
+
31
+ By default the server binds **`127.0.0.1:8787`** — local-only. Set `IFLOW_OPENAPI_HOST=0.0.0.0` to expose it to a LAN or a container network. See [Configuration](#configuration) for the full env list.
32
+
33
+ ## Endpoints
34
+
35
+ | Method | Path | Description |
36
+ |---|---|---|
37
+ | `GET` | `/health` | Liveness probe — `{"ok": true, "version": "..."}` |
38
+ | `GET` | `/openapi.json` | OpenAPI 3.1 schema (auto-generated from Pydantic models) |
39
+ | `POST` | `/tools/iflow_web_search` | `{"query": "...", "count": 3}` |
40
+ | `POST` | `/tools/iflow_image_search` | `{"query": "...", "count": 3}` |
41
+ | `POST` | `/tools/iflow_web_fetch` | `{"url": "https://example.com"}` |
42
+
43
+ ### Success envelope
44
+
45
+ ```json
46
+ {
47
+ "ok": true,
48
+ "data": {
49
+ "query": "latest LLM benchmarks",
50
+ "results": [
51
+ {"title": "...", "url": "https://...", "snippet": "...", "position": 1}
52
+ ],
53
+ "took_ms": 142
54
+ }
55
+ }
56
+ ```
57
+
58
+ Field names are **snake_case**. The core SDK's `raw` (upstream envelope) is excluded by default — it bloats LLM context for fields the model cannot act on.
59
+
60
+ ### Error envelope
61
+
62
+ ```json
63
+ {
64
+ "ok": false,
65
+ "error": {
66
+ "code": "business_rate_limited",
67
+ "message": "Rate limit exceeded.",
68
+ "status_code": 429
69
+ }
70
+ }
71
+ ```
72
+
73
+ `code` is a stable string; switch on it (not on HTTP status alone) for retry/backoff decisions. The full code table is in [`docs/design/python-openapi-design.md` §8.3](https://github.com/zhengyanglsun/iflow-search-py/blob/main/docs/design/python-openapi-design.md).
74
+
75
+ ## Use with Open WebUI
76
+
77
+ 1. Run `iflow-search-openapi` somewhere Open WebUI can reach (`http://your-host:8787`).
78
+ 2. In Open WebUI → **Workspace → Tools → Add Tool** (the "OpenAPI Servers" entry), paste `http://your-host:8787/openapi.json`.
79
+ 3. If you set `IFLOW_OPENAPI_AUTH_TOKEN`, Open WebUI will prompt for it when importing.
80
+ 4. Open WebUI imports the three tools; assign them to a model/conversation as usual.
81
+
82
+ If Open WebUI runs in a browser on a different origin from this server, set `IFLOW_OPENAPI_CORS_ORIGIN=https://your-open-webui-host`.
83
+
84
+ ## Use with Coze
85
+
86
+ 1. Run `iflow-search-openapi` somewhere Coze can reach.
87
+ 2. Coze → **Plugins → Create plugin → Import from OpenAPI** → URL `http://your-host:8787/openapi.json`.
88
+ 3. Provide the bearer token (`IFLOW_OPENAPI_AUTH_TOKEN`) when prompted.
89
+ 4. The three tools appear as plugin actions; attach to a bot as usual.
90
+
91
+ ## Authentication
92
+
93
+ Two distinct credentials:
94
+
95
+ | Credential | Direction | Source |
96
+ |---|---|---|
97
+ | `IFLOW_API_KEY` | this server → iFlow API | env, required |
98
+ | `IFLOW_OPENAPI_AUTH_TOKEN` | external client → this server | env, optional |
99
+
100
+ When `IFLOW_OPENAPI_AUTH_TOKEN` is **unset**, the server is open: any caller that can reach the socket can invoke the tools. Intended for local dev or behind a private network / reverse proxy.
101
+
102
+ When **set**, all routes except `/health` require `Authorization: Bearer <token>`. The compare is constant-time. `/openapi.json` is also gated so the schema (which advertises the server as an iFlow proxy) stays behind the bearer.
103
+
104
+ `IFLOW_API_KEY` is **never** echoed in any response, log line, OpenAPI schema, or startup banner — only its *presence* is implied by the server having started successfully.
105
+
106
+ ## Configuration
107
+
108
+ All configuration is via environment variables. **No `.env` loader. No CLI flags. No config file.**
109
+
110
+ | Variable | Required | Default | Notes |
111
+ |---|---|---|---|
112
+ | `IFLOW_API_KEY` | yes | — | iFlow API key. Read once at startup, never echoed. |
113
+ | `IFLOW_BASE_URL` | no | core default | Override iFlow API base URL (staging/proxy). |
114
+ | `IFLOW_TIMEOUT_MS` | no | `30000` | Per-request timeout in milliseconds. |
115
+ | `IFLOW_OPENAPI_HOST` | no | `127.0.0.1` | Bind address. Use `0.0.0.0` for LAN/container exposure. |
116
+ | `IFLOW_OPENAPI_PORT` | no | `8787` | Bind port. |
117
+ | `IFLOW_OPENAPI_AUTH_TOKEN` | no | unset (open mode) | Bearer token required from external callers when set. |
118
+ | `IFLOW_OPENAPI_CORS_ORIGIN` | no | unset (no CORS) | `*` or an exact origin (`https://host[:port]`). |
119
+ | `IFLOW_OPENAPI_CLIENT` | no | unset | Free-form host name (e.g. `open-webui`). Banner only — not on the wire. |
120
+
121
+ ### Heroku / App Engine / fly.io — bridging `PORT`
122
+
123
+ This package uses `IFLOW_OPENAPI_PORT` instead of the generic `PORT` so a platform's auto-injected port can't silently take over the bind. If your platform requires `PORT`, bridge it in your start command:
124
+
125
+ ```bash
126
+ IFLOW_OPENAPI_PORT="$PORT" IFLOW_OPENAPI_HOST=0.0.0.0 iflow-search-openapi
127
+ ```
128
+
129
+ ## CORS
130
+
131
+ `IFLOW_OPENAPI_CORS_ORIGIN`:
132
+
133
+ - **unset** — no CORS headers; server is intended for same-origin or server-to-server use.
134
+ - `*` — wildcard allow-origin.
135
+ - `http(s)://host[:port]` — exact-origin allow.
136
+
137
+ Anything with a path, query, fragment, or non-printable character is rejected at startup with `ConfigError` and exit code 1 — header-injection guard.
138
+
139
+ Preflight (`OPTIONS`) short-circuits to 204 before the bearer check, so browser-side tool importers (Open WebUI) can complete preflight without a token.
140
+
141
+ `Access-Control-Allow-Headers` is `Content-Type, Authorization, X-Session-Id`. `X-Session-Id` is allowed for Open WebUI compatibility; the adapter does not read it.
142
+
143
+ ## Attribution
144
+
145
+ The adapter does not construct any `Authorization`, `IFlow-*`, or `User-Agent` header itself — that's the core SDK's job. Outbound requests to iFlow carry:
146
+
147
+ | Header | Value |
148
+ |---|---|
149
+ | `Authorization` | `Bearer <IFLOW_API_KEY>` |
150
+ | `IFlow-Source` | `openapi` |
151
+ | `IFlow-Integration` | `iflow-search-openapi` |
152
+ | `IFlow-Integration-Version` | this package's `__version__` |
153
+ | `User-Agent` | `iflow-search-openapi/<version>` |
154
+
155
+ `IFLOW_OPENAPI_CLIENT` is **not** forwarded as a wire header (that namespace belongs to MCP transports). It appears in the startup banner only.
156
+
157
+ ## What's not included in v0.1.0a0
158
+
159
+ - TLS termination — put a reverse proxy in front.
160
+ - Streaming / SSE / WebSocket — iFlow Search is request/response.
161
+ - Per-platform packages (no `iflow-search-open-webui`, no `iflow-search-coze`).
162
+ - A public Python embedding API (`build_app(...)` is underscore-prefixed and not part of the contract).
163
+ - `.env` file loading, a CLI flag for the API key, or any config file.
164
+ - Per-request access logs — operators put a reverse proxy in front for those.
165
+
166
+ ## Public Python surface
167
+
168
+ ```python
169
+ from iflow_search_openapi import __version__
170
+ ```
171
+
172
+ That is the only supported import in MVP. Internal modules (`_app`, `_routes`, `_auth`, etc.) are underscore-prefixed; they may be reorganised without notice. The stable contract is the **HTTP surface**, not the Python surface.
173
+
174
+ ## Local development
175
+
176
+ From `packages/iflow-search-openapi/`:
177
+
178
+ ```bash
179
+ python -m pip install -e ".[dev]"
180
+ python -m pytest -q
181
+ python -m ruff check .
182
+ python -m mypy src/iflow_search_openapi
183
+ python -m build
184
+ ```
185
+
186
+ ## Real-API smoke
187
+
188
+ ```bash
189
+ cd packages/iflow-search-openapi
190
+ export IFLOW_API_KEY="your-api-key"
191
+ export IFLOW_OPENAPI_SMOKE=1
192
+ python scripts/smoke_real_api.py
193
+ ```
194
+
195
+ The script:
196
+
197
+ - Is **opt-in** — without `IFLOW_OPENAPI_SMOKE=1` it refuses to call the live API.
198
+ - Reads `IFLOW_API_KEY` from the environment only — never from disk.
199
+ - Redacts the key in all log output.
200
+ - Does not write any file.
201
+
202
+ ## License
203
+
204
+ [MIT](./LICENSE)
@@ -0,0 +1,92 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "iflow-search-openapi"
7
+ version = "0.1.0a0"
8
+ description = "OpenAPI 3.1 tool server for iFlow Search (心流搜索) — drop-in for Open WebUI, Coze, and other platforms that consume OpenAPI tool catalogues."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "iFlow Search SDK contributors" }]
13
+ keywords = ["iflow", "search", "openapi", "open-webui", "coze", "ai", "llm", "tools"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Framework :: FastAPI",
26
+ "Topic :: Internet :: WWW/HTTP",
27
+ "Topic :: Internet :: WWW/HTTP :: HTTP Servers",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ "Typing :: Typed",
30
+ ]
31
+ dependencies = [
32
+ "iflow-search>=0.1.0a0,<0.2",
33
+ "fastapi>=0.115,<1.0",
34
+ "uvicorn>=0.30,<1.0",
35
+ "pydantic>=2.7,<3.0",
36
+ ]
37
+
38
+ [project.urls]
39
+ Homepage = "https://platform.iflow.cn/"
40
+ Documentation = "https://platform.iflow.cn/docs/"
41
+ Repository = "https://github.com/zhengyanglsun/iflow-search-py"
42
+ Issues = "https://github.com/zhengyanglsun/iflow-search-py/issues"
43
+
44
+ [project.scripts]
45
+ iflow-search-openapi = "iflow_search_openapi._bin:main"
46
+
47
+ [project.optional-dependencies]
48
+ dev = [
49
+ "pytest>=8",
50
+ "pytest-asyncio>=0.23",
51
+ "httpx>=0.27,<1.0",
52
+ "ruff>=0.4",
53
+ "mypy>=1.10",
54
+ "tomli>=2.0; python_version<'3.11'",
55
+ ]
56
+
57
+ [tool.hatch.build.targets.wheel]
58
+ packages = ["src/iflow_search_openapi"]
59
+
60
+ [tool.hatch.build.targets.sdist]
61
+ include = [
62
+ "/src",
63
+ "/README.md",
64
+ "/LICENSE",
65
+ "/pyproject.toml",
66
+ ]
67
+ exclude = [
68
+ "/tests",
69
+ "/scripts",
70
+ "/.pytest_cache",
71
+ "/__pycache__",
72
+ ]
73
+
74
+ [tool.pytest.ini_options]
75
+ minversion = "8.0"
76
+ testpaths = ["tests"]
77
+ asyncio_mode = "strict"
78
+ addopts = "-ra --strict-markers"
79
+
80
+ [tool.ruff]
81
+ line-length = 100
82
+ target-version = "py310"
83
+
84
+ [tool.ruff.lint]
85
+ select = ["E", "F", "W", "I", "UP", "B", "SIM"]
86
+ ignore = ["E501"]
87
+
88
+ [tool.mypy]
89
+ python_version = "3.10"
90
+ strict = true
91
+ warn_unused_ignores = true
92
+ files = ["src/iflow_search_openapi"]
@@ -0,0 +1,12 @@
1
+ """iflow-search-openapi — OpenAPI 3.1 tool server for iFlow Search.
2
+
3
+ Only ``__version__`` is part of the supported public Python surface
4
+ (design §11). All other modules are underscore-prefixed and internal; the
5
+ user-facing entry point is the ``iflow-search-openapi`` console script.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from ._version import __version__
11
+
12
+ __all__ = ("__version__",)