Metadata-Version: 2.4
Name: langchain-apertis
Version: 0.2.0
Summary: Native LangChain integration for the Apertis AI API
Project-URL: Homepage, https://apertis.ai
Project-URL: Documentation, https://docs.apertis.ai/api/sdks/langchain/
Project-URL: Repository, https://github.com/apertis-ai/langchain-apertis
Project-URL: Issues, https://github.com/apertis-ai/langchain-apertis/issues
Author: Apertis
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: apertis,chat,langchain,llm
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
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: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <4.0,>=3.10
Requires-Dist: apertis<0.4.0,>=0.3.0
Requires-Dist: langchain-core<2.0.0,>=1.4.7
Provides-Extra: test
Requires-Dist: langchain-tests<2.0.0,>=1.1.9; extra == 'test'
Requires-Dist: pytest-asyncio<2.0.0,>=1.3.0; extra == 'test'
Requires-Dist: pytest<10.0.0,>=9.0.3; extra == 'test'
Description-Content-Type: text/markdown

# langchain-apertis

Native [LangChain](https://python.langchain.com/) integration for the
[Apertis AI API](https://apertis.ai). It uses the official `apertis` SDK directly and
does not depend on `langchain-openai`.

## Installation

```bash
pip install -U langchain-apertis
export APERTIS_API_KEY="..."
```

## Chat completions

```python
from langchain_apertis import ChatApertis

llm = ChatApertis(model="gpt-5.5", temperature=0)
print(llm.invoke("Explain what a native LangChain provider is.").text)
```

`bind_tools()` and `with_structured_output()` use Apertis' OpenAI-compatible tool
format. A current Web Search model keeps its exact `:web` model suffix and exposes
source records safely in `response_metadata["apertis"]["web_sources"]`.

```python
search = ChatApertis(
    model="gpt-5.5:web",
    web_results_count=5,
    web_content_length="medium",
)
response = search.invoke("What changed in this week's AI news?")
print(response.response_metadata["apertis"]["web_sources"])
```

Both current SDK Web Search stream-status shapes are exposed before model text. When the
SDK supplies a status string, `stream()` and `astream()` retain it and set
`response_metadata["apertis"]["web_search_status"]` to `"in_progress"`.

## Multimodal and audio chat

`ChatApertis` forwards LangChain's OpenAI-shaped image, input-audio, and video content
parts directly to the official SDK. Model availability remains account- and
model-dependent; the integration preserves the request contract rather than claiming a
static catalog.

```python
from langchain_core.messages import HumanMessage

vision = ChatApertis(model="gpt-5.5")
response = vision.invoke(
    [
        HumanMessage(
            content=[
                {"type": "text", "text": "Describe this image."},
                {"type": "image_url", "image_url": {"url": "https://example.com/cat.png"}},
            ]
        )
    ]
)
```

For audio-output requests, use the Apertis SDK-compatible `modalities` and `audio`
parameters. Returned audio data is retained in `response.additional_kwargs["audio"]`;
Web Search URL citations are retained in
`response.response_metadata["apertis"]["annotations"]`.

The current SDK's `response_format` and `extra_body` request fields are also direct
`ChatApertis` constructor parameters.

## Development verification

The public package metadata resolves published `apertis>=0.3.0` from PyPI.

```bash
uv sync --group dev
uv run pytest -m "not integration"
uv build
docker build -t langchain-apertis-test -f Dockerfile.test .
docker run --rm --network none langchain-apertis-test
```

## Publishing

After `apertis>=0.3.0` is available on PyPI, configure PyPI Trusted Publishing for
`apertis-ai/langchain-apertis`, `.github/workflows/publish.yml`, and the `pypi`
environment. The manual **Publish to PyPI** workflow uploads only when dispatched with
the `publish` confirmation value.
