interfaze 1.0.1__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.
Files changed (36) hide show
  1. interfaze-1.0.1/.github/workflows/ci.yml +61 -0
  2. interfaze-1.0.1/.github/workflows/publish.yml +59 -0
  3. interfaze-1.0.1/.github/workflows/qa-live.yml +29 -0
  4. interfaze-1.0.1/.gitignore +218 -0
  5. interfaze-1.0.1/LICENSE +21 -0
  6. interfaze-1.0.1/PKG-INFO +168 -0
  7. interfaze-1.0.1/README.md +141 -0
  8. interfaze-1.0.1/pyproject.toml +64 -0
  9. interfaze-1.0.1/scripts/qa_live.py +254 -0
  10. interfaze-1.0.1/src/interfaze/__init__.py +69 -0
  11. interfaze-1.0.1/src/interfaze/_chat.py +284 -0
  12. interfaze-1.0.1/src/interfaze/_client.py +108 -0
  13. interfaze-1.0.1/src/interfaze/_constants.py +48 -0
  14. interfaze-1.0.1/src/interfaze/_errors.py +9 -0
  15. interfaze-1.0.1/src/interfaze/_guard.py +21 -0
  16. interfaze-1.0.1/src/interfaze/_inputs.py +112 -0
  17. interfaze-1.0.1/src/interfaze/_schema.py +30 -0
  18. interfaze-1.0.1/src/interfaze/_stream.py +323 -0
  19. interfaze-1.0.1/src/interfaze/_tasks.py +110 -0
  20. interfaze-1.0.1/src/interfaze/_types.py +57 -0
  21. interfaze-1.0.1/src/interfaze/langchain.py +220 -0
  22. interfaze-1.0.1/src/interfaze/py.typed +0 -0
  23. interfaze-1.0.1/tests/assets.py +18 -0
  24. interfaze-1.0.1/tests/conftest.py +207 -0
  25. interfaze-1.0.1/tests/test_async.py +90 -0
  26. interfaze-1.0.1/tests/test_chat.py +297 -0
  27. interfaze-1.0.1/tests/test_compliance.py +83 -0
  28. interfaze-1.0.1/tests/test_errors.py +198 -0
  29. interfaze-1.0.1/tests/test_guard.py +39 -0
  30. interfaze-1.0.1/tests/test_inputs_and_client.py +185 -0
  31. interfaze-1.0.1/tests/test_langchain.py +183 -0
  32. interfaze-1.0.1/tests/test_models.py +41 -0
  33. interfaze-1.0.1/tests/test_schema.py +65 -0
  34. interfaze-1.0.1/tests/test_stream.py +270 -0
  35. interfaze-1.0.1/tests/test_tasks.py +186 -0
  36. interfaze-1.0.1/uv.lock +2279 -0
