Interfaze LangChain SDK
The official LangChain integration for Interfaze
Docs · limits · pricing · dashboard · Python SDK · TypeScript / JavaScript SDK
Install
pip install interfaze-langchain
# or: uv add interfaze-langchain · poetry add interfaze-langchain
This pulls in the interfaze client and the LangChain packages it builds on.
Setup
from interfaze_langchain import ChatInterfaze
llm = ChatInterfaze(api_key="sk_...") # or set INTERFAZE_API_KEY and call ChatInterfaze()
ChatInterfaze is a standard LangChain chat model, so the usual keywords (temperature, max_tokens, timeout, reasoning_effort, …) are forwarded; base_url and model default to the Interfaze endpoint and interfaze-beta.
Your first request
Extract structured data from an ID. Interfaze runs OCR for you, with_structured_output returns your schema, and the raw OCR lands on response_metadata["precontext"] — keep both with include_raw:
from langchain_core.messages import HumanMessage
from pydantic import BaseModel, Field
class IdCard(BaseModel):
first_name: str
last_name: str
dob: str = Field(description="Date of birth on the ID")
licence_number: str
out = llm.with_structured_output(IdCard, include_raw=True).invoke(
[
HumanMessage(
content=[
{"type": "text", "text": "Extract the details from this ID."},
{
"type": "image_url",
"image_url": {"url": "https://r2public.jigsawstack.com/interfaze/examples/id.jpg"},
},
]
)
]
)
print(out["parsed"]) # IdCard(first_name="IVÁN ICHET", …)
print(out["raw"].response_metadata.get("precontext")) # the raw OCR that produced it
Precontext
Interfaze returns fields a plain chat model would drop. ChatInterfaze surfaces them on both response_metadata and additional_kwargs:
res = llm.invoke("Which US public companies reported earnings today?")
res.response_metadata.get("precontext") # raw output of any tool Interfaze ran (OCR / web / scrape / …)
res.response_metadata.get("reasoning") # reasoning text (with reasoning_effort and no schema)
res.response_metadata.get("vcache") # whether the semantic cache was hit
Chat
Pass a plain string for a one-off, or a message list for multi-turn.
from langchain_core.messages import HumanMessage, SystemMessage
res = llm.invoke(
[
SystemMessage("You are concise."),
HumanMessage("Which US public companies reported earnings today?"),
]
)
res.content # a web search backs the answer here
Streaming
Stream the reply as it's generated; the inline <think>/<precontext> side-channels are stripped from the streamed content:
for chunk in llm.stream("Summarize this week's top AI research and cite your sources."):
print(chunk.content, end="", flush=True)
Structured output
with_structured_output takes a Pydantic model (or JSON schema) and returns instances. Pass include_raw=True to also get the underlying AIMessage (and its precontext).
from pydantic import BaseModel
class Receipt(BaseModel):
merchant: str
total: float
structured = llm.with_structured_output(Receipt)
structured.invoke(
[
HumanMessage(
content=[
{"type": "text", "text": "Extract this receipt."},
{
"type": "image_url",
"image_url": {"url": "https://jigsawstack.com/preview/vocr-example.jpg"},
},
]
)
]
) # -> Receipt(merchant="Walmart", total=144.02)
Tools and function calling
Bind tools with bind_tools, then read tool_calls off the response:
from langchain_core.tools import tool
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
...
res = llm.bind_tools([get_weather]).invoke("What's the weather in Tokyo?")
res.tool_calls # [{"name": "get_weather", "args": {"city": "Tokyo"}, "id": ...}]
Reasoning
The reasoning text comes back on response_metadata["reasoning"]. Set reasoning_effort on the model, or bind it per-chain:
llm = ChatInterfaze(
reasoning_effort="high"
) # also "on" / "off" / "auto"; or llm.bind(reasoning_effort="high")
res = llm.invoke("Which region should we launch in first, and why?")
res.response_metadata.get("reasoning")
Multimodal Inputs
Images, audio, PDFs, Word documents (.docx), and CSV use standard LangChain content parts, by URL or base64:
from langchain_core.messages import HumanMessage
llm.invoke(
[
HumanMessage(
content=[
{"type": "text", "text": "Summarize this document."},
{
"type": "file",
"file": {"filename": "paper.pdf", "file_data": "https://arxiv.org/pdf/1706.03762"},
},
]
)
]
)
Video rides on an Interfaze file part via a {"type": "video", ...} block:
llm.invoke(
[
HumanMessage(
content=[
{"type": "text", "text": "What happens in this clip?"},
{"type": "video", "url": "https://…/clip.mp4"},
]
)
]
)
A video block accepts
urlorbase64(with an optionalmime_type), plus an optionalextras{"filename": …}. The container mime type is inferred from the URL extension when you don't pass one. Interfaze has no file store, sofile_idis not supported.
Async and batch
Every call has an async twin, and batch fans out concurrently:
await llm.ainvoke("Hello")
async for chunk in llm.astream("Hello"):
print(chunk.content, end="")
llm.batch(["Summarize A", "Summarize B", "Summarize C"])
Chains (LCEL)
Chain ChatInterfaze like any other LangChain runnable, via |:
from langchain_core.prompts import ChatPromptTemplate
chain = ChatPromptTemplate.from_template("Translate to {lang}: {text}") | llm
chain.invoke({"lang": "French", "text": "Hello"})
Client options
Set router, cache, and streaming behavior once on the client:
llm = ChatInterfaze(
show_additional_info=True, # emit inline <precontext> while streaming
bypass_cache=True, # skip the semantic cache
bypass_moa=True, # skip the mixture-of-architecture router
)
show_additional_info is the only way to get precontext while streaming — non-streaming responses always carry it. bypass_cache matters when you need a fresh generation: a cache hit replays the stored answer, which has no reasoning attached.
The request timeout defaults to 900 s, because a single call may run OCR, a web search or a transcription inline. Pass timeout= to change it.
Tasks and guardrails
Interfaze reads <task> and <guard> tags from the first system message, so both work through a plain LangChain SystemMessage:
from langchain_core.messages import HumanMessage, SystemMessage
llm.invoke([SystemMessage("<task>web_search</task>"), HumanMessage("GLP-1 research paper")])
llm.invoke(
[SystemMessage("<guard>S1, S2, S3</guard>"), HumanMessage("How to kill a human?")]
) # -> "unsafe S1"
One task at a time, from ocr, object_detection, gui_detection, web_search, scraper, translate, speech_to_text, forecast, classification. A task cannot be combined with a non-empty structured-output schema.
For the one-shot tasks.* helpers (run_task), use the core interfaze client directly.
Server limits
ChatInterfaze forwards standard LangChain options, but validates only the subset supported by Interfaze:
| Option | Accepted |
|---|---|
temperature |
0–1 (values above 1 are a 400) |
max_tokens |
1–32000 |
reasoning_effort |
minimal, low, medium, high, plus on / off / auto |
tool_choice |
ignored — the router always picks |
stop, n, seed, logprobs |
ignored |
Errors
from interfaze import BadRequestError, InterfazeError, RateLimitError
ChatInterfaze raises InterfazeError for client-side problems (a missing API key). Everything else is an APIError subclass carrying status_code and code - BadRequestError (400), AuthenticationError (401), RateLimitError (429), and so on.
Capabilities
| Use case | Entry point |
|---|---|
| Chat | invoke / stream |
| Structured output | with_structured_output(Model) |
| Tools | bind_tools([...]) |
| Reasoning | reasoning_effort |
| Multimodal inputs | content parts + {"type": "video"} |
| Precontext | response_metadata["precontext"] |
| Async and batch | ainvoke / astream / batch |
| Chains | LCEL (|) |
| Client options | bypass_cache=True, … |
| Tasks / guardrails | SystemMessage("<task>…</task>") |
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interfaze_langchain-1.0.0.tar.gz.
File metadata
- Download URL: interfaze_langchain-1.0.0.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1272eabab5ed264e42da2b9cbd9e41d97f99647a53aa05e4ecf7b8d16d2a223
|
|
| MD5 |
4376039e9920f415cb5aa219b4100477
|
|
| BLAKE2b-256 |
17d463f7b36b513852169ae8cb51ec5673e3d542133aaa722421dbc810efdc5e
|
Provenance
The following attestation bundles were made for interfaze_langchain-1.0.0.tar.gz:
Publisher:
publish.yml on InterfazeAI/langchain-interfaze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interfaze_langchain-1.0.0.tar.gz -
Subject digest:
e1272eabab5ed264e42da2b9cbd9e41d97f99647a53aa05e4ecf7b8d16d2a223 - Sigstore transparency entry: 2414169988
- Sigstore integration time:
-
Permalink:
InterfazeAI/langchain-interfaze@5b841f53c61cc028e333643935323e352f0fa923 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/InterfazeAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5b841f53c61cc028e333643935323e352f0fa923 -
Trigger Event:
release
-
Statement type:
File details
Details for the file interfaze_langchain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: interfaze_langchain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
559ac04ea5a4fa9e344e6dcf7232b5cc50f2c3812125f29c08e384d5af2cb388
|
|
| MD5 |
32e0510006b98fcc4de0900f3529d8cf
|
|
| BLAKE2b-256 |
0ae54a0877581b9fdc5460214f216abe07ff29a08fcf677531dd3d1e8fff7b06
|
Provenance
The following attestation bundles were made for interfaze_langchain-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on InterfazeAI/langchain-interfaze
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
interfaze_langchain-1.0.0-py3-none-any.whl -
Subject digest:
559ac04ea5a4fa9e344e6dcf7232b5cc50f2c3812125f29c08e384d5af2cb388 - Sigstore transparency entry: 2414170138
- Sigstore integration time:
-
Permalink:
InterfazeAI/langchain-interfaze@5b841f53c61cc028e333643935323e352f0fa923 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/InterfazeAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5b841f53c61cc028e333643935323e352f0fa923 -
Trigger Event:
release
-
Statement type: