Antler by Autoflux

Configuration

Setting up models, providers, environment variables, tracing with LangSmith, and assembling a real application.

Path: configuration

Third-party documentation. This is independently authored analysis of the public LangChain codebase — not the official docs, and not reviewed or endorsed by the LangChain team.

Configuration

Getting a LangChain app running is mostly provider configuration and environment wiring. This module covers the practical setup that the architecture module abstracted away.

Installing packages

LangChain is split into small installable packages — install what you use, not the whole monolith:

pip install langchain langchain-core langchain-openai langchain-text-splitters langchain-community

The core is langchain-core; langchain adds orchestration helpers; each provider has its own package (langchain-openai, langchain-anthropic, ...). langchain-community hosts integrations that don't warrant their own package. The TypeScript side is symmetric: @langchain/core, @langchain/openai, etc.

Model configuration

Chat models are configured at construction, with provider keys read from the environment by default:

  • model — the model name/version (e.g. gpt-4o-mini, claude-3-5-sonnet).
  • temperature, max_tokens (or max_completion_tokens), timeout — sampling and safety limits.
  • api_key, base_url — override the env default (e.g. for a local model server).
  • model_kwargs — passthrough to the provider's own options.

Keys come from environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, ...) by default — keep them out of code, and set them via .env or the platform.

Environment and tracing

  • LangSmith — set LANGCHAIN_TRACING_V2=true, LANGCHAIN_API_KEY=..., and LANGCHAIN_PROJECT=... to get full trace logging of every run (prompts, tool calls, costs). It is the debugging tool for anything beyond a toy.
  • Callbacks — the config argument of every runnable accepts callbacks, tags, and metadata, which flow into LangSmith and custom handlers.

Assembling a real application

  1. Define prompts as ChatPromptTemplate (with format_instructions where needed).
  2. Construct the model with the provider you're deploying against.
  3. Compose with parsers, retrievers, and tools.
  4. Wrap in a chain (create_retrieval_chain, AgentExecutor) or a LangGraph graph for stateful flows.
  5. Serve — LangChain is just Python/TS code; expose it via FastAPI/Next.js as ordinary functions. There is no LangChain-specific server to configure unless you adopt LangGraph Platform.

Configuration gotchas

  • Missing OPENAI_API_KEY surfaces at invoke time, not construction time — test early.
  • Model parameter names differ across providers (max_tokens vs max_completion_tokens); passing the wrong one fails only when the provider rejects it.
  • Local/self-hosted models: set base_url and possibly api_key="not-needed"; the OpenAI-compatible endpoint pattern works with many local servers.