LangChain Baseline
In-process reference implementation using LangChain agents with direct tool integration and streaming support.
Architecture
How It Works
- Receives OpenAI-compatible chat completion requests.
- Runs a vision check to identify image workloads.
- Uses keyword and LLM verification to decide fast path vs agent path.
- Executes LangChain agents and tools in-process.
- Streams SSE responses with reasoning content and artifacts.
Request Flow
LangChain uses the same OpenAI-compatible payloads and streams results over SSE.
curl -N -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "baseline-langchain", "messages": [{"role": "user", "content": "Generate an image of a cat"}], "stream": true}'Features
In-process execution
Runs entirely inside a FastAPI process without external sandboxing.
Tool-rich agent
Image, video, audio, TTS, deep research, and code execution tools are built in.
Vision routing
Image requests route to dedicated vision models before tool execution.
Streaming responses
SSE streaming delivers reasoning content, artifacts, and final responses.
Extensible tool system
Add or replace tools via LangChain tool bindings.
Fast path fallback
Simple prompts go directly to ChatOpenAI for speed and cost control.
Configuration
Server configuration
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_HOST | 0.0.0.0 | Server host binding for the API. |
| BASELINE_LANGCHAIN_PORT | 8080 | Server port for the API. |
| BASELINE_LANGCHAIN_DEBUG | false | Enable debug logging and verbose output. |
Model configuration
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_MODEL | gpt-4o-mini | Primary LLM model used by the agent and fast path. |
| BASELINE_LANGCHAIN_OPENAI_API_KEY | - | OpenAI-compatible API key for the main LLM. |
| BASELINE_LANGCHAIN_OPENAI_BASE_URL | https://api.openai.com/v1 | OpenAI-compatible base URL for the main LLM. |
| BASELINE_LANGCHAIN_CHUTES_API_KEY | - | Chutes API key for image and TTS tools. |
| BASELINE_LANGCHAIN_CHUTES_API_BASE | https://llm.chutes.ai/v1 | Chutes API base URL for tool calls. |
Search and research
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_TAVILY_API_KEY | - | Tavily API key for web search. |
| BASELINE_LANGCHAIN_CHUTES_SEARCH_URL | https://chutes-search.onrender.com | Chutes search base URL for deep research. |
Vision routing
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_VISION_MODEL_PRIMARY | Qwen/Qwen3-VL-235B-A22B-Instruct | Primary vision model for image requests. |
| BASELINE_LANGCHAIN_VISION_MODEL_FALLBACK | chutesai/Mistral-Small-3.2-24B-Instruct-2506 | Fallback vision model for image requests. |
| BASELINE_LANGCHAIN_VISION_MODEL_TIMEOUT | 60.0 | Timeout for vision model requests (seconds). |
| BASELINE_LANGCHAIN_ENABLE_VISION_ROUTING | true | Route image requests to vision models. |
Artifacts
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_ARTIFACTS_DIR | /tmp/janus_baseline_langchain_artifacts | Local path for artifacts generated by the agent. |
| BASELINE_LANGCHAIN_ARTIFACT_BASE_URL | /artifacts | Base URL for served artifacts. |
Routing controls
| Variable | Default | Description |
|---|---|---|
| BASELINE_LANGCHAIN_COMPLEXITY_THRESHOLD | 100 | Token threshold for complexity detection. |
| BASELINE_LANGCHAIN_ALWAYS_USE_AGENT | false | Force all requests onto the agent path. |
Container overrides
Alternative environment variables honored by container deployments.
| Variable | Default | Description |
|---|---|---|
| HOST | - | Container host override. |
| PORT | - | Container port override. |
| DEBUG | - | Container debug override. |
| LOG_LEVEL | - | Container log level override. |
| OPENAI_API_KEY | - | Container OpenAI API key alias. |
| OPENAI_BASE_URL | - | Container OpenAI base URL alias. |
| CHUTES_API_KEY | - | Container Chutes API key alias. |
| TAVILY_API_KEY | - | Container Tavily API key alias. |
Getting Started
cd baseline-langchain
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
python -m janus_baseline_langchain.main