@@ -0,0 +1,61 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ test:
14
+ name: test (py${{ matrix.python-version }})
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: astral-sh/setup-uv@v6
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ enable-cache: true
26
+ - name: Install (all extras)
27
+ run: uv sync --all-extras
28
+ - name: Lint (ruff)
29
+ run: uv run ruff check src tests scripts
30
+ - name: Type check (mypy --strict)
31
+ if: matrix.python-version == '3.12'
32
+ run: uv run mypy
33
+ - name: Unit tests
34
+ run: uv run pytest -q
35
+
36
+ test-core-py39:
37
+ name: test (py3.9, core only)
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: astral-sh/setup-uv@v6
42
+ with:
43
+ python-version: "3.9"
44
+ enable-cache: true
45
+ # langchain-openai is gated python_version>='3.10', so it's skipped on 3.9 and its tests no-op.
46
+ - name: Install (dev extras; langchain skipped on 3.9)
47
+ run: uv sync --extra dev
48
+ - name: Lint (ruff)
49
+ run: uv run ruff check src tests scripts
50
+ - name: Unit tests
51
+ run: uv run pytest -q
52
+
53
+ secret-scan:
54
+ name: secret scan (gitleaks)
55
+ runs-on: ubuntu-latest
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+ - name: Scan working tree for leaked tokens/secrets
59
+ run: |
60
+ curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v8.21.2/gitleaks_8.21.2_linux_x64.tar.gz" | tar -xz gitleaks
61
+ ./gitleaks dir . --redact --no-banner
@@ -0,0 +1,59 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: astral-sh/setup-uv@v6
16
+ with:
17
+ python-version: "3.12"
18
+ - name: Build sdist + wheel
19
+ run: uv build
20
+ - name: Verify metadata
21
+ run: uvx twine check dist/*
22
+ - uses: actions/upload-artifact@v4
23
+ with:
24
+ name: dist
25
+ path: dist/
26
+
27
+ testpypi:
28
+ needs: build
29
+ if: github.event.release.prerelease == true
30
+ runs-on: ubuntu-latest
31
+ environment:
32
+ name: testpypi
33
+ url: https://test.pypi.org/p/interfaze
34
+ permissions:
35
+ id-token: write
36
+ steps:
37
+ - uses: actions/download-artifact@v4
38
+ with:
39
+ name: dist
40
+ path: dist/
41
+ - uses: pypa/gh-action-pypi-publish@release/v1
42
+ with:
43
+ repository-url: https://test.pypi.org/legacy/
44
+
45
+ pypi:
46
+ needs: build
47
+ if: github.event.release.prerelease == false
48
+ runs-on: ubuntu-latest
49
+ environment:
50
+ name: pypi
51
+ url: https://pypi.org/p/interfaze
52
+ permissions:
53
+ id-token: write
54
+ steps:
55
+ - uses: actions/download-artifact@v4
56
+ with:
57
+ name: dist
58
+ path: dist/
59
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,29 @@
1
+ name: Live QA
2
+
3
+ # Live e2e against the real API; gated on the INTERFAZE_API_KEY secret (never on PRs).
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ schedule:
8
+ - cron: "0 6 * * 1" # weekly, Monday 06:00 UTC
9
+
10
+ concurrency:
11
+ group: live-qa
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ live-qa:
16
+ name: live QA (multimodal + token usage + tasks)
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: astral-sh/setup-uv@v6
21
+ with:
22
+ python-version: "3.12"
23
+ enable-cache: true
24
+ - name: Install
25
+ run: uv sync
26
+ - name: Run live QA
27
+ env:
28
+ INTERFAZE_API_KEY: ${{ secrets.INTERFAZE_API_KEY }}
29
+ run: uv run python scripts/qa_live.py
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JigsawStack
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,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: interfaze
3
+ Version: 1.0.1
4
+ Summary: Official Interfaze SDK.
5
+ Project-URL: Homepage, https://interfaze.ai
6
+ Project-URL: Repository, https://github.com/InterfazeAI/interfaze-python
7
+ Author: Interfaze
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: ai,interfaze,ocr,openai,sdk,speech-to-text,web-search
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.9
15
+ Requires-Dist: openai<3,>=2
16
+ Provides-Extra: dev
17
+ Requires-Dist: langchain-openai>=1.3.5; (python_version >= '3.10') and extra == 'dev'
18
+ Requires-Dist: mypy>=1.11; extra == 'dev'
19
+ Requires-Dist: pydantic>=2; extra == 'dev'
20
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
21
+ Requires-Dist: pytest>=8; extra == 'dev'
22
+ Requires-Dist: respx>=0.21; extra == 'dev'
23
+ Requires-Dist: ruff>=0.6; extra == 'dev'
24
+ Provides-Extra: langchain
25
+ Requires-Dist: langchain-openai>=1.3.5; (python_version >= '3.10') and extra == 'langchain'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # interfaze-python
29
+
30
+ The official [Interfaze](https://interfaze.ai) SDK for Python.
31
+
32
+ - **Familiar chat surface** - `chat.completions`, streaming, tools, and structured output.
33
+ - **Typed Interfaze extras** - `precontext` (internal tool output), `reasoning`, and `vcache` (semantic-cache hit) on every response.
34
+ - **One-line task helpers** - OCR, web search, scraping, speech-to-text, translation, object/GUI detection, forecasting.
35
+ - **Multimodal inputs** - images, PDFs, audio, video, and CSV, by URL or base64.
36
+ - **Sync and async**, fully typed.
37
+
38
+ ## Learn more
39
+
40
+ - [interfaze.ai](https://interfaze.ai) - dashboard and API keys.
41
+ - [TypeScript / JavaScript SDK](https://github.com/InterfazeAI/interfaze-js).
42
+
43
+ ## Capabilities
44
+
45
+ | Category | Capabilities |
46
+ | ---------------- | ----------------------------------------------------------- |
47
+ | **Chat & text** | Chat completions, structured output, tools, reasoning |
48
+ | **Vision & OCR** | `tasks.ocr` - text and structured data from images and PDFs |
49
+ | **Web** | `tasks.web_search`, `tasks.scrape` |
50
+ | **Audio** | `tasks.transcribe` - speech-to-text |
51
+ | **Detection** | `tasks.object_detection`, `tasks.gui_detection` |
52
+ | **Translation** | `tasks.translate` |
53
+ | **Forecasting** | `tasks.forecast` - time-series prediction |
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ pip install interfaze
59
+ ```
60
+
61
+ ## Setup
62
+
63
+ Get an API key from the [Interfaze dashboard](https://interfaze.ai), then:
64
+
65
+ ```python
66
+ from interfaze import Interfaze
67
+
68
+ interfaze = Interfaze(api_key="sk_...") # or set INTERFAZE_API_KEY and call Interfaze()
69
+ ```
70
+
71
+ Async is identical via `AsyncInterfaze` (every call becomes `await`-able).
72
+
73
+ ## Usage
74
+
75
+ Chat completion:
76
+
77
+ ```python
78
+ res = interfaze.chat.completions.create(
79
+ messages=[{"role": "user", "content": "Write a haiku about deterministic AI."}],
80
+ )
81
+ print(res.choices[0].message.content)
82
+ print("cache hit:", res.vcache) # typed Interfaze extra
83
+ ```
84
+
85
+ Task helpers - each returns the extracted result directly (a `dict`/`list`/`str`, not a completion):
86
+
87
+ ```python
88
+ interfaze.tasks.ocr("https://example.com/receipt.jpg")
89
+ interfaze.tasks.web_search("latest AI agent news")
90
+ interfaze.tasks.transcribe("https://example.com/audio.wav")
91
+ interfaze.tasks.scrape("https://example.com/product")
92
+ interfaze.tasks.translate("Hello", to="French")
93
+ interfaze.tasks.object_detection("https://example.com/photo.jpg")
94
+ interfaze.tasks.gui_detection("https://example.com/screenshot.png")
95
+ interfaze.tasks.forecast("https://example.com/series.csv", periods=30)
96
+ ```
97
+
98
+ Structured output:
99
+
100
+ ```python
101
+ from interfaze import response_format
102
+
103
+ res = interfaze.chat.completions.create(
104
+ messages=[{"role": "user", "content": "Weather in Tokyo?"}],
105
+ response_format=response_format({
106
+ "type": "object",
107
+ "properties": {"city": {"type": "string"}, "temp_c": {"type": "number"}},
108
+ "required": ["city", "temp_c"],
109
+ }),
110
+ )
111
+ ```
112
+
113
+ Streaming - `.stream()` yields typed events, with the inline `<think>`/`<precontext>` side-channels
114
+ stripped from the content events:
115
+
116
+ ```python
117
+ stream = interfaze.chat.completions.stream(
118
+ messages=[{"role": "user", "content": "Tell me a story."}],
119
+ )
120
+ for event in stream:
121
+ if event.type == "content.delta":
122
+ print(event.delta, end="")
123
+ final = stream.get_final_completion()
124
+ ```
125
+
126
+ > `stream.text_deltas()` yields clean visible text only; `create(stream=True)` returns the raw
127
+ > chunk iterator (side-channel tags not stripped).
128
+
129
+ ## Inputs
130
+
131
+ ```python
132
+ from interfaze import inputs
133
+
134
+ inputs.image("https://…/a.png") # image_url part
135
+ inputs.file("https://…/doc.pdf") # file part (pdf/csv/xml/json/text/video…)
136
+ inputs.audio("https://…/a.wav") # input_audio part
137
+ inputs.data_url(raw_bytes, "image/png") # base64 data URI
138
+ inputs.from_path("./doc.pdf") # read a local file
139
+ ```
140
+
141
+ URLs and base64 both work; `image/gif` and `image/avif` are rejected client-side.
142
+
143
+ ## Interfaze extras
144
+
145
+ - `res.precontext` - raw outputs of any internal tools that ran (OCR/web/scrape/STT/forecast/…).
146
+ - `res.reasoning` - reasoning text (with `reasoning_effort="high"` and no schema).
147
+ - `res.vcache` - whether the semantic cache was hit.
148
+ - `reasoning_effort` also accepts `"on"`/`"off"`/`"auto"`.
149
+ - Guardrails: `create(guard=["S1", "S12_IMAGE"], …)`.
150
+ - Control options: `Interfaze(show_additional_info=..., bypass_moe=..., bypass_cache=..., admin_key=...)`.
151
+
152
+ ## LangChain
153
+
154
+ `pip install interfaze[langchain]` adds a chat model pointed at Interfaze that keeps the extras a stock `ChatOpenAI` drops:
155
+
156
+ ```python
157
+ from interfaze.langchain import ChatInterfaze
158
+
159
+ llm = ChatInterfaze() # reads INTERFAZE_API_KEY
160
+ res = llm.invoke("Summarize the latest AI news")
161
+ print(res.response_metadata.get("precontext"), res.response_metadata.get("vcache"))
162
+ ```
163
+
164
+ `precontext`/`reasoning`/`vcache` land on `response_metadata`, `{"type": "video", ...}` content blocks are accepted, and inline side-channel tags are stripped.
165
+
166
+ ## License
167
+
168
+ MIT
@@ -0,0 +1,141 @@
1
+ # interfaze-python
2
+
3
+ The official [Interfaze](https://interfaze.ai) SDK for Python.
4
+
5
+ - **Familiar chat surface** - `chat.completions`, streaming, tools, and structured output.
6
+ - **Typed Interfaze extras** - `precontext` (internal tool output), `reasoning`, and `vcache` (semantic-cache hit) on every response.
7
+ - **One-line task helpers** - OCR, web search, scraping, speech-to-text, translation, object/GUI detection, forecasting.
8
+ - **Multimodal inputs** - images, PDFs, audio, video, and CSV, by URL or base64.
9
+ - **Sync and async**, fully typed.
10
+
11
+ ## Learn more
12
+
13
+ - [interfaze.ai](https://interfaze.ai) - dashboard and API keys.
14
+ - [TypeScript / JavaScript SDK](https://github.com/InterfazeAI/interfaze-js).
15
+
16
+ ## Capabilities
17
+
18
+ | Category | Capabilities |
19
+ | ---------------- | ----------------------------------------------------------- |
20
+ | **Chat & text** | Chat completions, structured output, tools, reasoning |
21
+ | **Vision & OCR** | `tasks.ocr` - text and structured data from images and PDFs |
22
+ | **Web** | `tasks.web_search`, `tasks.scrape` |
23
+ | **Audio** | `tasks.transcribe` - speech-to-text |
24
+ | **Detection** | `tasks.object_detection`, `tasks.gui_detection` |
25
+ | **Translation** | `tasks.translate` |
26
+ | **Forecasting** | `tasks.forecast` - time-series prediction |
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ pip install interfaze
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ Get an API key from the [Interfaze dashboard](https://interfaze.ai), then:
37
+
38
+ ```python
39
+ from interfaze import Interfaze
40
+
41
+ interfaze = Interfaze(api_key="sk_...") # or set INTERFAZE_API_KEY and call Interfaze()
42
+ ```
43
+
44
+ Async is identical via `AsyncInterfaze` (every call becomes `await`-able).
45
+
46
+ ## Usage
47
+
48
+ Chat completion:
49
+
50
+ ```python
51
+ res = interfaze.chat.completions.create(
52
+ messages=[{"role": "user", "content": "Write a haiku about deterministic AI."}],
53
+ )
54
+ print(res.choices[0].message.content)
55
+ print("cache hit:", res.vcache) # typed Interfaze extra
56
+ ```
57
+
58
+ Task helpers - each returns the extracted result directly (a `dict`/`list`/`str`, not a completion):
59
+
60
+ ```python
61
+ interfaze.tasks.ocr("https://example.com/receipt.jpg")
62
+ interfaze.tasks.web_search("latest AI agent news")
63
+ interfaze.tasks.transcribe("https://example.com/audio.wav")
64
+ interfaze.tasks.scrape("https://example.com/product")
65
+ interfaze.tasks.translate("Hello", to="French")
66
+ interfaze.tasks.object_detection("https://example.com/photo.jpg")
67
+ interfaze.tasks.gui_detection("https://example.com/screenshot.png")
68
+ interfaze.tasks.forecast("https://example.com/series.csv", periods=30)
69
+ ```
70
+
71
+ Structured output:
72
+
73
+ ```python
74
+ from interfaze import response_format
75
+
76
+ res = interfaze.chat.completions.create(
77
+ messages=[{"role": "user", "content": "Weather in Tokyo?"}],
78
+ response_format=response_format({
79
+ "type": "object",
80
+ "properties": {"city": {"type": "string"}, "temp_c": {"type": "number"}},
81
+ "required": ["city", "temp_c"],
82
+ }),
83
+ )
84
+ ```
85
+
86
+ Streaming - `.stream()` yields typed events, with the inline `<think>`/`<precontext>` side-channels
87
+ stripped from the content events:
88
+
89
+ ```python
90
+ stream = interfaze.chat.completions.stream(
91
+ messages=[{"role": "user", "content": "Tell me a story."}],
92
+ )
93
+ for event in stream:
94
+ if event.type == "content.delta":
95
+ print(event.delta, end="")
96
+ final = stream.get_final_completion()
97
+ ```
98
+
99
+ > `stream.text_deltas()` yields clean visible text only; `create(stream=True)` returns the raw
100
+ > chunk iterator (side-channel tags not stripped).
101
+
102
+ ## Inputs
103
+
104
+ ```python
105
+ from interfaze import inputs
106
+
107
+ inputs.image("https://…/a.png") # image_url part
108
+ inputs.file("https://…/doc.pdf") # file part (pdf/csv/xml/json/text/video…)
109
+ inputs.audio("https://…/a.wav") # input_audio part
110
+ inputs.data_url(raw_bytes, "image/png") # base64 data URI
111
+ inputs.from_path("./doc.pdf") # read a local file
112
+ ```
113
+
114
+ URLs and base64 both work; `image/gif` and `image/avif` are rejected client-side.
115
+
116
+ ## Interfaze extras
117
+
118
+ - `res.precontext` - raw outputs of any internal tools that ran (OCR/web/scrape/STT/forecast/…).
119
+ - `res.reasoning` - reasoning text (with `reasoning_effort="high"` and no schema).
120
+ - `res.vcache` - whether the semantic cache was hit.
121
+ - `reasoning_effort` also accepts `"on"`/`"off"`/`"auto"`.
122
+ - Guardrails: `create(guard=["S1", "S12_IMAGE"], …)`.
123
+ - Control options: `Interfaze(show_additional_info=..., bypass_moe=..., bypass_cache=..., admin_key=...)`.
124
+
125
+ ## LangChain
126
+
127
+ `pip install interfaze[langchain]` adds a chat model pointed at Interfaze that keeps the extras a stock `ChatOpenAI` drops:
128
+
129
+ ```python
130
+ from interfaze.langchain import ChatInterfaze
131
+
132
+ llm = ChatInterfaze() # reads INTERFAZE_API_KEY
133
+ res = llm.invoke("Summarize the latest AI news")
134
+ print(res.response_metadata.get("precontext"), res.response_metadata.get("vcache"))
135
+ ```
136
+
137
+ `precontext`/`reasoning`/`vcache` land on `response_metadata`, `{"type": "video", ...}` content blocks are accepted, and inline side-channel tags are stripped.
138
+
139
+ ## License
140
+
141
+ MIT