Pattern guide
LangChain Integration Pattern
Privocio does not ship a native LangChain plugin. Use the OpenAI-compatible client for transcription, then pass structured text into your LangChain agent chain. Agent output mode reduces tokens before the LLM step.
Voice → transcript → agent
Separate STT (Privocio) from your agent LLM provider. Keeps voice data off shared training pipelines while using familiar LangChain patterns.
from openai import OpenAI
from langchain_openai import ChatOpenAI
# Transcription client — Privocio as Whisper backend
stt = OpenAI(
api_key="YOUR_PRIVOCIO_KEY",
base_url="https://api.privocio.com/v1",
)
def transcribe_audio(path: str) -> str:
with open(path, "rb") as f:
result = stt.audio.transcriptions.create(
model="whisper-1",
file=f,
)
return result.text
# Agent LLM (separate provider) consumes cleaned transcript
llm = ChatOpenAI(model="gpt-4o")
transcript = transcribe_audio("user_voice.wav")
response = llm.invoke(f"User said: {transcript}")See also AI agents use case · LangChain voice agent guide · OpenAI SDK integration
Output modes (Agent)